#1

how to make a command that can be used at the first time, and if he tried to do it again..
pawn Код:
SendClientMessage(playerid,COLOR_WHITE,"Please Wait to use this command again");
Reply
#2

Try something like this:

pawn Код:
new HasUsedCommandShop[MAX_PLAYERS]; // at the top of the script
forward CommandShopTimer(playerid);
Under the command:

pawn Код:
if(HasUsedCommandShop[playerid] == 1) return SendClientMessage(playerid, COLOR_WHITE, "Please wait until you can use this command again.");
And under the command if it was successful, use:

pawn Код:
HasUsedCommandShop[playerid] = 1;
SetTimerEx("CommandShopTimer", time here in milliseconds, false, "i", playerid);
And then, make a public for the command:

pawn Код:
public CommandShopTimer(playerid)
{
     HasUsedCommandShop[playerid] = 0;
     SendClientMessage(playerid, COLOR_WHITE, "You can now use the command again.");
     return 1;
}
Reply
#3

Better realisation, without using timers
PHP код:
new commandShopUsed[MAX_PLAYERS];
#define commandShopInterval 3600 //in seconds
CMD:shop(playerid) {
    if (
gettime() < commandShopUsed[playerid])
        return 
SendClientMessage(playerid, -1"Please Wait to use this command again");
    
commandShopUsed[playerid] = gettime() + commandShopInterval;
    
//Common code starts here
    
return true;

You can save commandShopUsed[playerid] to player's account
Reply
#4

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
Try something like this:

pawn Код:
new HasUsedCommandShop[MAX_PLAYERS]; // at the top of the script
forward CommandShopTimer(playerid);
Under the command:

pawn Код:
if(HasUsedCommandShop[playerid] == 1) return SendClientMessage(playerid, COLOR_WHITE, "Please wait until you can use this command again.");
And under the command if it was successful, use:

pawn Код:
HasUsedCommandShop[playerid] = 1;
SetTimerEx("CommandShopTimer", time here in milliseconds, false, "i", playerid);
And then, make a public for the command:

pawn Код:
public CommandShopTimer(playerid)
{
     HasUsedCommandShop[playerid] = 0;
     SendClientMessage(playerid, COLOR_WHITE, "You can now use the command again.");
     return 1;
}
it didn't work, it gives me the client message (please wait) each time i type the command and there is no timer set to it to could use it again, so you can use it any time :\


Quote:
Originally Posted by =KempeR=
Посмотреть сообщение
Better realisation, without using timers
PHP код:
new commandShopUsed[MAX_PLAYERS];
#define commandShopInterval 3600 //in seconds
CMD:shop(playerid) {
    if (
gettime() < commandShopInterval[playerid])
        return 
SendClientMessage(playerid, -1"Please Wait to use this command again");
    
commandShopInterval[playerid] = gettime() + commandShopInterval;
    
//Common code starts here
    
return true;

You can save commandShopUsed[playerid] to player's account
i don't understand, i want to make it 1 minute to could use the command again, so how the server would know that if i won't put 60000 milliseconds of time ?
Reply
#5

Try using this tutorial, It may help you: https://sampforum.blast.hk/showthread.php?tid=185625
Reply
#6

Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
it didn't work, it gives me the client message (please wait) each time i type the command and there is no timer set to it to could use it again, so you can use it any time :\



i don't understand, i want to make it 1 minute to could use the command again, so how the server would know that if i won't put 60000 milliseconds of time ?
You've missed something then, I just tried it on my own GM with a simple credits command and it works fine.
Reply
#7

Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
i don't understand, i want to make it 1 minute to could use the command again, so how the server would know that if i won't put 60000 milliseconds of time ?
PHP код:
new commandShopUsed[MAX_PLAYERS]; 
#define commandShopInterval 3600 //in seconds 
CMD:shop(playerid) { 
    if (
gettime() < commandShopUsed[playerid]) //
        
return SendClientMessage(playerid, -1"Please Wait to use this command again"); 
    
commandShopUsed[playerid] = gettime() + commandShopInterval
    
//Common code starts here 
    
return true

What exactly do not you understand? I can not exactly explain everything, I do not know English very well
Reply
#8

Quote:
Originally Posted by Krakuski
Посмотреть сообщение
Try using this tutorial, It may help you: https://sampforum.blast.hk/showthread.php?tid=185625
no error of compiling, but didn't work

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
You've missed something then, I just tried it on my own GM with a simple credits command and it works fine.
can u please post any random command and show me how you do it
Reply
#9

Quote:
Originally Posted by =KempeR=
Посмотреть сообщение
PHP код:
new commandShopUsed[MAX_PLAYERS]; 
#define commandShopInterval 3600 //in seconds 
CMD:shop(playerid) { 
    if (
gettime() < commandShopUsed[playerid]) //
        
return SendClientMessage(playerid, -1"Please Wait to use this command again"); 
    
commandShopUsed[playerid] = gettime() + commandShopInterval
    
//Common code starts here 
    
return true

What exactly do not you understand? I can not exactly explain everything, I do not know English very well
didn't work, and 7 errors on complie
Reply
#10

Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
didn't work, and 7 errors on complie
Show me compile output
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)