Jump to content

Help With Give COmmand


xXMADEXx

Recommended Posts

Posted

I have this command ( /give and /pay ) but i dont know how to make it so that the player sending money haves to have the amount of money that there sending. Like, i dont want sender want to be able to go in negative money.

function givecash(thePlayer, command, who, amount) 
    local noobwiegeldkrijgt = getPlayerFromName ( who ) 
    local noobdiegeldgeeft = getPlayerFromName ( thePlayer ) 
    if (getPlayerMoney(thePlayer) >= amount) then 
        givePlayerMoney (noobwiegeldkrijgt, math.abs(tonumber(amount))) 
        takePlayerMoney (thePlayer, math.abs(tonumber(amount))) 
    else 
        outputChatBox("Sorry, You Do Not Have That Much Money To Give.", thePlayer, 255, 0, 0 ) 
    end 
end 
addCommandHandler ("give", givecash) 
addCommandHandler ("pay", givecash) 

Posted

Simple add:

if ( tonumber ( amount ) < 0 ) then 
    return 
end 

Before:

    if (getPlayerMoney(thePlayer) >= amount) then 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Post the script.
function givecash(thePlayer, command, who, amount) 
    local noobwiegeldkrijgt = getPlayerFromName ( who ) 
    local noobdiegeldgeeft = getPlayerFromName ( thePlayer ) 
    if ( tonumber ( amount ) < 0 ) then return end 
    if (getPlayerMoney(thePlayer) >= amount) then 
        givePlayerMoney (noobwiegeldkrijgt, math.abs(tonumber(amount))) 
        takePlayerMoney (thePlayer, math.abs(tonumber(amount))) 
    else 
        outputChatBox("Sorry, You Do Not Have That Much Money To Give.", thePlayer, 255, 0, 0 ) 
    end 
end 
addCommandHandler ("give", givecash) 

Posted
function givecash(thePlayer, command, who, amount) 
    local noobwiegeldkrijgt = getPlayerFromName ( who ) 
    local noobdiegeldgeeft = getPlayerName ( thePlayer ) 
    if ( tonumber ( amount ) < 0 ) then return end 
    if (getPlayerMoney(thePlayer) >= tonumber(amount)) then 
        givePlayerMoney (noobwiegeldkrijgt, math.abs(tonumber(amount))) 
        takePlayerMoney (thePlayer, math.abs(tonumber(amount))) 
    else 
        outputChatBox("Sorry, You Do Not Have That Much Money To Give.", thePlayer, 255, 0, 0 ) 
    end 
end 
addCommandHandler ("give", givecash) 

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...