SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 28/07/2010, 12:40 PM   #1
Warlock
Little Clucker
 
Join Date: Jun 2008
Location: USA , Fremont, California, 94538-1257
Posts: 19
Reputation: 0
Question Issue with sscanf

I'm having an issue here. For some apparent reason this command I made isn't working at all. I figure the issue is
Code:
if (sscanf(params,"uud",Driver,Passenger,Seat))
"uud" . How can I fix this?

Code:
dcmd_incar(playerid,params[])
{
if(PlayerInfo[playerid][Level] >= 2) {
    	new Driver,Seat,Passenger;
	if (sscanf(params,"uud",Driver,Passenger,Seat))
	{
		SendClientMessage(playerid,0xFF0000FF, "Usage: \"/incar <PlayerID Driver> <PlayerID Passenger> <Seat>\"");
	}
	{
		new VehDr,VehPas;
		VehDr = GetPlayerVehicleID(Driver);
		VehPas = GetPlayerVehicleID(Passenger);
		if (VehDr>0)
		{
			PutPlayerInVehicle(VehDr,VehPas,Seat);
		}}
	}
	return 1;
}
Warlock is offline  
Old 29/07/2010, 07:27 AM   #2
Warlock
Little Clucker
 
Join Date: Jun 2008
Location: USA , Fremont, California, 94538-1257
Posts: 19
Reputation: 0
Default Re: Issue with sscanf

any suggestions? anyone?
Warlock is offline  
Old 29/07/2010, 07:45 AM   #3
Kyosaur
Gangsta
 
Kyosaur's Avatar
 
Join Date: Mar 2008
Location: USA - California
Posts: 973
Reputation: 349
Default Re: Issue with sscanf

Try this:

Code:
dcmd_incar(playerid,params[])
{
	if(PlayerInfo[playerid][Level] >= 2)
	{
		new Driver,Seat,Passenger;

		if (!sscanf(params,"uud",Driver,Passenger,Seat))
		{
			new VehDr,VehPas;
			VehDr = GetPlayerVehicleID(Driver);
			VehPas = GetPlayerVehicleID(Passenger);
			
			if (VehDr>0)
			{
				PutPlayerInVehicle(VehDr,VehPas,Seat);
				return 1;
			}
			else
			{
			    SendClientMessage(playerid,0xFF0000FF, "Error: Please specify a drive thats actually in a vehicle!");
			    return 1;
			}
		}
		SendClientMessage(playerid,0xFF0000FF, "Usage: \"/incar <PlayerID Driver> <PlayerID Passenger> <Seat>\"");
		return 1;
	}
	SendClientMessage(playerid,0xFF0000FF, "Error: You have to be level 2 to use this command!");
	return 1;
}

Last edited by Kyosaur; 29/07/2010 at 08:04 AM.
Kyosaur is offline  
Old 04/08/2010, 05:25 AM   #4
Warlock
Little Clucker
 
Join Date: Jun 2008
Location: USA , Fremont, California, 94538-1257
Posts: 19
Reputation: 0
Default Re: Issue with sscanf

its still not working dam. what i want it to do is when i type that command , i want to put a player in a players car in a certain seat. /incar <PlayerID Driver> <PlayerID Passenger> <Seat>. anything u suggest?
Warlock is offline  
Old 04/08/2010, 05:34 AM   #5
JaTochNietDan
High-roller
 
JaTochNietDan's Avatar
 
Join Date: Apr 2007
Location: Republic of Ireland
Posts: 2,502
Reputation: 363
Default Re: Issue with sscanf

Simple mistake with the code he posted

pawn Code:
dcmd_incar(playerid,params[])
{
    if(PlayerInfo[playerid][Level] >= 2)
    {
        new Driver,Seat,Passenger;

        if (!sscanf(params,"uud",Driver,Passenger,Seat))
        {
            new VehDr = GetPlayerVehicleID(Driver);
           
            if (IsPlayerInAnyVehicle(Driver))
            {
                PutPlayerInVehicle(Passenger,VehDr,Seat);
            }
            else
            {
                SendClientMessage(playerid,0xFF0000FF, "Error: Please specify a driver that's actually in a vehicle!");
            }
            return 1;
        }
        SendClientMessage(playerid,0xFF0000FF, "Usage: \"/incar <PlayerID Driver> <PlayerID Passenger> <Seat>\"");
        return 1;
    }
    SendClientMessage(playerid,0xFF0000FF, "Error: You have to be level 2 to use this command!");
    return 1;
}

He was putting the passengers vehicle ID in the drivers vehicle ID, which wouldn't work as you might imagine
JaTochNietDan is offline  
Old 04/08/2010, 09:24 AM   #6
Danny
High-roller
 
Danny's Avatar
 
Join Date: Jul 2010
Location: In a galaxy far far away, near the Netherlands
Posts: 1,097
Reputation: 2128
Default Re: Issue with sscanf

Are you sure you can't use 'iii'? I always use that and it works fine to me.
Danny is offline  
Old 04/08/2010, 03:10 PM   #7
JaTochNietDan
High-roller
 
JaTochNietDan's Avatar
 
Join Date: Apr 2007
Location: Republic of Ireland
Posts: 2,502
Reputation: 363
Default Re: Issue with sscanf

Quote:
Originally Posted by -Danny- View Post
Are you sure you can't use 'iii'? I always use that and it works fine to me.
Yes, but "u" is better in this situation as it is specifically made for getting playerid from a name or ID.
JaTochNietDan is offline  
Old 04/08/2010, 04:01 PM   #8
DRIFT_HUNTER
High-roller
 
Join Date: Oct 2009
Posts: 2,198
Reputation: 229
Default Re: Issue with sscanf

try change uud to sss
DRIFT_HUNTER is offline  
Old 04/08/2010, 04:28 PM   #9
Daren_Jacobson
Huge Clucker
 
Join Date: Jun 2008
Posts: 424
Reputation: 6
Default Re: Issue with sscanf

DRIFT_HUNTER, that has to be the stupidest suggestion I have ever seen.
pawn Code:
dcmd_incar(playerid,params[])
{
if(PlayerInfo[playerid][Level] >= 2) {
        new Driver,Seat,Passenger;
    if (sscanf(params,"uud",Driver,Passenger,Seat))
    {
        SendClientMessage(playerid,0xFF0000FF, "Usage: \"/incar <PlayerID Driver> <PlayerID Passenger> <Seat>\"");
    }
    else
    {
        new VehDr;
        VehDr = GetPlayerVehicleID(Driver);
        if (VehDr>0)
        {
            PutPlayerInVehicle(Passenger,VehDr,Seat);
        }
    }
    return 1;
}
__________________
Daren_Jacobson is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help with sscanf matthewdriftking Help Archive 3 28/07/2010 08:10 AM
sscanf legodude Help Archive 6 11/07/2010 10:07 PM
sscanf help please! SiJ Help Archive 14 19/12/2009 12:14 PM
[Help] sscanf+YSI Ace_Menace Help Archive 15 02/07/2009 11:25 AM
sscanf Help PLEASE! Kodman262 Help Archive 9 13/02/2009 11:02 PM


All times are GMT. The time now is 10:38 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.