2019-04-18, 08:05 AM
(This post was last modified: 2019-04-18, 08:08 AM by Gravityfalls.)
The code looks worse the way you write it because you use brackets just for a single "return" statement and leave absolutely no spacing in between.
PHP Code:
CMD:freezeplayer(playerid, params[]) {
new
targetid, string[128], name[MAX_PLAYER_NAME]; //name string is to store player's name, the is to account for null character
if (sscanf(params, "r", targetid)) //?r? specifier tells sscanf to look for a playerid. Some will tell you to use ?u? but that looks for both players AND npcs, either way it will work but if you don't want npcs to be included, use ?r? for playerid parameters
return SendClientMessage(playerid, 0xFF0000FF, "Syntax: {FFFFFF}/freezeplayer [playerid/name]");
if (targetid == INVALID_PLAYER_ID)
return SendClientMessage(playerid, 0xFF0000FF, "Error: {FFFFFF}The specified player is not connected or is a NPC.");
GetPlayerName(targetid, name, sizeof name); //this is used to get the player's name and store it in the `name` variable
format(string, sizeof string, "You've frozen %s.", name);
SendClientMessage(playerid, 0xFF0000FF, string);
TogglePlayerControllable(targetid, false); //this function will toggle the player's ability to move, depending on whether its toggled true or false (1 or 0)
return 1;
}