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

Is possible to make a variable or a define that locks all commands to set onplayercommandtext?
Without set on all command locked==1return sendclientmessage(blablabla)

P.S: I am using ZCMD processor

Thanks to all that will reply,
Rodri.
Reply
#2

I guess it's impossible without a variable within every cmd such as
PHP код:
if(locked == 1bla bla bla 
Reply
#3

Editing the include, setting a variable?
May i set a variable into it, that will be created on gamemode?
Reply
#4

Again!?!?!

PHP код:
#include <a_samp>
#include <zcmd>
new CommandEnabled[MAX_PLAYERS];
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
" Blank Filterscript by your name here");
    print(
"--------------------------------------\n");
        new 
playerid;
        
CommandEnabled[playerid] = 1;
    return 
1;
}
public 
OnFilterScriptExit()
{
    return 
1;
}
#else
main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
}
#endif
public OnGameModeInit()
{
    
// Don't use these lines if it's a filterscript
    
SetGameModeText("Blank Script");
    
AddPlayerClass(01958.37831343.157215.3746269.1425000000);
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    return 
1;
}
public 
OnVehicleSpawn(vehicleid)
{
    return 
1;
}
public 
OnVehicleDeath(vehicleidkillerid)
{
    return 
1;
}
public 
OnPlayerText(playeridtext[])
{
    return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/mycommand"cmdtexttrue10) == 0)
    {
        
// Do something here
        
return 1;
    }
    return 
0;
}
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    return 
1;
}
public 
OnPlayerExitVehicle(playeridvehicleid)
{
    return 
1;
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    return 
1;
}
public 
OnPlayerEnterCheckpoint(playerid)
{
    return 
1;
}
public 
OnPlayerLeaveCheckpoint(playerid)
{
    return 
1;
}
public 
OnPlayerEnterRaceCheckpoint(playerid)
{
    return 
1;
}
public 
OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 
1;
}
public 
OnRconCommand(cmd[])
{
    return 
1;
}
public 
OnPlayerRequestSpawn(playerid)
{
    return 
1;
}
public 
OnObjectMoved(objectid)
{
    return 
1;
}
public 
OnPlayerObjectMoved(playeridobjectid)
{
    return 
1;
}
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    return 
1;
}
public 
OnVehicleMod(playeridvehicleidcomponentid)
{
    return 
1;
}
public 
OnVehiclePaintjob(playeridvehicleidpaintjobid)
{
    return 
1;
}
public 
OnVehicleRespray(playeridvehicleidcolor1color2)
{
    return 
1;
}
public 
OnPlayerSelectedMenuRow(playeridrow)
{
    return 
1;
}
public 
OnPlayerExitedMenu(playerid)
{
    return 
1;
}
public 
OnPlayerInteriorChange(playeridnewinterioridoldinteriorid)
{
    return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    return 
1;
}
public 
OnRconLoginAttempt(ip[], password[], success)
{
    return 
1;
}
public 
OnPlayerUpdate(playerid)
{
    return 
1;
}
public 
OnPlayerStreamIn(playeridforplayerid)
{
    return 
1;
}
public 
OnPlayerStreamOut(playeridforplayerid)
{
    return 
1;
}
public 
OnVehicleStreamIn(vehicleidforplayerid)
{
    return 
1;
}
public 
OnVehicleStreamOut(vehicleidforplayerid)
{
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    return 
1;
}
public 
OnPlayerClickPlayer(playeridclickedplayeridsource)
{
    return 
1;
}
public 
OnPlayerCommandPerformed(playeridcmdtext[], success)
{
    if(
CommandEnabled[playerid] == 0) return SendClientMessage(playerid, -1"The administrator has locked the server command! try again later");
    
    if(
CommandEnabled[playerid] == 1) return 1;
    return 
1;
}
CMD:lockcmds(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"You don't have the authority to use this command!");
    if(
CommandEnabled[playerid] == 0)
    {
        
CommandEnabled[playerid] = 1;
        
SendClientMessageToAll( -1"The administrator has unlocked the Server Commands!");
    }
    else if(
CommandEnabled[playerid] == 1)
    {
        
CommandEnabled[playerid] = 0;
        
SendClientMessageToAll( -1"The administrator has locked the Server Commands!");
    }
    return 
1;

Edit: I know it's possible
Reply
#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
#6

Also,

PHP код:
public OnPlayerCommandReceived(playeridcmdtext[])
{
    if(
Isplayerdeath == 1)
    {
        
SendClientMessage(playerid, -1"Please respawn first before typing any command!");
        return 
0;
    }
    return 
1;

Reply
#7

Quote:
Originally Posted by MicroKyrr
Посмотреть сообщение
Also,

PHP код:
public OnPlayerCommandReceived(playeridcmdtext[])
{
    if(
Isplayerdeath == 1)
    {
        
SendClientMessage(playerid, -1"Please respawn first before typing any command!");
        return 
0;
    }
    return 
1;

That's also what Player_InClassSelection(playerid) does in my example code.
See the comments.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)