DiGiTal Posted June 5, 2017 Share Posted June 5, 2017 Hi, i have a scripts for example cinema once he hit a marker if he have 30,000$ the script will work if not the script will not work Link to comment
idarrr Posted June 5, 2017 Share Posted June 5, 2017 Use getPlayerMoney, use this code to check if the player has enough money to pay. function hasEnoughMoney (thePlayer, amount) if isElement(thePlayer) and getElementType(thePlayer) == "player" then if amount and tonumber(amount) then local amount = tonumber(amount) if amount < 0 then return false end local money = getPlayerMoney(thePlayer) if money >= amount then return true end end end return false end Then when you need to check if the player has enough money, call the function. The first argument is a player element, the second argument is the amount of money you want to check. Example: if hasEnoughMoney(thePlayer, 30000) then -- If the player has $30,000 takePlayerMoney(thePlayer, 30000) -- Don't forget to take their money -- Your code to execute here -- end Link to comment
aka Blue Posted June 5, 2017 Share Posted June 5, 2017 @idarrr Its not necessary use this hasEnoughMoney function. You can use simply: if getPlayerMoney( player ) >= 30000 then takePlayerMoney( player, 30000 ) end 2 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now