Cmd for 1 Player.
#1

How to make a command that only 1 player can use it like a roof top only 1 guy can use it ??
Reply
#2

There are several ways to do it. You can either create a player variable for each player which holds the values true or false. So if the value is true for the player then he can use it. A less elegant but at this point faster way to do it is if you just compare the playernames. For example if you are the server owner and you are the only one who can use it and your name is aymane123 then you can do something like that:

PHP код:
COMMAND:yourcommand(playerid,params[]){
   new 
name[MAX_PLAYER_NAME];
   
GetPlayerName(playerid,name,sizeof(name));
   if(
strcmp(name,"aymane123"))return 0;
   
//Your command
   
return 1;

Reply
#3

You could also use it for a specific ID

Код:
CMD:test(0,params[]) {//Only ID: 0 could use it.
Edit: ^^
Reply
#4

tthx guys.
Reply
#5

any help got this ?
Код:
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;
}
Reply
#6

Errors? does it works? Say Something...
Reply
#7

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;
}
Hope you understand <3
Reply
#8

i am not talking about that its too easy and that code when i run it as a FS it compiles with warning and on the server doesnt have any effect.
Reply
#9

Quote:
Originally Posted by RedRex
Посмотреть сообщение
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;
}
Hope you understand <3
Get off the post. he already knows how to make a command

Quote:
Originally Posted by aymane123
Посмотреть сообщение
i am not talking about that its too easy and that code when i run it as a FS it compiles with warning and on the server doesnt have any effect.
I don't really understand what you're saying,it complies with no errors/warnings but it doesn't work ingame right?
Reply
#10

Quote:
Originally Posted by aymane123
Посмотреть сообщение
i am not talking about that its too easy and that code when i run it as a FS it compiles with warning and on the server doesnt have any effect.
Which warning do you have?
Loose Indentation?
If so, you have to get the tabulators right.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)