Jump to content

[HELP] Need help with a script (Tried everything, but no success)


Recommended Posts

How can I disable collision for projectiles, created with createProjectile function, I tried everything, but no success, this is the line that creates a projectile. it's a shooter minigame, so the car is shooting projectiles/rockets: 

createProjectile(theVehicle, 19, x, y, z, 1.0, nil)

And the line for ghostmode in meta.xml file:

<setting name="#ghostmode" value='[ &quot;false&quot; ]' />

Here are a few options I've tried, with no success, so maybe someone knows what's the problem?


Solution 1:

function projectileGhost ()
	local projType = getProjectileType(source)
        local objects = getElementsByType("object")
        for i, v in ipairs(objects) do
            setElementCollidableWith(source, v, false)
        end
end		
addEventHandler( "onClientProjectileCreation", getRootElement(), projectileGhost)

Solution 2:

function projectileGhost ()
	local projType = getProjectileType(source)
        setElementCollisionsEnabled(source, false)
end		
addEventHandler( "onClientProjectileCreation", getRootElement(), projectileGhost)

Solution 3:

function projectileGhost ()
        local projectiles = getElementsByType("projectile")
        for i, v in ipairs(projectiles) do
            setElementCollisionsEnabled(v, false)
        end
end		
addEventHandler( "onClientProjectileCreation", getRootElement(), projectileGhost)

 

I have also tried to disable collision for objects, and that works, the rockets then go through the wall, ground, buildings... Exactly what I need, but so does the car, and yes I've tried to enable collision just for the vehicles, after disabling it for objects, but that doesn't work either. Here is the script for disabling collision for objects, that works:

function projectileGhost ()
        local objects = getElementsByType("object")
        for i, v in ipairs(objects) do
            setElementCollisionsEnabled(v, false)
        end
end		
addEventHandler( "onClientProjectileCreation", getRootElement(), projectileGhost)

I really need to figure this small problem that's bothering me for days, so please if anyone knows the solution, let me know?

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