I have tried (but I had given up) to create a system which takes away your cash when you die according to how much money you currently have ;(like in GTA games).What I tried to do was to decrease 10% of the current cash the player has when he gets smoked.
This is the code written in LUA:
Nothing happens when I get smoked...player_cash is not working accordingly and it's obvious that it doesn't get called like in bulding_purchase.lua.Here is a slice of code taken from builing_purchase.lua which uses the same variable player_cash as I used :
What's wrong with my code and why player_cash doesn't get called from C++ but in the other ones from the [stores].lua do get called?
This is the code written in LUA:
function cash_penalty(player_cash)
on_death("the_penalty",LOCAL_PLAYER)
end
function the_penalty()
cash_add( -((player_cash*10) /100)) ) --- the minus before means that it adds negative cash which means that it decreases the cash
end
Nothing happens when I get smoked...player_cash is not working accordingly and it's obvious that it doesn't get called like in bulding_purchase.lua.Here is a slice of code taken from builing_purchase.lua which uses the same variable player_cash as I used :
if player_cash < store_cost then
-- Show Dialog that says you can't afford it.
...
else
-- Ask player if they really want to purchase it.
...
end
What's wrong with my code and why player_cash doesn't get called from C++ but in the other ones from the [stores].lua do get called?