Jump to content

[Help] setTimer and createExplosion


BieHDC

Recommended Posts

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) 

Link to comment

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 
    )  

Link to comment

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 
)  

Link to comment

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 
) 
  

Link to comment

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 
) 
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...