Samp Sscanf

#include #include CMD:sethp(playerid, params[]) new targetid, Float:health; // sscanf checks if params contains an integer (i) and a float (f) if (sscanf(params, "if", targetid, health)) return SendClientMessage(playerid, -1, "USAGE: /sethp [playerid] [health]"); if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Error: That player is not online."); SetPlayerHealth(targetid, health); SendClientMessage(playerid, -1, "Health updated!"); return 1; Use code with caution. Copied to clipboard

Place the sscanf.dll (Windows) or .so (Linux) in your plugins folder. Add sscanf to the plugins line in your server.cfg . samp sscanf

new cmd[32], id, cash; if(sscanf(cmdtext, "s[32]dd", cmd, id, cash)) return SendClientMessage(playerid, -1, "Usage: /givecash [ID] [amount]"); if(strcmp(cmd, "/givecash", true) == 0) Arrays and Enums return 1; Here is a

You can make parameters optional by using the K syntax or by checking the return value. However, the most modern way is using the z specifier for strings that might not be there. 2. Arrays and Enums Arrays and Enums return 1

return 1;

Here is a "piece" of code for a /sethp command that takes a player ID and a health value.