Ohoy, Need help with SetTimerEx or SetTimer
#1

Hello, I working on doing a firework script for Halloween but needs some help with Timers. I'm a newbie in scripting and would be really thankful if someone could give me a example.

It's going to send flares every 2 seconds and don't really know how to do..

Reply
#2

forward fireworks()

public OnGameModeInit()
{
SetTimer("fireworks",2000,1);//2 second looping timer
return 1;
}

fireworks()
{
//what happens when timer goes off
flare1 = CreateObject(354,X,Y,Z,0,0,0) //set X , Y, Z to cordinates you want
MoveObject(flare1,X,Y,Z+30,speed); //set speed to speed of the fireworks going up
}
Reply
#3


Make a callback with a timer

pawn Код:
forward Fireworks(playerid);
public Fireworks(playerid)
{
// The content (Like SendClientMessage, etc)
return 1;
}

// In a command or where you want the timer to start
SetTimerEx("Fireworks",100,false, "d", playerid); // 100 = The time that will take to load the callback -- false = The timer wont repeat (true for repeating) playerid = Just dont change this.
If I wasnt busy I would make you the code, but i'm busy now
Reply
#4

hehe...

pawn Код:
forward fireworks();
pawn Код:
if (strcmp("/firework", cmdtext, true) == 0)
    {
     SetTimer(fireworks,2000,1);
    SendClientMessage(playerid,YELLOW,"Firework activated");
    return 1;
    }

pawn Код:
public fireworks()
{
    new flare1;
    new Float: X, Float: Y, Float: Z;
    flare1 = CreateObject(354,X,Y,Z,0,0,0); //set X , Y, Z to cordinates you want
    MoveObject(flare1,X,Y,Z+30,20); //set speed to speed of the fireworks going up

}

: error 076: syntax error in the expression, or invalid function call
Reply
#5

That syntax error is most probably this:

pawn Код:
SetTimer(fireworks,2000,1);
change it to:
pawn Код:
SetTimer("fireworks",2000,1);
Reply
#6

Quote:
Originally Posted by [B2K
Hustler ]
That syntax error is most probably this:

pawn Код:
SetTimer(fireworks,2000,1);
change it to:
pawn Код:
SetTimer("fireworks",2000,1);
It worked, No errors, Now I'm going to see how it is in-game D;
Reply
#7

I got a other issues now, the timer seems. It's goes out flares 30m up in the sky where ever i goes. :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)