CMD:ask(playerid, params[])
{
if(sscanf(params, "s[256]", Ask[playerid])) return SCM(playerid, -1, ""grey"Usage: "white"/ask [question]");
if(AskInProgress[playerid] == true) return SCM(playerid, -1, ""red"[ERROR] "white"You have already an active question");
new string[128];
format(string, sizeof(string), ""orange"QUESTION from %s: "white"%s", pName(playerid), Ask[playerid]);
SCMH(-1, string);
AskInProgress[playerid] = true;
SetTimer("deleteask", 5000, true);
return 1;
}
public:deleteask(playerid)
{
if(AskInProgress[playerid] == true)
{
AskInProgress[playerid] = false;
SCM(playerid, -1, ""red"[INFO] "white"Your question has been automatically removed");
SetTimer("deleteask", playerid, false);
}
return 1;
}
SetTimerEx("deleteask", 5000, false, "i", playerid);
forward deleteask(playerid);
public deleteask(playerid)
{
if(AskInProgress[playerid] == true)
{
AskInProgress[playerid] = false;
SCM(playerid, -1, ""red"[INFO] "white"Your question has been automatically removed");
}
return 1;
}
|
You don't pass the player id to deleteask. Do you think it will just magically appear?
If you want to pass arguments to a timer function, use SetTimerEx. pawn Код:
Also, the 2nd parameter of SetTimer/SetTimerEx is if the timer should be repeated. If set to true, the function will be called EVERY 5 seconds untill you use KillTimer. |
KillTimer(deleteask(playerid));
SetTimer("AFunction", 1000, true); // a repeating timer
SetTimer("AFunction", 1000, false); // a non repeating timer
SetTimerEx("AFunction", 1000, true, "i", 5); // a repeating timer
SetTimerEx("AFunction", 1000, false, "i", 5); // a non repeating timer
new timerid = SetTimer("AFunction", 1000, true);
KillTimer(timerid);
|
No, both SetTimerEx AND SetTimerEx can be used for repeating and non-repeating timers.
They will be repeating if you set the 3rd parameter to true. pawn Код:
And that's not how you use KillTimer. SetTimer and SetTimerEx return timer IDs, which are neede in KillTimer. For example: pawn Код:
|