SA-MP Forums Archive
Lock all commands with a variable without enter return msg - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Lock all commands with a variable without enter return msg (/showthread.php?tid=602115)



Lock all commands with a variable without enter return msg - xEF - 02.03.2016

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.


Re: Lock all commands with a variable without enter return msg - saffierr - 02.03.2016

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



Re: Lock all commands with a variable without enter return msg - xEF - 02.03.2016

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


Re: Lock all commands with a variable without enter return msg - MicroKyrr - 02.03.2016

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(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerRequestClass(playerid, classid)
{
    
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    return 
1;
}
public 
OnPlayerDisconnect(playerid, reason)
{
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    return 
1;
}
public 
OnPlayerDeath(playerid, killerid, reason)
{
    return 
1;
}
public 
OnVehicleSpawn(vehicleid)
{
    return 
1;
}
public 
OnVehicleDeath(vehicleid, killerid)
{
    return 
1;
}
public 
OnPlayerText(playerid, text[])
{
    return 
1;
}
public 
OnPlayerCommandText(playerid, cmdtext[])
{
    if (
strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        
// Do something here
        
return 1;
    }
    return 
0;
}
public 
OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 
1;
}
public 
OnPlayerExitVehicle(playerid, vehicleid)
{
    return 
1;
}
public 
OnPlayerStateChange(playerid, newstate, oldstate)
{
    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(playerid, objectid)
{
    return 
1;
}
public 
OnPlayerPickUpPickup(playerid, pickupid)
{
    return 
1;
}
public 
OnVehicleMod(playerid, vehicleid, componentid)
{
    return 
1;
}
public 
OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 
1;
}
public 
OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 
1;
}
public 
OnPlayerSelectedMenuRow(playerid, row)
{
    return 
1;
}
public 
OnPlayerExitedMenu(playerid)
{
    return 
1;
}
public 
OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 
1;
}
public 
OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 
1;
}
public 
OnRconLoginAttempt(ip[], password[], success)
{
    return 
1;
}
public 
OnPlayerUpdate(playerid)
{
    return 
1;
}
public 
OnPlayerStreamIn(playerid, forplayerid)
{
    return 
1;
}
public 
OnPlayerStreamOut(playerid, forplayerid)
{
    return 
1;
}
public 
OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 
1;
}
public 
OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 
1;
}
public 
OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 
1;
}
public 
OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 
1;
}
public 
OnPlayerCommandPerformed(playerid, cmdtext[], 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(playerid, params[])
{
    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


Re: Lock all commands with a variable without enter return msg - AmigaBlizzard - 02.03.2016

PHP код:
// This callback gets executed when zcmd receives a command (gets called BEFORE the command is executed)
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    
// If a player hasn't logged in properly, he cannot use this command
    
if (APlayerData[playerid][LoggedIn] == false)
    {
        
SendClientMessage(playerid, 0xFFFFFFFF, "{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(playerid, 0xFFFFFFFF, "{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_NONE, PLAYER_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.


Re: Lock all commands with a variable without enter return msg - MicroKyrr - 02.03.2016

Also,

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



Re: Lock all commands with a variable without enter return msg - AmigaBlizzard - 03.03.2016

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

PHP код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    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.