TorNix~|nR Posted August 1, 2017 Posted August 1, 2017 (edited) Guys there is a problem with this script please help! for example I can use /sendmoney "name" -9000 and I take 9000$ from his money any help please? function sendmoney (source, commandname, target, ammount) local sourcemoney = getPlayerMoney (source) local sourcename = getPlayerName ( source ) local targetp = getPlayerFromName (target) if targetp then if sourcemoney >= tonumber (ammount) then takePlayerMoney (source, ammount) givePlayerMoney (targetp, ammount) outputChatBox ( "You gave " .. target .. " " .. ammount .. "$", source, 0, 255, 0) outputChatBox ( "" .. sourcename .. "gave you " .. ammount .. "$", targetp, 0, 255, 0 ) else outputChatBox ( "You do not have enough money", source, 0, 255, 0 ) end else outputChatBox ( "Invalid target specified", source, 0, 255, 0 ) end end addCommandHandler("sendmoney", sendmoney) Edited August 1, 2017 by TorNix~|nR
itHyperoX Posted August 1, 2017 Posted August 1, 2017 (edited) edit mine addCommandHandler("pay",function(player,cmd,targetPlayer,money) money = tonumber(money) and math.floor(tonumber(money)) or nil if not (targetPlayer) or not (money) then outputChatBox(syntax.." /" .. cmd .. " [Player] [Amount]",player,255,0,0,true) else local targetPlayer = getPlayerFromName (targetPlayer) if targetPlayer then if (targetPlayer==player) then outputChatBox(error.." You cant give money to yourself.",player,255,0,0,true) elseif money <= 0 then outputChatBox(error.." Minimum ammount is 0.",player,255,0,0,true) elseif getPlayerMoney(player) >= money then takePlayerMoney(player,money) givePlayerMoney(targetPlayer,money) else outputChatBox(error.." You dont have enough money.",player,177,9,45,true) end end end end) Edited August 1, 2017 by TheMOG 1
TorNix~|nR Posted August 1, 2017 Author Posted August 1, 2017 @TheMOG, the final help please? I don't know why the line 16 doesnt work help? addCommandHandler("sendmoney",function(player,cmd,targetPlayer,money) money = tonumber(money) and math.floor(tonumber(money)) or nil if not (targetPlayer) or not (money) then outputChatBox(syntax.." /" .. cmd .. " [Player] [Amount]",player,255,0,0,true) else local targetPlayer = getPlayerFromName (targetPlayer) local sourcename = getPlayerName (source) if targetPlayer then if (targetPlayer==player) then outputChatBox(" You cant give money to yourself.",player,255,0,0,true) elseif money <= 0 then outputChatBox(" Minimum ammount is 0.",player,255,0,0,true) elseif getPlayerMoney(player) >= money then takePlayerMoney(player,money) givePlayerMoney(targetPlayer,money) outputChatBox ( "You gave " .. targetPlayer .. " " .. money .. "$", source, 0, 255, 0, true) -- LINE outputChatBox ( "" .. sourcename .. "gave you " .. money .. "$", targetPlayer, 0, 255, 0, true ) -- LINE else outputChatBox(" You dont have enough money.",player,177,9,45,true) end end end end)
itHyperoX Posted August 1, 2017 Posted August 1, 2017 (edited) source = player outputChatBox ( "You gave " .. targetPlayer .. " " .. money .. "$", source, 0, 255, 0, true) -- LINE replace with this outputChatBox ( "You gave " .. targetPlayer .. " " .. money .. "$", source, 0, 255, 0, true) -- LINE outputChatBox (player .. "gave you " .. money .. "$", targetPlayer, 0, 255, 0, true ) -- LINE Edited August 1, 2017 by TheMOG
TorNix~|nR Posted August 1, 2017 Author Posted August 1, 2017 :attempt to concatenate local 'targetPlayer' (a userdata value)
Dimos7 Posted August 2, 2017 Posted August 2, 2017 (edited) addCommandHandler("sendmoney",function(player,cmd,sendToName,money) money = tonumber(money) and math.floor(tonumber(money)) or nil if not (sendToName) or not (money) then outputChatBox(syntax.." /" .. cmd .. " [Player] [Amount]",player,255,0,0,true) else local targetPlayer = getPlayerFromName (sendtoName) local sourcename = getPlayerName (source) if targetPlayer then if (targetPlayer==player) then outputChatBox(" You cant give money to yourself.",player,255,0,0,true) elseif money <= 0 then outputChatBox(" Minimum ammount is 0.",player,255,0,0,true) elseif getPlayerMoney(player) >= money then takePlayerMoney(player,money) givePlayerMoney(targetPlayer,money) outputChatBox ( "You gave " .. targetPlayer .. " " .. money .. "$", source, 0, 255, 0, true) -- LINE outputChatBox ( "" .. sourcename .. "gave you " .. money .. "$", targetPlayer, 0, 255, 0, true ) -- LINE else outputChatBox(" You dont have enough money.",player,177,9,45,true) end end end end) Edited August 2, 2017 by Dimos7
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