Help with command
#1

How i can make this command can you it from one user (maybe it will need his nickname in the server)

PHP код:
if(strcmp(cmd"/boxevent"true) == 0)
    {
        if(
IsPlayerConnected(playerid) && (boxevent == 0))
        {
            
boxevent 1;
            
BroadCast(COLOR_WHITE"   write(/joinboxevent)!");
            
        }
        else if(
IsPlayerConnected(playerid) && (boxevent == 1))
        {
            
boxevent 0;
            
BroadCast(COLOR_GREEN"   deactive.");
        }
        return 
1;
    } 
Reply
#2

Function:
pawn Код:
Name( playerid )
{
    new s_p_N[ MAX_PLAYER_NAME ];
   
    GetPlayerName( playerid, s_p_N, sizeof s_p_N );
    return( s_p_N );
}
Command:
pawn Код:
if(strcmp(cmd, "/boxevent", true) == 0)
{
    if( !strcmp( Name( playerid ), "NAME", false ) )
    {
        if( boxevent == 0 )
        {
            boxevent = 1;
            BroadCast( COLOR_WHITE, "   write(/joinboxevent)!" );
           
        }
        else
        {
            boxevent = 0;
            BroadCast( COLOR_GREEN, "   deactive." );
        }
    }
    return 1;
}
PS: Is Case-Sensitive
Reply
#3

Can you make it for two nicknames
Reply
#4

Quote:
Originally Posted by boyan96
Посмотреть сообщение
Can you make it for two nicknames
Yes:
pawn Код:
if(strcmp(cmd, "/boxevent", true) == 0)
{
    if( !strcmp( Name( playerid ), "NAME", false ) || !strcmp( Name( playerid ), "NAME2", false ) )
    {
        if( boxevent == 0 )
        {
            boxevent = 1;
            BroadCast( COLOR_WHITE, "   write(/joinboxevent)!" );
           
        }
        else
        {
            boxevent = 0;
            BroadCast( COLOR_GREEN, "   deactive." );
        }
    }
    return 1;
}
PS: Still Case-Sensitive !
Reply
#5

pawn Код:
if(strcmp(cmd, "/boxevent", true) == 0)
{
   if( !strcmp( Name( playerid ), "NAME", false ) )
   {
      if( boxevent == 0 )
      {
        boxevent = 1;        
        BroadCast( COLOR_WHITE, "   write(/joinboxevent)!" );
      }
      else if ( !strcmp( Name( playerid ), "NAME2", false ) )
      if( boxevent == 0 )
      {
        boxevent = 1;        
        BroadCast( COLOR_WHITE, "   write(/joinboxevent)!" );
      }
      else
      {
        boxevent = 0;
        BroadCast( COLOR_GREEN, "   deactive." );
      }
   }
}
Reply
#6

@Twisted_Insane
The else if is outside the first if statement.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)