SA-MP Forums Archive
Easy ask - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Easy ask (/showthread.php?tid=655074)



Easy ask - LOLITO - 12.06.2018

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


Re: Easy ask - RogueDrifter - 12.06.2018

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)


Re: Easy ask - Exhibit - 12.06.2018

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 



Re: Easy ask - Bingo - 12.06.2018

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.


Re: Easy ask - J0sh... - 12.06.2018

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?

.


Re: Easy ask - CodeStyle175 - 12.06.2018

....