07.02.2013, 23:50
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:
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:
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;
}
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);

