Jump to content

Charging for repairs


Recommended Posts


local vehicleHealth = getElementHealth ( vehicle ) / 10 
triggerServerEvent( "takeRepairMoney", getLocalPlayer(), resourceRoot, vehicleHealth - 100 ) 


function takeRepairMoney ( thePlayer, command, amount )     -- when the takeRepairMoney command is called 
        takePlayerMoney ( thePlayer, tonumber(amount) ) -- take the amount of money from the player 
addCommandHandler ( "takeRepairMoney", takeRepairMoney )           -- add a handler function for the command "takecash" 

It displays vehicle health but wont charge accordingly. It gives the error: [2015-02-16 06:53:48] ERROR: Client (=[T]=) triggered serverside event takeRepairMoney, but event is not added serverside. Yet it is...

Link to comment

Try this at client side:

triggerServerEvent( "takeRepairMoney", resourceRoot, vehicleHealth - 100 ) -- [[vehicleHealth - 100]] should be a number btw, since its the cost amount. 

And you are adding a command in serverside, not an event, try this one:

function takeRepairMone (amount) 
addEvent("takeRepairMoney", true) 
addEventHandler("takeRepairMoney", root, takeRepairMoney) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...