PDA

View Full Version : how to create an object timer


Crossfire1989
17/05/2013, 07:41 AM
hello there, i want to take these objects if (strcmp("/fdtl", cmdtext, true, 5) == 0)
{
CreateObject(19294, -1553.23, -1608.65, 41.26, 0.00, 0.00, 0.00);
CreateObject(19294, -1553.76, -1612.27, 38.84, 0.00, 0.00, 0.00);
CreateObject(19294, -1553.81, -1612.79, 38.84, 0.00, 0.00, 0.00);
CreateObject(19294, -1553.27, -1608.25, 41.26, 0.00, 0.00, 0.00);
CreateObject(19294, -1535.87, -1604.26, 41.26, 0.00, 0.00, 0.00);
CreateObject(19294, -1535.80, -1603.85, 41.26, 0.00, 0.00, 0.00);
CreateObject(19294, -1535.16, -1600.25, 38.83, 0.00, 0.00, 0.00);
CreateObject(19294, -1535.10, -1599.69, 38.83, 0.00, 0.00, 0.00);
CreateObject(19294, -1537.66, -1595.35, 38.83, 0.00, 0.00, 0.00);
CreateObject(19294, -1538.24, -1595.36, 38.83, 0.00, 0.00, 0.00);
CreateObject(19294, -1538.24, -1595.36, 38.83, 0.00, 0.00, 0.00);
CreateObject(19294, -1541.91, -1595.27, 41.26, 0.00, 0.00, 0.00);
CreateObject(19294, -1542.31, -1595.29, 41.26, 0.00, 0.00, 0.00);
return 1;
}
and i want to make it so they activate via command, then shut off automatically on timer so once i put the command in i want the timer to destroy them after about 5 min, how do i do this and is it possible?

for example i want to do a command such as fdtl for Fire Department Traffic Light
and i want the flashing light do do this https://www.youtube.com/watch?v=kNlz37yhFIo for 5 Min at a time, is it possible to set it to a timer on all the objects?

Crossfire1989
17/05/2013, 07:46 AM
i will Rep the First One who Can Script the Command to Create the Command for me, since im not good at commands, i want it to create the objects and place them on a timer so they automatically turnoff

Simm
17/05/2013, 07:57 AM
make a command /deletefdtl
then remove that objects (+rep :D )

Crossfire1989
17/05/2013, 08:01 AM
i want it on a Timer so it Automatically deletes the object

Joe Staff
17/05/2013, 08:06 AM
3 steps really.


//Create objects that are linked with variables. This will go near the top, outside of any callbacks or functions.
new objects[13];
//This variable will keep the command from being called multiple times simultaneously
new objectsOn;
//declare a new callback
forward removeObjects();



//include a standard timer in your command
if (strcmp("/fdtl", cmdtext, true, 5) == 0)
{
//Prevent command from being used more than once at a time
if(objectsOn)return 1;

objects[0]=CreateObject(19294, -1553.23, -1608.65, 41.26, 0.00, 0.00, 0.00);
objects[1]=CreateObject(19294, -1553.76, -1612.27, 38.84, 0.00, 0.00, 0.00);
objects[2]=CreateObject(19294, -1553.81, -1612.79, 38.84, 0.00, 0.00, 0.00);
objects[3]=CreateObject(19294, -1553.27, -1608.25, 41.26, 0.00, 0.00, 0.00);
objects[4]=CreateObject(19294, -1535.87, -1604.26, 41.26, 0.00, 0.00, 0.00);
objects[5]=CreateObject(19294, -1535.80, -1603.85, 41.26, 0.00, 0.00, 0.00);
objects[6]=CreateObject(19294, -1535.16, -1600.25, 38.83, 0.00, 0.00, 0.00);
objects[7]=CreateObject(19294, -1535.10, -1599.69, 38.83, 0.00, 0.00, 0.00);
objects[8]=CreateObject(19294, -1537.66, -1595.35, 38.83, 0.00, 0.00, 0.00);
objects[9]=CreateObject(19294, -1538.24, -1595.36, 38.83, 0.00, 0.00, 0.00);
objects[10]=CreateObject(19294, -1538.24, -1595.36, 38.83, 0.00, 0.00, 0.00);
objects[11]=CreateObject(19294, -1541.91, -1595.27, 41.26, 0.00, 0.00, 0.00);
objects[12]=CreateObject(19294, -1542.31, -1595.29, 41.26, 0.00, 0.00, 0.00);

//Include timer
SetTimer("removeObjects",5000,0); //5000 = the amount of time for the objects to exist in milliseconds.
objectsOn=1; //set this to 1 to prevent command from being called again

return 1;
}


//Then create your callback destroying the objects and resetting the objectsOn variable to 0
public removeObjects()
{
objectsOn=0;
for(new o; o<sizeof objects; o++)
DestroyObject(objects[o]);
}

Crossfire1989
17/05/2013, 08:18 AM
ill try this, and let you know

Crossfire1989
18/05/2013, 10:05 AM
i cant get the Timer to Work??? and i had to change the Objects to Object, as Objects is Already Defined in my Script for my NPC Bus System