BieHDC Posted June 3, 2013 Posted June 3, 2013 Hello, i wanna make a script, that onPlayerSpawn makes timer to 16secs and than make an explosion. I have that: -- client side addEventHandler("onPlayerSpawn", resourceRoot, expl) setTimer (expl, 16000, 1, createExplosion) createExplosion (836.5 , -2047, 12.5, 10 , true, -1.0, false)
Castillo Posted June 3, 2013 Posted June 3, 2013 addEventHandler ( "onClientPlayerSpawn", root, function ( ) local x, y, z = getElementPosition ( source ) setTimer ( createExplosion, 16000, 1, x, y, z, 10, true, -1.0, false ) end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
BieHDC Posted June 3, 2013 Author Posted June 3, 2013 Would it look so with coordinates? addEventHandler ( "onClientPlayerSpawn", root, function ( ) local x, y, z = getElementPosition ( source ) setTimer ( createExplosion, 16000, 1, 836.5, -2047, 12.5, 10, true, -1.0, false ) end )
Castillo Posted June 3, 2013 Posted June 3, 2013 Yes, I replaced it with player position because I though you wanted to create it on his/her position. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
BieHDC Posted June 4, 2013 Author Posted June 4, 2013 So would that be right and working? and can i make a 2nd 3rd.... if i copy the 5 lines and make other coordinates? addEventHandler ( "onClientPlayerSpawn", root, function ( ) setTimer ( createExplosion, 16000, 1, 836.5, -2047, 12.5, 10, true, -1.0, false ) end )
iPrestege Posted June 4, 2013 Posted June 4, 2013 local ExplosionPosition = { [1] = { x,y,z }, [2] = { x,y,z }, [3] = { x,y,z }, [4] = { x,y,z }, } This is a table and please get the results by yourself .
BieHDC Posted June 4, 2013 Author Posted June 4, 2013 Would the script look then so? local ExplosionPosition = { [1] = { x,y,z }, [2] = { x,y,z }, [3] = { x,y,z }, [4] = { x,y,z }, } addEventHandler ( "onClientPlayerSpawn", root, function ( ) local x, y, z = getElementPosition ( ExplosionPosition ) setTimer ( createExplosion, 16000, 1, x, y, z, 10, true, -1.0, false ) end )
iPrestege Posted June 4, 2013 Posted June 4, 2013 No this is a wrong way try this ; local ExplosionPosition = { [1] = { x,y,z }, [2] = { x,y,z }, [3] = { x,y,z }, [4] = { x,y,z }, } addEventHandler ( "onClientPlayerSpawn", root, function ( ) for _,v in ipairs ( ExplosionPosition ) do local x,y,z = v[1],v[2],v[3] setTimer ( createExplosion, 16000, 1, x, y, z, 10, true, -1.0, false ) end end )
BieHDC Posted June 4, 2013 Author Posted June 4, 2013 And this creates 4 explosions with 16sec delay and all exploding at the same time?
BieHDC Posted June 4, 2013 Author Posted June 4, 2013 works perfect If i need a bigger script in future i will pay you^^
Castillo Posted June 4, 2013 Posted June 4, 2013 I would recommend using just one timer. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now