Jump to content

getElementType problem


zocken212

Recommended Posts

Posted

Hey all

I want to make a firefighter job but I have a problem. Since createFire returns no element I used particle_objects to make a fire object. Now when I'm aiming on it it always says "Error: Expected element at argument 1, got boolean".. (I created the fires before in another part)

addEventHandler("onPlayerTarget",getRootElement(), 
function (hitElement) 
    if getElementType(hitElement) == "object" then -- Error: Expected element at argument 1, got boolean 
        if getElementData(hitElement,"fire") == true then 
            outputChatBox("This is a fire") 
        end 
    end 
end) 

Where is my problem??

Posted

This can happen, if the played dindn't target anything wich can be detected by this event. To avoid the error do one mor check:

if isElement ( hitElement ) and getElementType(hitElement) == "object" then 

Posted

Ok thanks, the error doesn't appear anymore. Now my next problem is that the outputChatBox does not work ._. (No error or else, only there is no chatbox output)

Edit: Working now (Didn't aim with a weapon on it)

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