SA-MP Forums Archive
Problem 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)
+--- Thread: Problem with SSCANF (/showthread.php?tid=331885)



Problem with SSCANF - ThomasTailor93 - 06.04.2012

Hello,

I've got a problem with this command. /goto car ID should teleport me to the car. But the problem is, that the command wont work. The usage of /goto car works, but the ID wont work! Is there any faults in this code? And how can I fix the problem?

pawn Код:
ocmd:goto(playerid,params[])
{
if(!IsPlayerConnected(playerid)) return 1;
new carid,giveplayerid,Float:positionx,Float:positiony,Float:positionz,commandtext[15];
GetPlayerName(playerid,PlayerInfo[playerid][pName],MAX_PLAYER_NAME);
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid,COLOR_GREY,"* You are not authorized, to use this command!");
if(sscanf(params,"s[15]",commandtext))
{
SendClientMessage(playerid,COLOR_GREY,"USAGE: /goto [Text]");
SendClientMessage(playerid,COLOR_GREY,"available positions: ls,lv,sf,car,mark,player");
return 1;
}
if(strcmp(commandtext,"car",true) == 0)
{
if(sscanf(params,"i",carid)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /goto car [ID]");
GetVehiclePos(carid,positionx,positiony,positionz);
if(GetPlayerState(playerid) == 2)
{
SetVehiclePos(GetPlayerVehicleID(playerid),positionx,positiony,positionz);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else SetPlayerPos(playerid,positionx,positiony,positionz);
SendClientMessage(playerid, COLOR_YELLOW, "* You have been teleported to this car!");
SetPlayerInterior(playerid,0);
}
return 1;
}
I hope, anyone can help me!

Regards, ThomasTailor93


Re: Problem with SSCANF - Vince - 06.04.2012

I think replacing this:
pawn Код:
if(sscanf(params,"i",carid))
With this might work:
pawn Код:
if(sscanf(params,"'car 'i",carid))



Re: Problem with SSCANF - MadeMan - 06.04.2012

pawn Код:
new extra[16];
pawn Код:
if(sscanf(params,"s[15]S()[16]",commandtext,extra))
pawn Код:
if(sscanf(extra,"i",carid)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /goto car [ID]");



AW: Problem with SSCANF - ThomasTailor93 - 06.04.2012

Hi,

this wont work. Is there another opinion?

//Edit: Okay, I will try this code.

//Edit: Pretty cool, it works. Thank you!