Danii.- Posted December 29, 2021 Share Posted December 29, 2021 Hello guys, today i tried to make an traffipax script, but i got this error code: server.lua:212: Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got vehicle] Here is the code: local s1321321 = createColRectangle ( 1816.85632, -1793.69824, 13.38281, 1, 1) function bunti ( source ) local vehicle = getPedOccupiedVehicle(source) local velx, vely, velz = getElementVelocity( vehicle ) local speed = (velx ^ 2 + vely ^ 2 + velz ^ 2) ^ (0.5) local kmh = math.floor(speed * 180 ) local mgng = 50 local tul = kmh - mgng if theVehicle then if kmh > 50 then outputChatBox("#ff0000 *TRAFFIPAX* Sebességkorlát: 50km/h", source, 255, 194, 14, true) outputChatBox("#ff0000 *TRAFFIPAX* Sebességed:" ..kmh.. ". Bírság: 30000 Ft. Levonva a készpénzedből vagy a bankszámládról.", source, 255, 194, 14, true) outputChatBox("#ff0000 *TRAFFIPAX* Túllépés:" ..tul.."km/h.", source, 255, 194, 14, true) end end end addEventHandler ( "onColShapeHit", s1321321, bunti ) Solved. Link to comment
The_GTA Posted December 29, 2021 Share Posted December 29, 2021 (edited) Hello Danii.-, ist looks like you are expecting a player (not ped) inside of your onColShapeHit server-side event handler but have not installed logic to handle other element types, such as vehicles. I suggest you to use the getElementType function in connection with an if-statement to limit your event handler to source variable elements that are players. Or you could limit it to vehicles but then check that the vehicle is being driven by a player. As it currently stands, there is a common bug/misconception in your code. Hope this helps! Edited December 29, 2021 by The_GTA Link to comment
Danii.- Posted December 29, 2021 Author Share Posted December 29, 2021 Thank you very much. Helped a lot. Solved. 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