PaiN^ Posted April 21, 2013 Share Posted April 21, 2013 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
Jaysds1 Posted April 21, 2013 Share Posted April 21, 2013 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
PaiN^ Posted April 21, 2013 Author Share Posted April 21, 2013 Working Thanx ! But i want to ask, What did you do ? just reorginized it or what .. Link to comment
MR.S3D Posted April 21, 2013 Share Posted April 21, 2013 Working Thanx !But i want to ask, What did you do ? just reorginized it or what .. for _,veh in next, getElementsByType ( 'vehicle' ) do use ipairs Link to comment
Jaysds1 Posted April 21, 2013 Share Posted April 21, 2013 Working Thanx !But i want to ask, What did you do ? just reorginized it or what .. for _,veh in next, getElementsByType ( 'vehicle' ) do use ipairs and you had a ' : ' at the end of line 2. Link to comment
PaiN^ Posted April 21, 2013 Author Share Posted April 21, 2013 Oh, i didn't see that, Thanx MR.S3D and jaysds1 + Can you tell me when this kind of error happen ? It's the first time i see it ... Link to comment
Jaysds1 Posted April 21, 2013 Share Posted April 21, 2013 It usually happens when you're trying to index a table, so, when you put ' : ' at the end of line 2, it's attempting to index a table. Link to comment
PaiN^ Posted April 21, 2013 Author Share Posted April 21, 2013 Ok, got it Thanx jaysds1 ^^ Link to comment
ixjf Posted April 22, 2013 Share Posted April 22, 2013 Working Thanx !But i want to ask, What did you do ? just reorginized it or what .. for _,veh in next, getElementsByType ( 'vehicle' ) do use ipairs What's the problem with next? Link to comment
Jaysds1 Posted April 22, 2013 Share Posted April 22, 2013 (edited) WHAT EVER!!! I didn't say you can't/shouldn't use next the problem was the ' : '. Edited April 22, 2013 by Guest Link to comment
ixjf Posted April 22, 2013 Share Posted April 22, 2013 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. Link to comment
PaiN^ Posted April 23, 2013 Author Share Posted April 23, 2013 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 , That's why i started using next insted of ipairs / pairs . Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now