How do i enable and disable commands?
#1

As the title says

i've been trying for a while now, but i can't seem to figure it out


(got to sleep now, be back tomorrow)
Reply
#2

Like all commands or individual ones?
Reply
#3

Quote:
Originally Posted by backwardsman97
Like all commands or individual ones?
individual ones
Reply
#4

You could put // Round it or /*
Reply
#5

Quote:
Originally Posted by HarryKirkby
You could put // Round it or /*
yea, i know that


but i mean when i'm ingame, with another command.

(is it possible?)
Reply
#6

Make a new variable, allow the cmd if the variable ==1, disable it if it equals 0
Reply
#7

i think you can with some variables behind all the commands and some commands setting those variables so yes it is possible as it is seen in alot of gms
Reply
#8

In your script you could add a variable to turn the command on or off.

example:
Код:
	if(strcmp(cmdtext, "/cash", true) == 0 && CmdInUse == 1) {
		GivePlayerMoney(playerid, 100000);
 		return 1;
	}
Turn the cash command on:
Код:
	if(strcmp(cmdtext, "/Cashon", true) == 0) {
		CmdInUse[playerid] =1;
 		return 1;
	}
Turn the cash command off:
Код:
	if(strcmp(cmdtext, "/Cashoff", true) == 0) {
		CmdInUse[playerid] =0;
 		return 1;
	}
Reply
#9

Quote:
Originally Posted by Infamous
In your script you could add a variable to turn the command on or off.

example:
Код:
	if(strcmp(cmdtext, "/cash", true) == 0 && CmdInUse == 1) {
		GivePlayerMoney(playerid, 100000);
 		return 1;
	}
Turn the cash command on:
Код:
	if(strcmp(cmdtext, "/Cashon", true) == 0) {
		CmdInUse[playerid] =1;
 		return 1;
	}
Turn the cash command off:
Код:
	if(strcmp(cmdtext, "/Cashoff", true) == 0) {
		CmdInUse[playerid] =0;
 		return 1;
	}
That would give an error. It should be:
Код:
	if(strcmp(cmdtext, "/cash", true) == 0 && CmdInUse[playerid] == 1) {
		GivePlayerMoney(playerid, 100000);
 		return 1;
	}
Turn the cash command on:
Код:
	if(strcmp(cmdtext, "/Cashon", true) == 0) {
		CmdInUse[playerid] =1;
 		return 1;
	}
Turn the cash command off:
Код:
	if(strcmp(cmdtext, "/Cashoff", true) == 0) {
		CmdInUse[playerid] =0;
 		return 1;
	}
Reply
#10

Ah yes i missed a "[playerid]"
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)