Daniels69 Posted August 4, 2016 Share Posted August 4, 2016 Hello , lately i was making something like an house system. and i stopped at this warning. which i can't really solve , or my lua experience is too small. it appears that the code below doesn't seem to get the housemark variable.. and that's why the warning comes , and the script doesn't really work any more , any ideas how to solve it? Thanks CODE: function addhouses(thePlayer,command,arg) local x,y,z = getElementPosition(thePlayer) local r,g,b = 255,255,0 housemark = createMarker ( x , y, z+1, "arrow", 1.5, r, g, b, 170 ) if (housemark) then outputDebugString("house created") setElementData(housemark,"mtasa-house",true) setElementData(housemark,"mtasa-housename",arg) -- if getElementData(house,"mtasa-housesold") == false end end addCommandHandler("addhouse",addhouses) function househit(player) if getElementType( player ) == 'player' and not getPedOccupiedVehicle( player ) then if not isGuestAccount( getPlayerAccount( player ) ) then --some stuff happens here else outputChatBox( 'You must be logged in', player, 255, 51, 36 ); end; end; end addEventHandler("onMarkerHit",housemark,househit) ERROR: WARNING: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] Link to comment
Bonus Posted August 4, 2016 Share Posted August 4, 2016 Use the addEventHandler when you create it (= use it after line 6). Also you can use local for the housemarker after you did that. Explanation: You create the marker after using the command. So you can't attach the addEventHandler before using the command, cause the marker isn't even created. 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