Jump to content

playerblips


Drakath

Recommended Posts

I'm using a default resource called "playerblips". It worked fine but today, logs are spamming this:

WARNING: playerblips\playerblips.lua:66: Bad argument @ 'getElementType' [Expected element at argument 1]

function destroyBlipsAttachedTo(player) 
    local attached = getAttachedElements ( player ) 
    if ( attached ) then 
        for k,element in ipairs(attached) do 
            if getElementType ( element ) == "blip" then 
                destroyElement ( element ) 
            end 
        end 
    end 
end 

What causes this?

Link to comment
function destroyBlipsAttachedTo(player) 
    local attached = getAttachedElements ( player ) 
    if ( attached ) then 
        for k,element in ipairs(attached) do 
            if getElementType ( element ) == "blip" then 
                destroyElement ( element ) 
            end 
        end 
    end 
end 

function destroyBlipsAttachedTo( ) 
    local attached = getAttachedElements ( source ) 
    if getElementType ( attached ) == "player" then 
        for k,element in ipairs(attached) do 
            if getElementType ( element ) == "blip" then 
                destroyElement ( element ) 
            end 
        end 
    end 
end 

You did not specify to who does the script has to attach the blip, dunno if it works, I haven't tested it... If the error is still going, specify the elemnt, maybe something like:

element = getElementType ( ) == "blip" 

Link to comment

Just add if isElement(element):

  
for k,element in ipairs(attached) do 
  
    if isElement(element) and getElementType ( element ) == "blip" then 
        destroyElement ( element ) 
    end 
end 

That ensures that the element in the loop is a valid element, not an already destroyed one.

D&G: You're trying to get the element type of a table or possibly a boolean value.

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