Help disabling commands on occasions. -
TahaMhr - 01.09.2017
I wanted to know how can I disable all the commands in an event or dm or maybe when a player is jailed in dcmd. For example, this is a code from Lux Admin of jailing a player, but as I made teleports also, while jailed players can tp and evade the jail. Here's the code;
"dcmd_jail(playerid,params[])
{
if(AccInfo[playerid][LoggedIn] == 1)
{
if(AccInfo[playerid][Level] >= 3)
{
new Index;
new tmp[256]; tmp = strtok(params,Index);
new tmp2[256]; tmp2 = strtok(params,Index);
new tmp3[256]; tmp3 = strtok(params,Index);
if(!strlen(params)) return
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /jail [PlayerID] [Minutes] [Reason]") &&
SendClientMessage(playerid, orange, "Function: Will Jailed the specified player");
new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(tmp);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
{
if(AccInfo[player1][Jailed] == 0)
{
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
new jtime = strval(tmp2);
if(jtime == 0) jtime = 9999;
SendCommandToAdmins(playerid,"Jail");
AccInfo[player1][JailTime] = jtime*1000*60;
SetTimerEx("JailPlayer",5000,0,"d",player1);
SetTimerEx("Jail1",1000,0,"d",player1);
AccInfo[player1][Jailed] = 1;
if(jtime == 9999)
{
if(!strlen(params[strlen(tmp2)+1])) format(string,sizeof(string),"|- Administrator %s has Jailed %s -|",adminname,playername);
else format(string,sizeof(string),"|- Administrator %s has Jailed %s | Reason: %s -|",adminname,playername,params[strlen(tmp)+1]);
}
else
{
if(!strlen(tmp3)) format(string,sizeof(string),"|- Administrator %s has Jailed %s for %d Minutes -|",adminname,playername, jtime);
else format(string,sizeof(string),"|- Administrator %s has Jailed %s for %d Minutes | Reason: %s -|",adminname,playername,jtime,params[strlen(tmp2)+strlen(tmp)+1]);
}
return SendClientMessageToAll(blue,string);
}
else return SendClientMessage(playerid, red, "ERROR: Player is already in jail");
}
else return SendClientMessage(playerid, red, "ERROR: Player is not connected or is the highest level admin");
}
else return ErrorMessages(playerid, 1);
}
else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
"
the tps are also in dcmd, but i want it like if anyone is jailed, he cannot evade it by others commands, suggest me what should I add in here.
Sorry if its a lame question, Im a newbie.
Re: Help disabling commands on occasions. -
mongi - 01.09.2017
Add this to your TP Commands:
PHP код:
if(AccInfo[playerid][JailTime] != 0) return SendClientMessage(playerid, red, "ERROR: You can't use this command in jail!");
Re: Help disabling commands on occasions. -
TahaMhr - 01.09.2017
Quote:
Originally Posted by mongi
Add this to your TP Commands:
PHP код:
if(AccInfo[playerid][JailTime] != 0) return SendClientMessage(playerid, red, "ERROR: You can't use this command in jail!");
|
well, I appreciate your help but I haven't linked the scripts and Im running 3 different scripts for everything. Every new feature is added in either one of them, so do I have to link the tps script and admin system or is there any other way too? Like I want all other commands to be blocked, and adding this into every tp would be painful, though it is still an option.
Re: Help disabling commands on occasions. -
FuNkYTheGreat - 01.09.2017
Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(ifAccInfo[playerid][JailTime] != 0)
{
SendClientMessageEx(playerid,-1, "You can't use any command while in jail");
return 0;
}
return 1;
}
EDITED try now !
Re: Help disabling commands on occasions. -
TahaMhr - 01.09.2017
Quote:
Originally Posted by FuNkYTheGreat
Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(if(AccInfo[playerid][JailTime] != 0))
{
SendClientMessageEx(playerid,-1, "You can't use any command while in jail");
return 0;
}
return 1;
}
EDITED try now !
|
Код:
(7757) : warning 235: public function lacks forward declaration (symbol "OnPlayerCommandReceived")
(7759) : error 029: invalid expression, assumed zero
(7759) : warning 215: expression has no effect
(7759) : error 001: expected token: ";", but found ")"
(7759) : error 029: invalid expression, assumed zero
(7759) : fatal error 107: too many error messages on one line
Re: Help disabling commands on occasions. -
FuNkYTheGreat - 01.09.2017
Oops i missed brackets,
Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(AccInfo[playerid][JailTime] != 0)
{
SendClientMessageEx(playerid,-1, "You can't use any command while in jail");
return 0;
}
return 1;
}
Try this !
Re: Help disabling commands on occasions. -
TahaMhr - 01.09.2017
Quote:
Originally Posted by FuNkYTheGreat
Oops i missed brackets,
Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(AccInfo[playerid][JailTime] != 0)
{
SendClientMessageEx(playerid,-1, "You can't use any command while in jail");
return 0;
}
return 1;
}
Try this !
|
Код:
(7759) : warning 235: public function lacks forward declaration (symbol "OnPlayerCommandReceived")
(7763) : error 017: undefined symbol "SendClientMessageEx"
I was getting this error first, I changed the "SendClientMessageEx" to "SendClientMessage", and the error is gone, but the warning still exists.
And it didnt work ingame.
Re: Help disabling commands on occasions. -
mongi - 02.09.2017
You should link them
OR (Not sure)
Check the player's pos. And interior (if any)
Re: Help disabling commands on occasions. -
Paulice - 03.09.2017
Here's some code you can use to disable individual commands:
PHP код:
#include <sscanf>
#include <zcmd>
public OnPlayerCommandReceived(playerid, cmdtext[])
{
new cmd[29], null;
sscanf(cmdtext, "s[29]i", cmd, null);
if(GetPVarInt(playerid, cmd))
{
SendClientMessage(playerid, 0xFF0000FF, "That command is disabled for you!");
return 0;
}
return 1;
}
CMD:disable(playerid, params[])
{
if(isnull(params))
{
SendClientMessage(playerid, 0xFF0000FF, "Usage: /disable (/command)");
}
else if(!IsValidCommand(params))
{
SendClientMessage(playerid, 0xFF0000FF, "Please enter a valid command!");
}
else
{
SetPVarInt(playerid, params, 1);
SendClientMessage(playerid, 0xFFF000FF, "You have disabled a command for yourself!");
}
return 1;
}
CMD:enable(playerid, params[])
{
if(isnull(params))
{
SendClientMessage(playerid, 0xFF0000FF, "Usage: /enable (/command)");
}
else if(!IsValidCommand(params))
{
SendClientMessage(playerid, 0xFF0000FF, "Please enter a valid command!");
}
else
{
DeletePVar(playerid, params); // can also be SetPVarInt(playerid, params, 0); but not recommended as PVars are limited
SendClientMessage(playerid, 0xFFF000FF, "You have enabled a command for yourself!");
}
return 1;
}
CMD:cmd1(playerid, params[])
{
SendClientMessage(playerid, 0xFFF000FF, "You have used /cmd1!");
return 1;
}
CMD:cmd2(playerid, params[])
{
SendClientMessage(playerid, 0xFFF000FF, "You have used /cmd2!");
return 1;
}
IsValidCommand(const command[])
{
if(command[0] == EOS || command[0] != '/' || strlen(command) > 28 || strfind(command, " ", true) != -1)
{
return false;
}
return true;
}
Re: Help disabling commands on occasions. -
TahaMhr - 03.09.2017
Thanks for your help guys, I've found a way to disable the required commands in ZCMD and yep
Quote:
Originally Posted by mongi
You should link them
|
I have merged 2 script into 1 which did solve my problem. That LuxAdmin is somewhat messed up in my head, so I tried on other scripts xd.
Thanks, @Paulice for your script too.
Is there a way to link two scripts without merging them? Like if I wanted to disable teleports while in a DM, I had to merge the 2 scripts in one for the script to recognize the operation. But is there a way that I don't merge the script but still it works?