shaio Posted July 22, 2016 Share Posted July 22, 2016 Well this is a small server-side payment script that lets players pay each other, unfortunately my 'money checker' doesn't work, no matter how much money you have, it says you don't have enough. I have no idea why it is doing this.. function payScript(player,cmd,other,amount) local money = getPlayerMoney(player) local otherPlayer = getPlayerFromName(other) if not other then outputChatBox("Syntax: /pay (playerName) (amount)",player,0,255,255) else if not amount then outputChatBox("Syntax: /pay (playerName) (amount)",player,0,255,255) else if ((money - amount) < money) then outputChatBox("You do not have enough money!",player,0,255,255) return else setPlayerMoney(otherPlayer,getPlayerMoney(otherPlayer) + amount) setPlayerMoney(player,money - amount) outputChatBox("$"..amount.." has been sent to "..other.."!",player,0,255,255) outputChatBox("You have received $"..amount.." from "..getPlayerName(player).."!",otherPlayer,0,255,255) end end end end addCommandHandler("pay",payScript) Link to comment
EstrategiaGTA Posted July 22, 2016 Share Posted July 22, 2016 Use this. function payScript(player,cmd,other,amount) local money = getPlayerMoney(player) local otherPlayer = getPlayerFromName(other) if not other then outputChatBox("Syntax: /pay (playerName) (amount)",player,0,255,255) else if not amount then outputChatBox("Syntax: /pay (playerName) (amount)",player,0,255,255) else if ((money - amount) < 0) then outputChatBox("You do not have enough money!",player,0,255,255) return else setPlayerMoney(otherPlayer,getPlayerMoney(otherPlayer) + amount) setPlayerMoney(player,money - amount) outputChatBox("$"..amount.." has been sent to "..other.."!",player,0,255,255) outputChatBox("You have received $"..amount.." from "..getPlayerName(player).."!",otherPlayer,0,255,255) end end end end addCommandHandler("pay",payScript) Link to comment
shaio Posted July 23, 2016 Author Share Posted July 23, 2016 Oh I see what u did, thx bro. I feel retarded now I couldn't figure that out.. Link to comment
LabiVila Posted July 25, 2016 Share Posted July 25, 2016 By the way, since you had the same outputChatBox for both 'if not other then' and 'if not amount then', you can merge them to one line: if not other or not amount then outputChatBox("Syntax: /pay (playerName) (amount)",player,0,255,255) end 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