Jump to content

[HELP]pay code


DiGiTal

Recommended Posts

Posted

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

Posted

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

 

 

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