Posts: 56
Threads: 17
Joined: Dec 2018
Reputation:
0
How can I make a command with optional options? Like...
/kill <targetid> (optional)
If you type "/kill" it sets your hp to 0
If you type "/kill 4" it sets id 4's hp to 0
Is this possible without making it super complicated?
Posts: 1,506
Threads: 13
Joined: Jun 2015
PHP код:
CMD:kill(playerid, params[]) {
new
lookupid;
if (sscanf(params, "U", lookupid)) {
SendClientMessage(playerid, -1, "USAGE: You can use \"/kill [playerid]\"");
SetPlayerHealth(playerid, 0.0);
}
else {
if (!IsPlayerConnected(lookupid)) {
return SendClientMessage(playerid, -1, "ERROR: The specified player is not connected.");
}
SetPlayerHealth(lookupid, 0.0);
}
return 1;
}
You can find the list of supported specifiers for sscanf here:
https://sampforum.blast.hk/showthread.php?tid=570927
Posts: 3,085
Threads: 37
Joined: Nov 2012
Reputation:
0
You've got to be kidding me...