Jump to content

how do I use this


Recommended Posts

what I want was to create an object that would appear above and when the object fell, the explosion would be activated.

And the problem is that the object appears above where I am, and I want it further away and where I am looking, and the explosion appears behind me and I want it to appear where I look.
the matrix did not work

How to use: getPedTargetEnd, getScreenFromWorldPosition and getWorldFromScreenPosition
that's what I need so that the explosion and the object appear where I look and away from me, but do I know how to use.
Here I leave my code

objs = {} 
 
       addCommandHandler ( "explosion",
            function ( thePlayer ) 
                local x, y, z = getElementPosition ( thePlayer )

                local rx, ry, rz = getElementRotation ( thePlayer )

                local origX, origY, origZ = getElementPosition ( thePlayer )

                local mat = Matrix.create ( x, y, z+20, rx, ry, rz, origX - 30,origY+30,origZ)

                local forward = ( Matrix.getForward ( mat ) * 4)

                local pos = ( Matrix.getPosition ( mat ) + forward )

                setTimer (createExplosion, 2000, 1,x+10, y, z, 11) 
                objs[thePlayer] = createObject(751, pos)

                local newZ = origZ +0
                moveObject( objs[thePlayer], 2000, origX, origY, origZ)

            end 
   )

please help me, the matrix will not work

Link to comment
objs = {} 

addCommandHandler ( "explosion",
    function ( thePlayer ) 
        local x, y, z = getElementPosition ( thePlayer )
        local rx, ry, rz = getElementRotation ( thePlayer )
        local mat = Matrix.create ( x+30, y+1, z+20, rx, ry, rz)
        local pos = ( Matrix.getPosition ( mat ) + forward )
        setTimer (createExplosion, 2000, 1,x+30, y+1, z, 11)
        objs[thePlayer] = createObject(751, pos)
        moveObject( objs[thePlayer], 2000, x +30, y+1, z)
    end 
)

well i don't know why you added this " local origX, origY, origZ = getElementPosition ( thePlayer ) " as long you got " local x, y, z = getElementPosition ( thePlayer ) " so i remove it..

and i didn't understand for what was the " local newZ = origZ +0 " i removed it .. 

Nothing important happen, i just edit the x+ and y+  nothing more.. but i saw something that when the object get created, you need to remove it because it will not get auto removed..

so you can add a time so you can add:

setTimer ( function () 
    destroyElement ( objs[thePlayer] )
end, 5000, 1 )

as like that:

objs = {} 

addCommandHandler ( "explosion",
    function ( thePlayer ) 
        local x, y, z = getElementPosition ( thePlayer )
        local rx, ry, rz = getElementRotation ( thePlayer )
        local mat = Matrix.create ( x+30, y+1, z+20, rx, ry, rz)
        local pos = ( Matrix.getPosition ( mat ) + forward )
        setTimer (createExplosion, 2000, 1,x+30, y+1, z, 11)
        objs[thePlayer] = createObject(751, pos)
        moveObject( objs[thePlayer], 2000, x +30, y+1, z)
        setTimer ( function () 
            destroyElement ( objs[thePlayer] )
        end, 5000, 1
    end 
)

 

Hope i did something useful :)

Edited by SSKE
Link to comment
28 minutes ago, SSKE said:

objs = {} 

addCommandHandler ( "explosion",
    function ( thePlayer ) 
        local x, y, z = getElementPosition ( thePlayer )
        local rx, ry, rz = getElementRotation ( thePlayer )
        local mat = Matrix.create ( x+30, y+1, z+20, rx, ry, rz)
        local pos = ( Matrix.getPosition ( mat ) + forward )
        setTimer (createExplosion, 2000, 1,x+30, y+1, z, 11)
        objs[thePlayer] = createObject(751, pos)
        moveObject( objs[thePlayer], 2000, x +30, y+1, z)
    end 
)

well i don't know why you added this " local origX, origY, origZ = getElementPosition ( thePlayer ) " as long you got " local x, y, z = getElementPosition ( thePlayer ) " so i remove it..

and i didn't understand for what was the " local newZ = origZ +0 " i removed it .. 

Nothing important happen, i just edit the x+ and y+  nothing more.. but i saw something that when the object get created, you need to remove it because it will not get auto removed..

so you can add a time so you can add:


setTimer ( function () 
    destroyElement ( objs[thePlayer] )
end, 5000, 1 )

as like that:

objs = {} 


addCommandHandler ( "explosion",
    function ( thePlayer ) 
        local x, y, z = getElementPosition ( thePlayer )
        local rx, ry, rz = getElementRotation ( thePlayer )
        local mat = Matrix.create ( x+30, y+1, z+20, rx, ry, rz)
        local pos = ( Matrix.getPosition ( mat ) + forward )
        setTimer (createExplosion, 2000, 1,x+30, y+1, z, 11)
        objs[thePlayer] = createObject(751, pos)
        moveObject( objs[thePlayer], 2000, x +30, y+1, z)
        setTimer ( function () 
            destroyElement ( objs[thePlayer] )
        end, 5000, 1
    end 
)

 

Hope i did something useful :)

But i can't rotate the Explosion.. so the player need to rotate on where is the rotation.

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...