Command Disabling -
Naman - 28.07.2016
So I made a new command which kinda teleports a player to an unknown location. Now I want to disable other commands which I got on the gamemode like /dm [id]. Lets assume the command is /teleloc [id]. Now If I use /teleloc [id] the player gets sent to the location but now I want to stop him from using /dm [id] so that he cannot enter dm while I have sent him to the location. I tried some bool thingy didn't quite work out. Help is appreciated.
Re: Command Disabling -
AndySedeyn - 28.07.2016
Could you provide the code of your attempt? You will need a boolean variable which will be set to true when you use the tp command.
PHP код:
new bool:UsedTeleport[MAX_PLAYERS];
PHP код:
CMD:tp(playerid, params[]) {
// ...
// Code
// ...
UsedTeleport[playerid] = true;
return true;
}
CMD:othercommands(playerid, params[]) {
if(UsedTeleport[playerid]) {
return SendClientMessage(playerid, -1, "You have recently used /tp and are now restricted to use this command.");
}
// ...
// Code
// ...
return true;
}
Re: Command Disabling -
yvoms - 28.07.2016
Use a variable, set it on command execution, and if the variable is set then disallow the command from being executed.
Send the code please.
Re: Command Disabling -
Naman - 28.07.2016
Here's the code for teleporting the player:
Код:
CMD:rip(playerid, params[])
{
new name[32];
new string[128];
new ID = strval(params);
#if PLUGINS == 1
if(sscanf(params,"u[64]", playerid)) return SendClientMessage(playerid, -1,"{FFFFFF}Error: {0099FF}/rip [Player ID]");
#else
if(sscanf(params,"u", playerid)) return SendClientMessage(playerid, -1,"{FFFFFF}Error: {0099FF}/rip [Player ID]");
#endif
if(Player[playerid][Level] < 3 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}You need to be a higher level admin.");
GetPlayerName(ID, name, sizeof(name));
SetPlayerPos(playerid, 1397.9011,78.4020,313.1431);
SetPlayerWeather(playerid, 33);
SetPlayerInterior(playerid, 1);
format(string, sizeof(string), "{FFFFFF}%s {0099FF}has been sent to heaven, Rest In Peace.", name);
SendClientMessageToAll(-1, string);
return 1;
}
Here's the code to be disabled:
Код:
CMD:rc(playerid, params[])
{
new iString[160];
if(Player[playerid][RC] == true) {
Player[playerid][RC] = false;
SpawnPlayerEx(playerid);
format(iString, sizeof(iString), "{FFFFFF}%s {0099FF}has quit the RC zone.", Player[playerid][Name]);
SendClientMessageToAll(-1, iString);
return 1;
}
if(Player[playerid][Playing] == true) return SendClientMessage(playerid, -1, "{FFFFFF}Error: {0099FF}Can't use the command while playing.");
if(Player[playerid][Spectating] == true) StopSpectate(playerid);
if(Player[playerid][InDM] == true) {
Player[playerid][InDM] = false;
Player[playerid][DMReadd] = 0;
}
Player[playerid][RC] = true;
SpawnInRC(playerid);
format(iString, sizeof(iString), "{FFFFFF}%s {0099FF}has joined RC zone. {FFFFFF}/rc", Player[playerid][Name]);
SendClientMessageToAll(-1, iString);
return 1;
}
Re: Command Disabling -
yvoms - 28.07.2016
Код:
//place this above ongamemodeinit
new bool:UsedTeleport[MAX_PLAYERS];
CMD:rip(playerid, params[])
{
new name[32];
new string[128];
new ID = strval(params);
#if PLUGINS == 1
if(sscanf(params,"u[64]", playerid)) return SendClientMessage(playerid, -1,"{FFFFFF}Error: {0099FF}/rip [Player ID]");
#else
if(sscanf(params,"u", playerid)) return SendClientMessage(playerid, -1,"{FFFFFF}Error: {0099FF}/rip [Player ID]");
#endif
if(Player[playerid][Level] < 3 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}You need to be a higher level admin.");
GetPlayerName(ID, name, sizeof(name));
SetPlayerPos(playerid, 1397.9011,78.4020,313.1431);
SetPlayerWeather(playerid, 33);
SetPlayerInterior(playerid, 1);
UsedTeleport[playerid] = true;
format(string, sizeof(string), "{FFFFFF}%s {0099FF}has been sent to heaven, Rest In Peace.", name);
SendClientMessageToAll(-1, string);
return 1;
}
CMD:rc(playerid, params[])
{
new iString[160];
if(UsedTeleport[playerid]) return SendClientMessage(playerid, -1, "Can not use this command right now.");
if(Player[playerid][RC] == true) {
Player[playerid][RC] = false;
SpawnPlayerEx(playerid);
format(iString, sizeof(iString), "{FFFFFF}%s {0099FF}has quit the RC zone.", Player[playerid][Name]);
SendClientMessageToAll(-1, iString);
return 1;
}
if(Player[playerid][Playing] == true) return SendClientMessage(playerid, -1, "{FFFFFF}Error: {0099FF}Can't use the command while playing.");
if(Player[playerid][Spectating] == true) StopSpectate(playerid);
if(Player[playerid][InDM] == true) {
Player[playerid][InDM] = false;
Player[playerid][DMReadd] = 0;
}
Player[playerid][RC] = true;
SpawnInRC(playerid);
format(iString, sizeof(iString), "{FFFFFF}%s {0099FF}has joined RC zone. {FFFFFF}/rc", Player[playerid][Name]);
SendClientMessageToAll(-1, iString);
return 1;
}
Re: Command Disabling -
Naman - 28.07.2016
I tried this before too, didn't work. Here's the error I am getting:
Note, I am using "Ripped" instead of "UsedTeleport"
Код:
error 028: invalid subscript (not an array or too many subscripts): "Ripped"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Re: Command Disabling -
yvoms - 28.07.2016
On which line can i find these errors?
Re: Command Disabling -
Naman - 28.07.2016
All on the same line where you got "UsedTeleport[playerid] = true;" under CMD:rip
Re: Command Disabling -
Fairuz - 28.07.2016
PHP код:
CMD:rip(playerid, params[])
{
new name[32];
new string[128];
new ID = strval(params);
#if PLUGINS == 1
if(sscanf(params,"u[64]", playerid)) return SendClientMessage(playerid, -1,"{FFFFFF}Error: {0099FF}/rip [Player ID]");
#else
if(sscanf(params,"u", playerid)) return SendClientMessage(playerid, -1,"{FFFFFF}Error: {0099FF}/rip [Player ID]");
#endif
if(Player[playerid][Level] < 3 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}You need to be a higher level admin.");
GetPlayerName(ID, name, sizeof(name));
SetPlayerPos(playerid, 1397.9011,78.4020,313.1431);
SetPlayerWeather(playerid, 33);
SetPlayerInterior(playerid, 1);
Ripped[playerid] = true;
format(string, sizeof(string), "{FFFFFF}%s {0099FF}has been sent to heaven, Rest In Peace.", name);
SendClientMessageToAll(-1, string);
return 1;
}
CMD:rc(playerid, params[])
{
new iString[160];
if(Ripped[playerid]) return SendClientMessage(playerid, -1, "{FFFFFF}Error: {0099FF}Can't use the command while ripped.");
if(Player[playerid][RC] == true) {
Player[playerid][RC] = false;
SpawnPlayerEx(playerid);
format(iString, sizeof(iString), "{FFFFFF}%s {0099FF}has quit the RC zone.", Player[playerid][Name]);
SendClientMessageToAll(-1, iString);
return 1;
}
if(Player[playerid][Playing] == true) return SendClientMessage(playerid, -1, "{FFFFFF}Error: {0099FF}Can't use the command while playing.");
if(Player[playerid][Spectating] == true) StopSpectate(playerid);
if(Player[playerid][InDM] == true) {
Player[playerid][InDM] = false;
Player[playerid][DMReadd] = 0;
}
Player[playerid][RC] = true;
SpawnInRC(playerid);
format(iString, sizeof(iString), "{FFFFFF}%s {0099FF}has joined RC zone. {FFFFFF}/rc", Player[playerid][Name]);
SendClientMessageToAll(-1, iString);
return 1;
}
Re: Command Disabling -
Naman - 28.07.2016
Didn't help, still the same. Thanks for the replies though.