Jump to content

adding money to the player's account using nickname


Dzemous

Recommended Posts

Hi! I am writing a script to transfer money from one player's account to another. I have already written a code to collect money from the sender's account, but I have no idea how to add the money to the recipient's account.  I know that the function responsible for adding money is

https://wiki.multitheftauto.com/wiki/GivePlayerMoney

and looks like this

bool givePlayerMoney ( player thePlayer, int amount )

And I want to use it to add money to another player's account.  How do I specify the name of the recipient's account in this function? I have to use "for" for this or how can I still do it?

My code (this is s-side):

function przekaz (nadawca, komenda, odbiorca, kwota)  -- who used command, commandname, the variable of the player to whom the money is transferred, amount

    local pieniazki = tonumber(kwota)  --variable amount
        if (getPlayerMoney(nadawca)==pieniazki) or (getPlayerMoney(nadawca)>pieniazki) then --if the player's amount is equal to or greater than the amount to be sent
            takePlayerMoney (nadawca, kwota)  -- collects the amount of money sent from the player's account
                outputChatBox("Wysłałeś kwotę" ..pieniazki.. "graczowi" ..odbiorca  , nadawca)  --sends a successful transaction notification
                    --here is to be a line with a function whose task is to add a specific amount to the player's account. 

end
end
addCommandHandler("zaplac", przekaz)
addCommandHandler("dajkase", przekaz)
addCommandHandler("przelej", przekaz)

 

Link to comment
function przekaz (nadawca, komenda, odbiorca, kwota)  -- who used command, commandname, the variable of the player to whom the money is transferred, amount
	local pieniazki = tonumber(kwota)  --variable amount
		if (getPlayerMoney(nadawca)==pieniazki) or (getPlayerMoney(nadawca)>pieniazki) then --if the player's amount is equal to or greater than the amount to be sent
			takePlayerMoney(nadawca, kwota)  -- collects the amount of money sent from the player's account
			outputChatBox("Wysłałeś kwotę" ..pieniazki.. "graczowi" ..odbiorca  , nadawca)  --sends a successful transaction notification
			givePlayerMoney(getPlayerFromName(odbiorca), kwota) --here is to be a line with a function whose task is to add a specific amount to the player's account. 
		end
	end
end
addCommandHandler("zaplac", przekaz)
addCommandHandler("dajkase", przekaz)
addCommandHandler("przelej", przekaz)

You can use getPlayerFromName to get the player from their name, and then givePlayerMoney.

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