• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Create Basic Commands
#2
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; }
  Reply


Messages In This Thread
How to Create Basic Commands - by DTV - 2019-04-18, 01:50 AM
RE: How to Create Basic Commands - by Gravityfalls - 2019-04-18, 08:05 AM
RE: How to Create Basic Commands - by kristo - 2019-04-18, 12:56 PM
RE: How to Create Basic Commands - by DTV - 2019-04-18, 06:49 PM