how to script when player used command and he must wait untill ....
#1

hi .how to script this
Example : when player used /s command and he talked with it ..

then when he wants to use /s again a msg showed at his screens and say You must

wait affter 20 Sec To use /s again .
Reply
#2

Код:
new bool:bool[MAX_PLAYERS]
Код:
if (strcmp("/s", cmdtext, true) == 0)
{
if(bool[playerid] == true) return SendClientMessage(playerid, COLOR_RED,"You need to wait 40 seconds");

//....
bool[playerid] = true;
SetTimerEx("usecmd",40*1000,0,"i",playerid);
}
Код:
forward usecmd(playerid);
public usecmd(playerid)
{
bool = false
}
Reply
#3

Hmm,

Just make it call a timer:


pawn Код:
new UsedS[MAX_PLAYERS];
Under OnPlayerConnect
pawn Код:
UsedS[playerid] = 0;
Then Just make the command and check if UsedS is = 1, Else send them a message saying they cant do it

pawn Код:
dcmd_s(playerid, params[])
{
    if(UsedS[playerid] == 1) return SendClientMessage(playerid, COLOR_YELLOW, "You Must Wait 20 Secs);
    else
    {
          //Stuff In Here

        UsedS[giveplayerid] = 1; //Setting it to 1
        SetTimerEx("
STimer",20000,0,"i",playerid); //Setting A Timer
        return 1;
        }
        return 1;
    }
}
pawn Код:
forward STimer

public STimer(playerid);
{
   UsedS[playerid] = 0;
   SendClientMessage(playerid, COLOR_YELLOW, "You Can Use /s Now");
   return 1;
}
Reply
#4

Does that save a bunch of CPU, *****?

I'm familiarizing myself with new functions as I took a coding hiatus. My server has some CPU issues when we hit 40 players so I'd love to remove the timers.
Reply
#5

Quote:
Originally Posted by ŚĂĞĔ
Hmm,

Just make it call a timer:


pawn Код:
new UsedS[MAX_PLAYERS];
Under OnPlayerConnect
pawn Код:
UsedS[playerid] = 0;
Then Just make the command and check if UsedS is = 1, Else send them a message saying they cant do it

pawn Код:
dcmd_s(playerid, params[])
{
    if(UsedS[playerid] == 1) return SendClientMessage(playerid, COLOR_YELLOW, "You Must Wait 20 Secs);
    else
    {
          //Stuff In Here

        UsedS[giveplayerid] = 1; //Setting it to 1
        SetTimerEx("
STimer",20000,0,"i",playerid); //Setting A Timer
        return 1;
        }
        return 1;
    }
}
pawn Код:
forward STimer

public STimer(playerid);
{
   UsedS[playerid] = 0;
   SendClientMessage(playerid, COLOR_YELLOW, "You Can Use /s Now");
   return 1;
}
Thanks BUT what is this warring
Код:
 warning 203: symbol is never used: "UsedS"
Reply
#6

Код:
forward STimer(); 

public STimer(playerid)
Reply
#7

Sorry,

Suppsoed to be

pawn Код:
UsedS[playerid] = 1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)