Jump to content

Send Money


TorNix~|nR

Recommended Posts

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 by TorNix~|nR
Link to comment

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 by TheMOG
  • Thanks 1
Link to comment

@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)

 

Link to comment
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 by Dimos7
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...