PT-BR/getPlayerMoney: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Alteração de Templates para a versão em português, dentre eles: OOP e Shared functions.)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server client function}}
{{BR/Funcao compartilhada}}
Returns the amount of money a player currently has.
Retorna a quantidade de dinheiro que um jogador possui.


'''Note:''' The amount may vary between the server and client, you shouldn't trust the client side value to always be accurate.
'''Nota:''' A quantidade pode variar entre o servidor e o cliente. Você não deveria confiar plenamente no valor obtido no cliente.


==Syntax==  
==Sintaxe==  
<section show="true" name="Server" class="server">
<section show="true" name="Server" class="server">
<syntaxhighlight lang="lua">int/bool getPlayerMoney ( player thePlayer )</syntaxhighlight>  
<syntaxhighlight lang="lua">int/bool getPlayerMoney ( player thePlayer )</syntaxhighlight>  
{{OOP||[[player]]:getMoney|money|setPlayerMoney}}
{{PT-BR/POO||[[player]]:getMoney|money|setPlayerMoney}}
===Required Arguments===  
===Argumentos obrigatórios===
*'''thePlayer:''' The player you wish the retrieve the amount of money from.
*'''thePlayer:''' O jogador no qual você deseja obter a quantidade de dinheiro.  


===Returns===
===Retorno===
Returns an integer with the amount of money the specified player has, ''false'' if the player is invalid.
Retorna um inteiro cujo valor é a quantidade de dinheiro que o jogador especificado possui, ou retorna ''false'' se o jogador informado for inválido.
</section>
</section>


<section show="true" name="Client" class="client">
<section show="true" name="Client" class="client">
<syntaxhighlight lang="lua">int getPlayerMoney ( )</syntaxhighlight>  
<syntaxhighlight lang="lua">int getPlayerMoney ( )</syntaxhighlight>  
{{OOP||[[Player]].getMoney||setPlayerMoney}}
{{PT-BR/POO||[[Player]].getMoney||setPlayerMoney}}
===Returns===
===Retorno===
Returns an integer with the amount of money the local player has.
Retorna um inteiro cujo valor é a quantidade de dinheiro que o jogador local possui.
</section>
</section>


==Example==
==Exemplo==
<section show="true" name="Server" class="server">
<section show="true" name="Server" class="server">
When a player types '/checkMoney' this example retrieves the player's money and outputs a message according to the value.
Quando um jogador digita '/checkMoney', este exemplo obtém a quantidade de dinheiro do jogador e mostra uma mensagem de acordo com o valor.
 
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function checkMoney(thePlayer, command)
function checkMoney(thePlayer, command)
local money = getPlayerMoney(thePlayer)                               -- get the amount of money from the player who entered the command
 
if (money > 1000) then                                                 -- if money is more than 1000
-- Obtém a quantidade de dinheiro do jogador que digitou o comando
outputChatBox("You are rich: " .. tostring(money), thePlayer) -- output this message together with the money
local money = getPlayerMoney(thePlayer)
 
-- Se o dinheiro for maior que 1000
if (money > 1000) then  
 
-- Mostra uma mensagem com o texto e a quantidade em dinheiro
outputChatBox("Você é rico: " .. tostring(money), thePlayer)
 
-- Senão (dinheiro for menor ou igual a 1000)
  else
  else
outputChatBox("Poor guy...", thePlayer)                        -- and else, output this message
outputChatBox("Pobre rapaz...", thePlayer)                         
end
end
end
end
addCommandHandler("checkMoney", checkMoney)                                   -- add the console command
 
-- Cria o comando "checkMoney" que, quando digitado, executa a função "checkMoney"
addCommandHandler("checkMoney", checkMoney)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>


==See Also==
==Veja também==
{{Player functions}}
{{Player functions}}


[[en:getPlayerMoney]]
[[en:getPlayerMoney]]
[[pt-br:getPlayerMoney]]
[[ru:getPlayerMoney]]
[[ru:getPlayerMoney]]
[[tr:getPlayerMoney]]
[[tr:getPlayerMoney]]

Latest revision as of 00:51, 11 March 2020

Retorna a quantidade de dinheiro que um jogador possui.

Nota: A quantidade pode variar entre o servidor e o cliente. Você não deveria confiar plenamente no valor obtido no cliente.

Sintaxe

Click to collapse [-]
Server
int/bool getPlayerMoney ( player thePlayer )

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

Método: player:getMoney(...)
Variável: .money
Oposto: setPlayerMoney

Argumentos obrigatórios

  • thePlayer: O jogador no qual você deseja obter a quantidade de dinheiro.

Retorno

Retorna um inteiro cujo valor é a quantidade de dinheiro que o jogador especificado possui, ou retorna false se o jogador informado for inválido.

Click to collapse [-]
Client
int getPlayerMoney ( )

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

Método: Player.getMoney(...)
Oposto: setPlayerMoney

Retorno

Retorna um inteiro cujo valor é a quantidade de dinheiro que o jogador local possui.

Exemplo

Click to collapse [-]
Server

Quando um jogador digita '/checkMoney', este exemplo obtém a quantidade de dinheiro do jogador e mostra uma mensagem de acordo com o valor.

function checkMoney(thePlayer, command)

	-- Obtém a quantidade de dinheiro do jogador que digitou o comando
	local money = getPlayerMoney(thePlayer)

	-- Se o dinheiro for maior que 1000
	if (money > 1000) then 

		-- Mostra uma mensagem com o texto e a quantidade em dinheiro
		outputChatBox("Você é rico: " .. tostring(money), thePlayer)

	-- Senão (dinheiro for menor ou igual a 1000)
 	else
		outputChatBox("Pobre rapaz...", thePlayer)                        
	end
end

-- Cria o comando "checkMoney" que, quando digitado, executa a função "checkMoney"
addCommandHandler("checkMoney", checkMoney)

Veja também

Shared