SA-MP Forums Archive
Issue with sscanf - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Issue with sscanf (/showthread.php?tid=163664)



Issue with sscanf - Warlock - 28.07.2010

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;
}



Re: Issue with sscanf - Warlock - 29.07.2010

any suggestions? anyone?


Re: Issue with sscanf - Kyosaur - 29.07.2010

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;
}



Re: Issue with sscanf - Warlock - 04.08.2010

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?


Re: Issue with sscanf - JaTochNietDan - 04.08.2010

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


Re: Issue with sscanf - Danny - 04.08.2010

Are you sure you can't use 'iii'? I always use that and it works fine to me.


Re: Issue with sscanf - JaTochNietDan - 04.08.2010

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.


Re: Issue with sscanf - DRIFT_HUNTER - 04.08.2010

try change uud to sss


Re: Issue with sscanf - Daren_Jacobson - 04.08.2010

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;
}