Easy ask
#1

How do I make a command to only be used once?
Reply
#2

in a life time or in a connection phase? if its for a connection set a variable true and check at the beginning if its true return 0; or something.

If for a life time then use a file saving system or ur SQL method either way works and do the same process as above, set a value in the file to 1 once its used then check for it at the beginning of the cmd.

EX:

PHP код:
new bool:testvar;
CMD:testcmd(cmd)
{
    if(
testvar) return 0;
    
testvar true;
    
//cmd stuff here
    
return 1;

Although i assume you know you'll need to add an array and make it per-player.
Oh yeah and reset it at either onplayerconnect/disconnect. (in case of a connection phase one time cmd)
Reply
#3

only once?
You can make a variable like this
PHP код:
new UsedCommand[MAX_PLAYERS]; //on top of the script
OnPlayerConnect(playerid)
{
    
UsedCommand[playerid] = 0;
    return 
1;
}
CMD:yourcommand(playeridparams[])
{
    if(
UsedCommand[playerid]==1) return SendClientMessage(playerid, -1"You can only use this command once!");
     
// rest of the command 
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
Put it in a filterscript and add this to the command:

PHP код:
SendRconCommand("unloadfs one_time_cmd"); 
Save the file as "one_time_cmd.pwn" and load it with "loadfs one_time_cmd".
By doing this the filterscript will be unloaded once the player types in the command this means he/she won't be able to do the same command again.
Reply
#5

Quote:
Originally Posted by Bingo
Посмотреть сообщение
By doing this the filterscript will be unloaded once the player types in the command this means he/she won't be able to do the same command again.
Quote:

How do I make a command to only be used once?

.
Reply
#6

....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)