Issue with sscanf
#1

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;
}
Reply
#2

any suggestions? anyone?
Reply
#3

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;
}
Reply
#4

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?
Reply
#5

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
Reply
#6

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

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.
Reply
#8

try change uud to sss
Reply
#9

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


Forum Jump:


Users browsing this thread: 4 Guest(s)