PT-BR/GivePlayerMoney

From Multi Theft Auto: Wiki
(Redirected from PT-BR/givePlayerMoney)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Esta função adiciona dinheiro a quantia atual do player. Para definir o dinheiro do jogador utilize PT-BR/SetPlayerMoney

Post-it.png Nota: Usar essa função no lado cliente (não recomendável) não irá mudar o dinheiro do jogador no servidor.

Sintaxe

Click to collapse [-]
Server
bool givePlayerMoney ( player thePlayer, int amount )

Sintaxe POO(OOP) Não entendeu o que significa isso?

Método: player:giveMoney(...)
Variável: .money

Argumentos necessários

  • thePlayer: O player que você deseja dar dinheiro.
  • amount: Valor que você deseja dar ao jogador (deve ser um número inteiro e positivo).
Click to collapse [-]
Client
bool givePlayerMoney ( int quantia )

Sintaxe POO(OOP) Não entendeu o que significa isso?

Método: Player.giveMoney(...)

Argumentos necessários

  • amount: Valor que você deseja dar ao jogador (deve ser um número inteiro e positivo).

Retorna

Retorna true se o dinheiro for adicionado ou false se os parâmetros passados são inválidos.

Exemplos

Click to collapse [-]
Exemplo 1 - Client e Server

Este exemplo dá ao jogador dinheiro ao digitar o comando "givecash".

function consoleGiveCash ( thePlayer, command, amount ) --when the givecash command is called
	givePlayerMoney ( thePlayer, amount ) --give the player money according to the amount
end
addCommandHandler ( "givecash", consoleGiveCash  ) --add a handler function for the command "givecash"
Click to collapse [-]
Exemplo 2 - Server

Este exemplo dá a um jogador mil dólares, como recompensa por matar outro jogador.

function rewardOnWasted ( ammo, killer, killerweapon, bodypart )
	--if there is a killer, and that killer is not the same person as whoever died
	if ( killer ) and ( killer ~= source ) then 
		givePlayerMoney ( killer, 1000 ) --reward the killer with 1000 cash.
	end
end
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) --attach the rewardOnWasted function to the relevant event.
Click to collapse [-]
Exemplo 3 - Server

Este exemplo dá ao jogador 30000 ao usar um PickUP.

local money = createPickup (1896.4000244141, -1950.9000244141, 13, 3, 1274, 10000 )
function pickupUse ( player )
    givePlayerMoney ( player, 30000 )
end
addEventHandler ( "onPickupUse", money, pickupUse )

Veja também