roaddog Posted July 10, 2014 Posted July 10, 2014 Hai I got a lil problem with this custom wanted level. error says attempt to compare number with nil function handleVehicleDamage(attacker, weapon, loss, x, y, z, tyre) -- Protect law and staff from getting wanted local hasWantedPlayersInside = false local occupants = getVehicleOccupants( source ) local vx,vy,vz = getElementPosition( source ) local px,py,pz = getElementPosition( localPlayer ) local dist = getDistanceBetweenPoints3D( vx,vy,vz, px,py,pz ) if occupants then for seat, occupant in pairs(occupants) do if getElementType(occupant) == "player" then if tonumber(getElementData(occupant,"Wanted")) > 0 then ----- this line gives error hasWantedPlayersInside = true end end end end You gone learn today. I work my ass off, but I still can't pay tho.
manawydan Posted July 10, 2014 Posted July 10, 2014 getElementData can return nil if no is set. try function handleVehicleDamage(attacker, weapon, loss, x, y, z, tyre) -- Protect law and staff from getting wanted local hasWantedPlayersInside = false local occupants = getVehicleOccupants( source ) local vx,vy,vz = getElementPosition( source ) local px,py,pz = getElementPosition( localPlayer ) local dist = getDistanceBetweenPoints3D( vx,vy,vz, px,py,pz ) if occupants then for seat, occupant in pairs(occupants) do if getElementType(occupant) == "player" then if (tonumber(getElementData(occupant,"Wanted")) or 0) > 0 then ----- this line gives error hasWantedPlayersInside = true else outputChatBox("No data, or data<0",root) end end end end "Querer não é poder, mas tentar é avançar"!
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