rpgforlife Posted April 17, 2014 Share 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) Link to comment
Castillo Posted April 17, 2014 Share 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 ) Link to comment
Castillo Posted April 17, 2014 Share Posted April 17, 2014 Any errors in debugscript? Link to comment
Vinctus Posted April 17, 2014 Share 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 Link to comment
rpgforlife Posted April 17, 2014 Author Share 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 Link to comment
Castillo Posted April 17, 2014 Share 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. Link to comment
rpgforlife Posted April 17, 2014 Author Share Posted April 17, 2014 your class is civilian I think my whole spawn is bugged if it says my class is civilian wtf Link to comment
Castillo Posted April 17, 2014 Share Posted April 17, 2014 Which is why this doesn't work, your class must be "Mechanic" to work. Link to comment
rpgforlife Posted April 17, 2014 Author Share Posted April 17, 2014 The bugg will be in the spawn script then but idk how to fix it ;( Link to comment
Castillo Posted April 17, 2014 Share Posted April 17, 2014 What spawn system are you using? Link to comment
rpgforlife Posted April 17, 2014 Author Share Posted April 17, 2014 idk if you know Totti, i got the spawn by him. Link to comment
rpgforlife Posted April 17, 2014 Author Share Posted April 17, 2014 You can with this spawn, making spawns ingame with a nice gui Link to comment
rpgforlife Posted April 17, 2014 Author Share Posted April 17, 2014 Can you fix it maybe? Link to comment
Castillo Posted April 17, 2014 Share Posted April 17, 2014 You can send me part of the spawn system code over PM. Link to comment
Castillo Posted April 17, 2014 Share 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. Link to comment
Recommended Posts