Jump to content

[HELP] Bad argument on destroyElement


HeK

Recommended Posts

I'm getting a weird warning on destroyElement.

"WARNING: script\script_client\:62: Bad argument @ 'destroyElement'

"WARNING: script\script_client\:63: Bad argument @ 'destroyElement'

Could someone explain to me, what's going on?

These are the lines:

             destroyElement ( robhouseMarker ) 
           destroyElement ( robhouseBlip ) 

Link to comment
  • Moderators

Make sure the element do exist.

 

Most of the time the problem:

When you try to destroy an element that already have been destroyed.

To solve it:

if robhouseMarker and robhouseBlip then 
   destroyElement ( robhouseMarker ) 
   destroyElement ( robhouseBlip ) 
end 

or if you aren't sure they both exist:

if robhouseMarker then 
   destroyElement ( robhouseMarker ) 
end 
if  robhouseBlip then 
   destroyElement ( robhouseBlip ) 
end 

Link to comment

Here's the code, i tried those but still doesn't work, still gives me warnings.

addEventHandler ( "onClientMarkerHit", root, 
    function ( hitElement ) 
        if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then 
            triggerServerEvent ( "givePlayerPayment", localPlayer ) 
        if robhouseMarker and robhouseBlip then 
            destroyElement ( robhouseMarker ) 
            destroyElement ( robhouseBlip ) 
        end 
            triggerEvent ( "createHouseEvent", localPlayer ) 
        end 
    end 
) 

Link to comment
  • Scripting Moderators

Try

if isElement ( robhouseMarker ) and isElement ( robhouseBlip ) then 
    destroyElement ( robhouseMarker ) 
    destroyElement ( robhouseBlip ) 
end 

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