Jump to content

mechanic


rpgforlife

Recommended Posts

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
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
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
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...