Jump to content

Help


SkrillexX

Recommended Posts

Greetings , i've been recently learning how to script and as my first script , i tried to make something simple. A command that would give you money if your money is between 1000$ and 5000$. This is my lua code.

function giveMoney(cmd , thePlayer) 
number = math.random (1000,5000) 
money = getPlayerMoney(thePlayer) 
 if money == number then  
 givePlayerMoney(thePlayer, 1000) 
 else 
 outputChatBox ("You already have enough money , fool" ,getRootElement(),250 ,250 ,0 ) 
 end 
 addCommandHandler ("money" ,giveMoney ) 
end 
  

Please , if any you see an error try to notify me it. Thanks.

Link to comment
function giveMoney ( thePlayer ) 
    local number = math.random ( 1000, 5000 ) 
    local money = getPlayerMoney ( thePlayer ) 
    if ( money == number ) then 
        givePlayerMoney ( thePlayer, 1000 ) 
    else 
        outputChatBox ( "You already have enough money , fool", thePlayer, 250, 250, 0  ) 
    end 
end 
addCommandHandler ( "money", giveMoney ) 

By the way, this script will check if your money is EXACTLY the same amount as math.random returned.

Link to comment
function giveMoney ( thePlayer ) 
    local money = getPlayerMoney ( thePlayer ) 
    if ( money < 5000 ) then 
        givePlayerMoney ( thePlayer, 1000 ) 
    else 
        outputChatBox ( "You already have enough money , fool", thePlayer, 250, 250, 0  ) 
    end 
end 
addCommandHandler ( "money", giveMoney ) 

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