Jump to content

[Snippet] /givecash command


Recommended Posts

Ok i made a simple /givecash command, here you are ;)

function giveCash( source, command, giveplayername, amount ) 
    local money = getPlayerMoney( source ) 
    local givenplayer = getPlayerFromNick ( giveplayername ) 
    local playername = getClientName ( source )  
    local moneytogive = tonumber(amount)     
    if( money < moneytogive ) then 
        outputChatBox ( "* Invalid amount", source, 243, 151, 12 ) 
        return 
    end  
    if( moneytogive < 1 ) then 
        outputChatBox ( "* Invalid amount", source, 243, 151, 12 ) 
        return 
    end      
    if( givenplayer ) then 
        givePlayerMoney ( givenplayer, amount ) 
        takePlayerMoney ( source, tonumber(amount) ) 
        outputChatBox ( "* You have send $" ..amount.." to "..getClientName ( givenplayer ).. ".", source, 243, 151, 12 ) 
        outputChatBox ( "* " ..playername.. " sent you $" ..amount.. ".", givenplayer, 243, 151, 12 ) 
    else  
        outputChatBox ( "* That playername does not exist", source, 243, 151, 12 ) 
    end      
end 
  
  
addCommandHandler ( "givecash", giveCash )  

Edited by Guest
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...