Lock all commands with a variable without enter return msg
#5

PHP код:
// This callback gets executed when zcmd receives a command (gets called BEFORE the command is executed)
public OnPlayerCommandReceived(playeridcmdtext[])
{
    
// If a player hasn't logged in properly, he cannot use this command
    
if (APlayerData[playerid][LoggedIn] == false)
    {
        
SendClientMessage(playerid0xFFFFFFFF"{FF0000}You cannot use commands if you haven't logged in properly");
        return 
0;
    }
    
// If the player is on the class-selection menu, block the command
    
if (Player_InClassSelection(playerid) == 1)
    {
        
SendClientMessage(playerid0xFFFFFFFF"{FF0000}You cannot use commands while using class-selection");
        return 
0;
     }
    
// Allow commands to be performed when the player is logged in, and he's not in class-selection
    
return 1;
}
// This function checks if the given player is in class-selection screen
Player_InClassSelection(playerid)
{
    
// If the player has state NONE (entered server and got to class-selection), or if the player's state is WASTED (killed or returned to class-selection), return 1
    
switch (GetPlayerState(playerid))
    {
        case 
PLAYER_STATE_NONEPLAYER_STATE_WASTED: return 1
    }
    
// For any other state, return 0 as the player isn't in class-selection
    
return 0;

This is what I'm using to block usage of all commands.
It blocks all commands and sends a message when the player is still in class selection, or when he hasn't logged in properly (he must have entered the correct password to be logged in).

Returning 0 inside this callback blocks execution of the command.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)