Jump to content

userdata value ?!!


PaiN^

Recommended Posts

marker = createMarker ( 205.71435546875, 2511.4284667969, 16.558746337891 - 1, 'checkpoint', 20, 255, 255, 255, 255 ); 
createBlipAttachedTo ( marker, 9 ): 
  
addEventHandler ( 'onMarkerHit', marker,  
    function ( car ) 
        if getElementType ( car ) == 'vehicle' then 
            destroyElement ( car ); 
        end 
    end 
); 
  
setTimer ( function ( ) 
    for _,veh in next, getElementsByType ( 'vehicle' ) do 
        if isElementWithinMarker ( veh, marker ) then 
            destroyElement ( veh ); 
        end 
    end 
end, 1000, 0 ); 

Error : AD\server.lua:4: attempt to index a userdata value

Link to comment

try this:

local marker = createMarker ( 205.71435546875, 2511.4284667969, 16.558746337891 - 1, 'checkpoint', 20, 255, 255, 255, 255 ) 
createBlipAttachedTo ( marker, 9 ) 
  
addEventHandler ('onMarkerHit',marker,function ( car ) 
    if getElementType ( car ) == 'vehicle' then 
        destroyElement ( car ) 
    end 
end) 
  
setTimer (function () 
    for _,veh in ipairs(getElementsByType ( 'vehicle' )) do 
        if isElementWithinMarker ( veh, marker ) then 
            destroyElement ( veh ) 
        end 
    end 
end,1000,0) 

Link to comment
Don't tell me to read that, because I honestly have read that million times already. You can directly use next instead of pairs/ipairs.

Yes, i read that somewhere in the forum xD, That's why i started using next insted of ipairs / pairs .

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