SkrillexX Posted February 28, 2014 Posted February 28, 2014 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.
Castillo Posted February 28, 2014 Posted February 28, 2014 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.
SkrillexX Posted February 28, 2014 Author Posted February 28, 2014 Thanks but how to make it check if its between 1000$ and 5000$ ?
Castillo Posted February 28, 2014 Posted February 28, 2014 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 )
Moderators Citizen Posted February 28, 2014 Moderators Posted February 28, 2014 Thanks but how to make it check if its between 1000$ and 5000$ ? Well the if statement you wanted was: if ( money > 1000 and money < 5000 ) then
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