Command with timer - 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: Command with timer (
/showthread.php?tid=415569)
Command with timer -
KoSmYn - 13.02.2013
Hi! I tried to do a command with timer, who must be executed every 2-3 minutes. But, my script isn't good.
Код:
#include <a_samp>
#include <core>
new LSp;
forward Timerf();
forward Timer();
public OnGameModeInit()
{
LSp = CreateObject(5167, -2450.27, 1851.55, 0.15, 0.00, 0.00, 180.00);
SetTimer("Timerf", 5000, true);
SetTimer("Timer", 5000, true);
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/ff"))
{
MoveObject(LSp, -2400.27, 1851.55, 0.15, 5.0);
SetTimer("Timerf2", 5000, true);
return 1;
}
if(!strcmp(cmdtext, "/ff2"))
{
MoveObject(LSp, -2450.27, 1851.55, 0.15, 5.0);
SetTimer("Timer2", 5000, true);
return 1;
}
return 0;
}
Help me. ( Sorry for my English) PS: I know 5000 = 5 sec, i will set it later )
Re: Command with timer -
zxc1 - 13.02.2013
What 'is not good' exactly?
Re: Command with timer -
KoSmYn - 13.02.2013
The command isn't execute.
Re: Command with timer -
DiGiTaL_AnGeL - 13.02.2013
You gave forwarded but there's no callback.
pawn Код:
public Timerf()
{
MoveObject(LSp, -2400.27, 1851.55, 0.15, 5.0);
SetTimer("Timer", 5000, 0);
public Timer()
{
MoveObject(LSp, -2450.27, 1851.55, 0.15, 5.0);
SetTimer("Timerf", 5000, 0);
Delete the cmd too, and ongamemodeinit:
pawn Код:
SetTimer("Timer", 5000, 0);