• 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(playeridparams[]) {

    new 
        
targetidstring[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(playerid0xFF0000FF"Syntax: {FFFFFF}/freezeplayer [playerid/name]");

    if (
targetid == INVALID_PLAYER_ID)
        return 
SendClientMessage(playerid0xFF0000FF"Error: {FFFFFF}The specified player is not connected or is a NPC.");
    
    
GetPlayerName(targetidnamesizeof name); //this is used to get the player's name and store it in the `name` variable
    
    
format(stringsizeof string"You've frozen %s."name);
    
SendClientMessage(playerid0xFF0000FFstring);
    
    
TogglePlayerControllable(targetidfalse); //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

Forum Jump: