SA-MP Forums Archive
Command Usage - 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: Command Usage (/showthread.php?tid=624328)



Command Usage - ISmokezU - 14.12.2016

Is it possible to make a command with parameter and without parameter at the same time? like for instance,/slap
if i just type it just like that. it would look for the closest person to slap,if i input a parameter it would look for that specific player. i dont want it to show like /slap [name/id] Thanks.


Re: Command Usage - Konstantinos - 14.12.2016

https://sampforum.blast.hk/showthread.php?tid=602923

Quote:
Originally Posted by ******
pawn Код:
sscanf(params, "U(-1)", id);
if (id == -1)
{
    // No player was entered.
}
else if (id == INVALID_PLAYER_ID)
    // Entered player is not connected.
}



Re: Command Usage - Vince - 14.12.2016

So, instead of returning that message you find the closest player.

PHP код:
new targetid INVALID_PLAYER_ID;

if(
sscanf(params"r"targetid))
{
    
targetid FindClosest(...);
}

SetPlayerPos(targetid, ...);