Making a variable with tmp
#4

Well first off you should use sscanf for handling commands with extra parameters: https://sampforum.blast.hk/showthread.php?tid=120356.

Example using sscanf with OnPlayerCommandText:
pawn Код:
if(!strcmp(cmdtext, "/hi", true, 3))
{
    new otherplayerid;
    if(sscanf(cmdtext[6], "i", otherplayerid)) return SendClientMessage(playerid,-1,"Usage: /hi [player id]");
    else {
        SendClientMessage(otherplayerid,-1,"Hello!");
    }
    return 1;
}
This would send message 'Hello!' to the specified player id, or return an error message if no ID was entered.

That example can be altered to become any command with 1 integer as a parameter (commands with other player ids, a vehicle id, etc). Just change the length in the strcmp line to the command length and the length in the sscanf line to the command length+1.

And once you get your command worked out you don't need to assign 'tmp' to VehID as you're doing now, you could just use this instead:
pawn Код:
GetVehiclePos(tmp, X, Y, Z);
Reply


Messages In This Thread
Making a variable with tmp - by jakejohnsonusa - 07.02.2013, 20:56
Re: Making a variable with tmp - by Misiur - 07.02.2013, 21:02
Re: Making a variable with tmp - by jakejohnsonusa - 07.02.2013, 21:09
Re: Making a variable with tmp - by zDevon - 07.02.2013, 23:50
Respuesta: Making a variable with tmp - by kirk - 07.02.2013, 23:58

Forum Jump:


Users browsing this thread: 1 Guest(s)