Jump to content

mechanic


rpgforlife

Recommended Posts

Posted

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) 

Posted
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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Any errors in debugscript?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 :P

hi i script and stuff

Posted
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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Which is why this doesn't work, your class must be "Mechanic" to work.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

What spawn system are you using?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You can send me part of the spawn system code over PM.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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