Jump to content

Need help


Recommended Posts

Hi. I want to make a script, when player type /double "Amount",  it take the player money,  with math.random, when number numbers under 50 = give back the double money to player, if numbers  above 50 =  then just take the player money.

Anybody can help me please what should i use for this? Thanks!

Edited by TheMOG
Link to comment
addCommandHandler("double", function(p, cmd, money)
  if tonumber(money) then
    local mny = tonumber(money)
    local rnd = math.random(1, 100)
    if rnd <= 50 then
      takePlayerMoney(p, mny)
    else
      givePlayerMoney(p, mny)
    end
  end
end)

As simple as that, you probably over-complicated it.

Link to comment

hmm.

I want check the player money, and the money is positive 

addCommandHandler("double",
function(p, cmd, money)
    if tonumber(money) then
        local mny = tonumber(money)
        local rnd = math.random(1, 100)
	    if mny <= 0 then
	        outputChatBox("Bigger than 0",p)
	    elseif exports["core"]:getMoney(p) >= mny then -- 8
            if rnd <= 50 then  
                exports["core"]:takeMoney(p, mny)
            else
                exports["core"]:giveMoney(p, mny)
            end
        end
	end
end
)

attemt to comapre number with nil

Edited by TheMOG
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...