Jump to content

getElementType


TioTiago

Recommended Posts

Wanted when firing on a bed (id 1812) created a ped, I tried this but to no avail: /

function onlyFunction () 
        if getElementType (hitElement) == "object" and getElementModel (hitElement) == 1812 then 
            x,y,z = getElementPosition(hitElement) 
            createPed (0, x, y, z, true) 
    end 
end 
addEventHandler ("onClientPlayerWeaponFire", getRootElement(), onlyFunction) 

O que está errado?

ty

Link to comment
I think that making onClientPlayerDamage would he better...

onClientPlayerDamage doesn't trigger when an object is hit.

You forgot to pass a parameter to the function.

function onlyFunction (hitElement) 
    if getElementType (hitElement) == "object" and getElementModel (hitElement) == 1812 then 
        local x,y,z = getElementPosition(hitElement) 
        createPed (0, x, y, z, true) 
    end 
end 
addEventHandler ("onClientPlayerWeaponFire", getRootElement(), onlyFunction) 

Link to comment

even removing getElementModel (hitElement) == 1812 it does not work

function onlyFunction (hitElement) 
    if getElementType (hitElement) == "object" then 
        local x,y,z = getElementPosition(hitElement) 
        createPed (0, x, y, z, true) 
    end 
end 
addEventHandler ("onClientPlayerWeaponFire", getRootElement(), onlyFunction) 

Link to comment

You're both welcome :) I didn't know that it exists also, but I found it out pretty easily :P Makes sense tho, since it's a useful function. By the way, does it work with weapons? I had small doubt in this case.

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