31.12.2016, 15:42
How to make a command that only 1 player can use it like a roof top only 1 guy can use it ??
COMMAND:yourcommand(playerid,params[]){
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
if(strcmp(name,"aymane123"))return 0;
//Your command
return 1;
}
CMD:test(0,params[]) {//Only ID: 0 could use it.
CMD:gopen( playerid, params[] ) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,sizeof(name)); if(strcmp(name,"aymane123"))return 0; if( isnull( params ) ) return SendClientMessage( playerid, -1, "Syntax: /gopen [password]" ); new szName[24], gate = -1; GetPlayerName( playerid, szName, 24 ); for( new i = 0; i != MAX_GATES; i++ ) if( GateInfo[i][gCreated] == 1 ) if( strval( params ) == GateInfo[i][gPassword] ) { gate = i; break; } if( gate != -1 ) { if( !IsObjectMoving( GateInfo[gate][gObject] ) ) { if( IsPlayerInRangeOfPoint( playerid, 10.0, GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ] ) ) { if( GateInfo[gate][gStatus] == GATE_STATE_CLOSED ) { MoveObject( GateInfo[gate][gObject], GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ]-5.3, 7.0 ); SendClientMessage( playerid, -1, "You opened the gate." ); } else return SendClientMessage( playerid, -1, "The gate is already open." ); } else return SendClientMessage( playerid, -1, "You're not near any gate." ); } else return SendClientMessage( playerid, -1, "You must wait untill the gate has moved." ); } else return SendClientMessage( playerid, -1, "Invalid password." ); return 1; }
2- CMD:teleport(playerid, params[]) { SetPlayerPos(playerid, x,y,z) SendClientMessage(playerid, -1, "YOU HAVE BEEN TELEPORTER"); return 1; }
To make Command Follow this Steps:
1- #include <zcmd> Код:
2- CMD:teleport(playerid, params[]) { SetPlayerPos(playerid, x,y,z) SendClientMessage(playerid, -1, "YOU HAVE BEEN TELEPORTER"); return 1; } |