Problem with SSCANF
#1

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

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

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]");
Reply
#4

Hi,

this wont work. Is there another opinion?

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)