rpgforlife Posted April 17, 2014 Posted April 17, 2014 Everytime when i want to repair a car i get an error: WARNING: jobs\mech\server.lua:5: Bad argument @ 'getElementData' [Expected element at argument 1, got nil] local allowedClass = {["Mechanic"] = true} function fix () car = getPedOccupiedVehicle(source) if allowedClass [getElementData ( player, "class" )] == "Mechanic" then price = 1001 - getElementHealth(car) givePlayerMoney(source, price*20) fixVehicle(car) outputChatBox("You have fixed this car", source, 0, 255, 0) end end addEventHandler("onPlayerVehicleEnter", getRootElement(), fix)
Castillo Posted April 17, 2014 Posted April 17, 2014 local allowedClass = { [ "Mechanic" ] = true } function fix ( player ) if ( allowedClass [ getElementData ( player, "class" ) ] ) then local price = ( 1001 - getElementHealth ( source ) ) givePlayerMoney ( player, price * 20 ) fixVehicle ( source ) outputChatBox ( "You have fixed this car", player, 0, 255, 0 ) end end addEventHandler ( "onVehicleEnter", getRootElement(), fix )
Vinctus Posted April 17, 2014 Posted April 17, 2014 make sure to check it's not empty vehicle (that there is someone driving) or players can abuse it by shooting at their vehicle and then repairing it
rpgforlife Posted April 17, 2014 Author Posted April 17, 2014 maybe it clashes with my new spawn screen because i didnt had this problem with my jobs and none of my jobs are working anymore
Castillo Posted April 17, 2014 Posted April 17, 2014 local allowedClass = { [ "Mechanic" ] = true } function fix ( player ) outputChatBox ( "Your class is: ".. tostring ( getElementData ( player, "class" ) ), player ) if ( allowedClass [ getElementData ( player, "class" ) ] ) then local price = ( 1001 - getElementHealth ( source ) ) givePlayerMoney ( player, price * 20 ) fixVehicle ( source ) outputChatBox ( "You have fixed this car", player, 0, 255, 0 ) end end addEventHandler ( "onVehicleEnter", getRootElement(), fix ) See what it outputs to chatbox when you enter a vehicle.
rpgforlife Posted April 17, 2014 Author Posted April 17, 2014 your class is civilian I think my whole spawn is bugged if it says my class is civilian wtf
Castillo Posted April 17, 2014 Posted April 17, 2014 Which is why this doesn't work, your class must be "Mechanic" to work.
rpgforlife Posted April 17, 2014 Author Posted April 17, 2014 The bugg will be in the spawn script then but idk how to fix it ;(
rpgforlife Posted April 17, 2014 Author Posted April 17, 2014 idk if you know Totti, i got the spawn by him.
rpgforlife Posted April 17, 2014 Author Posted April 17, 2014 You can with this spawn, making spawns ingame with a nice gui
Castillo Posted April 17, 2014 Posted April 17, 2014 You can send me part of the spawn system code over PM.
Castillo Posted April 17, 2014 Posted April 17, 2014 Just like I thought, you're using the spawn system I made for a server, which got leaked by one of their staffs. Topic locked.
Recommended Posts