Command Disabling
#1

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.
Reply
#2

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(playeridparams[]) {

    
// ...
    // Code
    // ...
    
    
UsedTeleport[playerid] = true;
    return 
true;
}

CMD:othercommands(playeridparams[]) {

    if(
UsedTeleport[playerid]) {
    
        return 
SendClientMessage(playerid, -1"You have recently used /tp and are now restricted to use this command.");
    }

    
// ...
    // Code
    // ...
    
return true;

Reply
#3

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.
Reply
#4

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;
}
Reply
#5

Код:
//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;
}
Reply
#6

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
Reply
#7

On which line can i find these errors?
Reply
#8

All on the same line where you got "UsedTeleport[playerid] = true;" under CMD:rip
Reply
#9

PHP код:
CMD:rip(playeridparams[])
{
    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] < && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}You need to be a higher level admin.");
    
GetPlayerName(IDnamesizeof(name));
    
SetPlayerPos(playerid1397.9011,78.4020,313.1431);
    
SetPlayerWeather(playerid33);
    
SetPlayerInterior(playerid1);
    
Ripped[playerid] = true;
    
format(stringsizeof(string), "{FFFFFF}%s {0099FF}has been sent to heaven, Rest In Peace."name);
    
SendClientMessageToAll(-1string);
    return 
1;
}
CMD:rc(playeridparams[])
{
    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(iStringsizeof(iString), "{FFFFFF}%s {0099FF}has quit the RC zone."Player[playerid][Name]);
        
SendClientMessageToAll(-1iString);
        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] == trueStopSpectate(playerid);
    if(
Player[playerid][InDM] == true) {
        
Player[playerid][InDM] = false;
        
Player[playerid][DMReadd] = 0;
    }
    
Player[playerid][RC] = true;
    
SpawnInRC(playerid);
    
format(iStringsizeof(iString), "{FFFFFF}%s {0099FF}has joined RC zone. {FFFFFF}/rc"Player[playerid][Name]);
    
SendClientMessageToAll(-1iString);
    return 
1;

Reply
#10

Didn't help, still the same. Thanks for the replies though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)