ÆBKV Posted February 1, 2018 Posted February 1, 2018 (edited) function giveMoney(sender,command,name,amount) if not name or not amount then outputChatBox("Usage: #FFFFFF/givemoney [player name] [amount]",sender,255,0,0,true) return end local receiver = getPlayerFromName(name) if not receiver then outputChatBox("Couldn't find a player with the name #FFFFFF("..name..").",sender,255,0,0,true) return end local receiver = getPlayerFromName(name) if receiver == sender then outputChatBox("You can't give money to yourself.",sender,255,0,0) return end if not tonumber(amount) then outputChatBox("Please enter a valid value.",sender,255,0,0) return end local receiver = getPlayerFromName(name) local receivername = getPlayerName(receiver) local sendername = getPlayerName(sender) local sendermoney = getPlayerMoney(sender) if receiver and tonumber(amount) <= sendermoney then takePlayerMoney(sender,amount) givePlayerMoney(receiver,amount) outputChatBox("You gave #FFFFFF"..receivername.." #00FF00$"..tonumber(amount)..".",sender,0,255,0,true) outputChatBox(""..sendername.." #00FF00gave you $"..tonumber(amount)..".",receiver,255,255,255,true) else outputChatBox("You don't have $"..tonumber(amount)..".",sender,255,0,0,true) end end addCommandHandler("givemoney",giveMoney) For example, when I type in /givemoney 4BKV -500 it works too. How can I fix this? Edited February 1, 2018 by ÆBKV
Bilal135 Posted February 1, 2018 Posted February 1, 2018 (edited) function giveMoney(sender,command,name,amount) if not name or not amount then outputChatBox("Usage: #FFFFFF/givemoney [player name] [amount]",sender,255,0,0,true) return end local receiver = getPlayerFromName(name) if not receiver then outputChatBox("Couldn't find a player with the name #FFFFFF("..name..").",sender,255,0,0,true) return end local receiver = getPlayerFromName(name) if receiver == sender then outputChatBox("You can't give money to yourself.",sender,255,0,0) return end if not tonumber(amount) then outputChatBox("Please enter a valid value.",sender,255,0,0) return end local receiver = getPlayerFromName(name) local receivername = getPlayerName(receiver) local sendername = getPlayerName(sender) local sendermoney = getPlayerMoney(sender) if receiver and tonumber(amount) <= sendermoney then if (amount < 0) then return outputChatBox("Please select a positive number to send.", sender, 255, 0, 0) end takePlayerMoney(sender,amount) givePlayerMoney(receiver,amount) outputChatBox("You gave #FFFFFF"..receivername.." #00FF00$"..tonumber(amount)..".",sender,0,255,0,true) outputChatBox(""..sendername.." #00FF00gave you $"..tonumber(amount)..".",receiver,255,255,255,true) else outputChatBox("You don't have $"..tonumber(amount)..".",sender,255,0,0,true) end end addCommandHandler("givemoney",giveMoney) Edited February 1, 2018 by Bilal135
Storm-Hanma Posted February 1, 2018 Posted February 1, 2018 (edited) 4 hours ago, ÆBKV said: local receiver = getPlayerFromName(name) if receiver == sender then outputChatBox("You can't give money to yourself.",sender,255,0,0) return end it clearly shows the function receiver - sender, then how can you sen money to yourself? test it now may work function giveMoney(sender,command,name,amount) if not name or not amount then outputChatBox("Usage: #FFFFFF/givemoney [player name] [amount]",sender,255,0,0,true) return end local receiver = getPlayerFromName(name) if not receiver then outputChatBox("Couldn't find a player with the name #FFFFFF("..name..").",sender,255,0,0,true) return end if not tonumber(amount) then outputChatBox("Please enter a valid value.",sender,255,0,0) return end local receiver = getPlayerFromName(name) local receivername = getPlayerName(receiver) local sendername = getPlayerName(sender) local sendermoney = getPlayerMoney(sender) if receiver and tonumber(amount) <= sendermoney then takePlayerMoney(sender,amount) givePlayerMoney(receiver,amount) outputChatBox("You gave #FFFFFF"..receivername.." #00FF00$"..tonumber(amount)..".",sender,0,255,0,true) outputChatBox(""..sendername.." #00FF00gave you $"..tonumber(amount)..".",receiver,255,255,255,true) else outputChatBox("You don't have $"..tonumber(amount)..".",sender,255,0,0,true) end end addCommandHandler("givemoney",giveMoney) test it Edited February 1, 2018 by Khadeer143 1
SycroX Posted February 1, 2018 Posted February 1, 2018 (edited) function giveMoney(sender,_, name, amount) if not name or not amount then outputChatBox("Usage: #FFFFFF/givemoney [player name] [amount]", sender, 255, 0, 0, true) return end local receiver = getPlayerFromName(name) local sendername = getPlayerName(sender) local sendermoney = getPlayerMoney(sender) local amount = tonumber(amount) if not receiver then outputChatBox("Couldn't find a player with the name #FFFFFF("..name..").", sender, 255, 0, 0, true) return end if receiver == sender then outputChatBox("You can't give money to yourself.", sender, 255, 0, 0) return end if not amount or tostring(amount):find("-") then outputChatBox("Please enter a valid value.", sender, 255, 0, 0) return end if getPlayerMoney(sender) >= amount then takePlayerMoney(sender, amount) givePlayerMoney(receiver, amount) outputChatBox("You gave #FFFFFF"..name.." #00FF00$"..tostring(amount)..".", sender, 0, 255, 0, true) outputChatBox(""..sendername.." #00FF00gave you $"..tostring(amount)..".", receiver, 255, 255, 255, true) else outputChatBox("You don't have $"..tostring(amount)..".", sender, 255, 0, 0, true) end end addCommandHandler("givemoney", giveMoney) Edited February 1, 2018 by #x1AhMeD,-09
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