https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=Eficiencia&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-28T14:45:31ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=P%C3%A1gina_Inicial&diff=67201Página Inicial2020-08-06T22:32:02Z<p>Eficiencia: </p>
<hr />
<div>{| width="100%" cellspacing="0" cellpadding="0"<br />
| colspan="2" |<br />
<div style="border: 1px solid #D8D8D8; padding: 5px; height: 130px;"><br />
[[File:Mtalogo.png|left|100px]]'''Bem vindo ao Wiki do Multi Theft Auto.''' Aqui você encontra tudo sobre o uso desta modificação.<br />
<br />
Há muitas [[How you can help|coisas em que você pode nos ajudar]] para melhorar este programa, como criar um mapa, um modo de jogo, documentar funções e eventos, escrever códigos úteis para outros usuários, fazer tutoriais, reportar bugs que encontrar ou somente jogar a vontade!<br />
<br />
Se você tem alguma dúvida a respeito do Multi Theft Auto, não se esqueça de perguntar à comunidade em nossos [http://forum.mtasa.com/ fóruns].<br />
<br><br><br />
[ Pare de jogar sozinho ]<br />
<br><br><br />
</div><br />
|}<br />
{| width="100%" cellspacing="0" cellpadding="0"<br />
| colspan="2" |<br />
|-<br />
|width="50%" style="vertical-align:top;" |<div style="border: 1px solid #D8D8D8; padding:4px 8px 8px 8px; margin:10px; background: #FFFCF2;"><br />
<div style="float:right; width: 32px;">[[File:Input-gaming.png|link=]]</div><br />
<h3>Jogar</h3><br />
<div style="background: #FFEEAA; border: 1px solid #FFCD19;"><br />
[[File:Go-down.png|link=http://mtasa.com/]] ''' [http://mtasa.com/ Baixe o Multi Theft Auto {{Current Version|full}}]'''</div><br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Onde_adquirir_o_GTASA|Onde adquirir o GTASA]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Manual_do_Cliente|Manual do usuário]]<br />
<!--* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Novidades_na_versão_{{Current Version|full}}|Novidades da última versão ]] --><br />
* [[Image:iUS.png|Em Inglês|20px]] [[Changes_in_{{padleft:|5|{{Current Version|full}}}}| Novidades da versão {{padleft:|5|{{Current Version|full}}}}]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Soluções_de_Problemas_-_FAQ|Solução de problemas]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Migrando_do_MTA:Race_ao_MTA:SA_1.3|Migrando do MTA:Race para o MTA:SA {{padleft:|3|{{Current Version|full}}}}]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Manual_do_Servidor|Manual do servidor]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Recursos:Map_Manager|Gerenciador de mapas (''Map Manager'')]]<br />
<br />
<h3>Editor de mapas</h3><br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Resource:Editor|Manual do editor]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Resource:Editor-EDF|Ficheiro de definições do editor (EDF)]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Resource:Editor-Plugins|Extensões para o editor]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Resource:Editor#FAQ|Perguntas frequentes (FAQ)]]<br />
</div><br />
<div style="border: 1px solid #D8D8D8; padding:4px 8px 8px 8px; margin:10px;"><br />
<div style="float:right; width: 32px;">[[File:Package-x-generic.png|link=]]</div><br />
<h3>Banco de dados</h3><br />
Aqui tem tudo relacionado às vantagens que Lua tem a oferecer ao MTA e seus recursos.<br />
* [[Image:iUS.png|Em Inglês|20px]] [[:Category:Resource|Catálogo de Recursos]] - Você deve aprender com eles para fazer scripts bons<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Scripts_do_Cliente|Scripts do Cliente]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Módulos|Módulos]]<br />
</div><br />
<br />
<div style="border: 1px solid #D8D8D8; padding:4px 8px 8px 8px; margin:10px;"><br />
<div style="float:right; width: 32px;">[[File:Applications-development.png|link=]]</div><br />
<h3>Desenvolvimento do Multi Theft Auto</h3><br />
[[File:Go-down.png|link=http://nightly.mtasa.com/]] [http://nightly.mtasa.com/ Últimas compilações]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Compilando_o_MTASA|Compilando o MTASA no Windows]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Compilando_o_MTASA_no_Mac_OS_X|Compilando o MTASA no Mac OS X]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Compilando_o_MTASA_no_Linux|Compilando o MTASA no Linux]]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Guia_do_Desenvolvedor|Guia do Desenvolvedor]]<br />
* [[File:iUS.png|Em Inglês|20px]] [https://github.com/multitheftauto/mtasa-blue Repositório Github]<br />
* [[Image:iBR.png|Em Português|20px]] [[PT-BR/Roadmap|Roteiro para versões futuras]]<br />
* [[File:iUS.png|Em Inglês|20px]] [http://bugs.mtasa.com/ Central de bugs]<br />
* [[File:iUS.png|En Inglês|20px]] [[Branches|Ramos]]<br />
</div><br />
<br />
<div style="border: 1px solid #D8D8D8; padding:4px 8px 8px 8px; margin:10px;"><br />
<div style="float:right; width: 32px;">[[File:Applications-office.png|link=]]</div><br />
<h3>Como você pode nos ajudar</h3><br />
* Documentar funções ou eventos<br />
* Criar exemplos funcionais e eficientes de funções e eventos<br />
* Examinar e corrigir as páginas<br />
* Escrever tutoriais para ajudar novatos<br />
* Ajudar a traduzir as páginas da Wiki para outras linguagens<br />
</div><br />
<br />
<div style="border: 1px solid #D8D8D8; padding:4px 8px 8px 8px; margin:10px;"><br />
<div style="float:right; width: 32px;">[[File:Internet-group-chat.png|link=]]</div><br />
<h3>Comunidade</h3><br />
* [[File:iUS.png|Em Inglês|20px]] [http://forum.multitheftauto.com/ Fóruns]<br />
* [[File:iUS.png|Em Inglês|20px]] [irc://irc.multitheftauto.com/mta IRC]<br />
* [[File:iUS.png|Em Inglês|20px]] [http://community.mtasa.com/ Comunidade]<br />
* [[File:iUS.png|Em Inglês|20px]] [http://twitter.com/#!/MTAQA/ Twitter] <br />
* [[File:iUS.png|Em Inglês|20px]] [http://www.youtube.com/user/MTAQA Youtube]<br />
* [[File:iUS.png|Em Inglês|20px]] [http://plus.google.com/102014133442331779727/ Google]<br />
* [[File:iUS.png|Em Inglês|20px]] [http://www.moddb.com/mods/multi-theft-auto-san-andreas ModDB]<br />
</div><br />
<br />
| width="50%" style="vertical-align:top;" |<br />
<br />
<div style="border: 1px solid #D8D8D8; padding:4px 8px 8px 8px; margin:10px;"><br />
<div style="float:right; width: 32px;">[[File:Accessories-text-editor.png|link=]]</div><br />
<h3>Scripting</h3><br />
* [[File:iBR.png|Em Português|20px]] [[PT-BR/Introdução_ao_Scripting|Introdução a ''scripting'']]<br />
* [[File:iBR.png|Em Português|20px]] [[PT-BR/Introducao_ao_GUI_scripting|Introdução a ''scripting'' de UI]]<br />
* [[File:iBR.png|Em Português|20px]] [[Depuração|Depuração]] - Encontre erros em seu Script<br />
* [[File:iBR.png|Em Português|20px]] [[PT-BR/Recursos|Introdução a recursos]]<br />
** [[File:iBR.png|Em Português|20px]] [[Acesso web via recursos|Acesso web via recursos]] - Abra servidores web através de recursos<br />
** [[File:iBR.png|Em Português|20px]] [[:Category:PT-BR/Recursos|Lista de recursos]]<br />
** [[File:iBR.png|Em Português|20px]] [[O arquivo Meta|Meta.xml]] - Todo recurso possui um arquivo meta descrevendo a si próprio<br />
** [[File:iBR.png|Em Português|20px]] [[Lista de Controle de Acesso|Lista de controle de acesso (ACL)]] - Componente vital para recursos complexos<br />
* [[File:iBR.png|Em Português|20px]] [[PT-BR/Composição_de_Gamemodes|Composição de modos de jogo]]<br />
<h3>Links dos fóruns</h3><br />
* [[File:iBR.png|Em Português|20px]] [http://forum.mtasa.com/viewforum.php?f=152 Secção do fórum para dúvidas sobre ''scripting'']<br />
* [[File:iUS.png|Em Inglês|20px]] [http://forum.mtasa.com/viewforum.php?f=148 Guias de ''scripting'']<br />
* [[File:iUS.png|Em Inglês|20px]] [http://forum.mtasa.com/viewtopic.php?f=13&t=29363 Wiki ''offline'']<br />
<div style="float:right; width: 32px;">[[File:start-here.png|link=]]</div><br />
<h3>Manuais sobre Lua</h3><br />
Página muito útil para ajuda-lo a entender o funcionamento do Lua<br />
* [[Image:iBR.png|Em Português|20px]] [http://www.lua.org/portugues.html Introdução à linguagem]<br />
* [[File:iUS.png|Em Inglês|20px]] [http://nixstaller.berlios.de/manual/0.2/nixstaller_9.html Manual básico]<br />
* [[Image:iBR.png|Em Português|20px]] [http://www.lua.org/manual/5.1/pt/ Manual de referência]<br />
* [[File:iUS.png|Em Inglês|20px]] [http://lua-users.org/wiki/TutorialDirectory Outra wiki, somente de Lua]<br />
</div><br />
<br />
<div style="border: 1px solid #D8D8D8; padding:4px 8px 8px 8px; margin:10px; background:#F2F2FF;"><br />
<div style="float:right; width: 32px;">[[File:Preferences-system.png|link=]]</div><br />
<h3>Referência</h3><br />
* [[File:iBR.png|Em Português|20px]] [[PT-BR/Funções_de_Scripting_do_Cliente|Funções de Scripting do Cliente]]<br />
* [[File:iUS.png|Em Inglês|20px]] [[Client Scripting Events|Eventos do cliente]]<br />
* [[File:iBR.png|Em Português|20px]] [[PT-BR/Funções_de_Scripting_do_Servidor|Funções de Scripting do Servidor]]<br />
* [[File:iBR.png|Em Português|20px]] [[PT-BR/Eventos_de_Scripting_do_Servidor|Eventos de Scripting do Servidor]]<br />
* [[File:iUS.png|Em Inglês|20px]] [[PT-BR/Funções_Úteis|Funções Úteis]]<br />
<!-- Incomplete * [[Module functions|Server-side external module scripting functions list]] --><br />
* [[File:iUS.png|Em Inglês|20px]] [[MTA Classes|Classes do Multi Theft Auto]] - Informações detalhadas sobre todas as classes do MTA<br />
** [[File:iUS.png|Em Inglês|20px]] [[Element tree|Árvore dos elementos]]<br />
</div><br />
<div style="border: 1px solid #D8D8D8; padding:4px 8px 8px 8px; margin:10px;"><br />
<div style="float:right; width: 32px;">[[File:System-file-manager.png|link=]]</div><br />
<h3>[[Id|Lista de IDs de objetos e texturas]]</h3><br />
*[[Animations|Animações]]<br />
*[[Character Skins|''Skins'' de pedestres]]<br />
*[[Roupas do CJ|Roupas do CJ]]<br />
*[[Garage|Garagens]]<br />
*[[Interior IDs|Interiores]]<br />
*[[Material IDs|Materiais]]<br />
*[[Projectiles|Projéteis]]<br />
*[[Radar Blips|''Blips'']]<br />
*[[Sounds|Efeitos sonoros]]<br />
*[[Vehicle IDs|Veículos]]<br />
*[[Vehicle Colors|Cores dos veículos]]<br />
*[[Vehicle Upgrades|Acessórios dos veículos]]<br />
*[[Vehicle variants|Variantes dos veículos]]<br />
*[[Weapons|Armas]]<br />
*[[Weather|Ambientação]]<br />
</div><br />
<br />
<div style="border: 1px dotted #D8D8D8; padding:4px 8px 8px 8px; margin:10px;"><br />
<div style="float:right; width: 32px;">[[File:pBR.png|32px]]</div><br />
<br />
<h3>Sobre a Tradução</h3><br />
* Tradutores:<br />
** [https://forum.mtasa.com/profile/19686-racextreme/|<span style="color: blue">RaceXtreme</span>]<br />
** [https://forum.mtasa.com/profile/27827-stanley-sathler/|<span style="color: blue">StanleySathler</span>]<br />
** [https://forum.mtasa.com/profile/24588-dnl291/|<span style="color: blue">DNL291</span>]<br />
** [https://forum.mtasa.com/profile/30695-ymassai/|<span style="color: blue">Ninguem</span>]<br />
** [https://forum.mtasa.com/profile/31772-anderl/|<span style="color:blue">Anderl</span>]<br />
** [https://forum.mtasa.com/profile/71215-kronos-lettify|<span style="color:blue">KronoS Lettify</span>]<br />
** [https://forum.mtasa.com/profile/69598-eficiencia/|<span style="color:blue">Eficiencia</span>]<br />
<br />
É importante que todos colaborem para que nossa página em português fique melhor a cada dia!<br />
<br />
[[File:Osi symbol.png|75px|link=http://opensource.org/]]<br />
'''Multi Theft Auto''' é um projeto '''open source'''. <br><br />
</div><br />
|-<br />
| colspan="2" |<br />
|}<br />
{| width="100%" cellspacing="0" cellpadding="0"<br />
| colspan="2" |<br />
<div style="padding-left: 15px; padding-right: 15px;" class="plainlinks"><br />
[[File:MTALogo_8ball.png|left|85px|link=Archive]]<br />
<ul style="list-style: none; width: 200px; float: left;"><br />
<li>'''Sobre o Multi Theft Auto'''</li><br />
<li>[[Archive|Arquivos]]</li><br />
<li>[[Press Coverage|Eventos]]</li><br />
<li>[http://code.google.com/p/mtasa-blue/people/list Desenvolvedores]</li><br />
</ul><br />
<ul style="list-style: none; width: 200px; float: left;"><br />
<li>'''Multi Theft Auto 0.5'''</li><br />
<li>[[Archive#Multi_Theft_Auto_0.5|Baixe-o]]</li><br />
<li>[[MTA 0.5r2 Known Issues|Solução de problemas]]</li><br />
</ul><br />
<ul style="list-style: none; width: 200px; float: left;"><br />
<li>'''Status da Wiki'''</li><br />
<li>{{NUMBEROFARTICLES}} artigos</li><br />
<li>{{NUMBEROFPAGES}} páginas</li><br />
<li>{{NUMBEROFUSERS}} usuários registrados</li><br />
</ul><br />
</div><br />
|}<br />
<br />
__NOTOC__<br />
__NOEDITSECTION__<br />
{{Languages list|pt-br}}</div>Eficienciahttps://wiki.multitheftauto.com/index.php?title=SetElementData&diff=67200SetElementData2020-08-06T22:28:19Z<p>Eficiencia: </p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__ <br />
This function stores [[element data]] under a certain key, attached to an element. Element data set using this is then synced with all clients and the server. The data can contain server created elements, but you should avoid passing data that is not able to be synced such as xmlnodes, acls, aclgroups etc.<br />
<br />
As element data is synced to all clients, it can generate a lot of network traffic and be heavy on performance. Events are much more efficient for sending data from a client to the server only, or from the server to a specific client. <br/><br />
Usage of element data should be disencouraged where your goal can be achieved with events like above, and [[table|tables]] for storing and retrieving data.<br />
<br />
{{Tip|A simple and efficient way to make a variable known to the server and clients is to use setElementData on the [[root]] element.}}<br />
{{Note|See [[Script security]] for tips on preventing cheaters when using events and element data}}<br />
{{Note|For performance reasons, never use setElementData in events that fire often (like [[onClientRender]]) without further optimization or conditions. In fact, using element data in general can take such a toll on performance that not using it unless strictly neccesary (e.g use alternatives such as storing data in tables) is recommended.}}.<br />
<br />
<br />
{{New items|5.0157|1.5.7-9.20477|A subscription mode has been introduced for [[setElementData]] serverside. When setting data in subscription mode, only clients that are added through [[addElementDataSubscriber]] will receive the data, which is good for performance.<br />
Note this mode only works when setting element data serverside. Setting data clientside still sends the update to all clients if 'synchronize' is set to true.<br />
}}<br />
<br />
==Syntax== <br />
<br />
<syntaxhighlight lang="lua"><br />
bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] )<br />
</syntaxhighlight> <br />
{{OOP||[[element]]:setData||getElementData}}<br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The [[element]] you wish to attach the data to.<br />
*'''key:''' The key you wish to store the data under. (Maximum 31 characters.) <br />
*'''value:''' The value you wish to store. See [[element data]] for a list of acceptable datatypes.<br />
<br />
===Optional Arguments=== <br />
*'''synchronize:''' Determines whether or not the data will be synchronized with the clients(server-side variation) or server(client-side variation)<br />
<br />
===Returns===<br />
Returns ''true'' if the data was set succesfully, ''false'' otherwise.<br />
<br />
{{New items|5.0157|1.5.7-9.20477|<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setElementData ( element theElement, string key, var value [, var syncMode="broadcast"] )<br />
</syntaxhighlight> <br />
{{OOP||[[element]]:setData||getElementData}}<br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The [[element]] you wish to attach the data to.<br />
*'''key:''' The key you wish to store the data under. (Maximum 31 characters.) <br />
*'''value:''' The value you wish to store. See [[element data]] for a list of acceptable datatypes.<br />
<br />
===Optional Arguments=== <br />
*'''syncMode:''' Synchronisation mode.<br />
**''"broadcast"'' - Synchronise to all clients (default behavior). You can also parse ''true'' for this option.<br />
**''"local"'' - Don't synchronise. You can also parse ''false'' for this option.<br />
**''"subscribe"'' - Only synchronise to specific clients. See [[addElementDataSubscriber]] and [[removeElementDataSubscriber]].<br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] )<br />
</syntaxhighlight> <br />
{{OOP||[[element]]:setData||getElementData}}<br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The [[element]] you wish to attach the data to.<br />
*'''key:''' The key you wish to store the data under. (Maximum 31 characters.) <br />
*'''value:''' The value you wish to store. See [[element data]] for a list of acceptable datatypes.<br />
<br />
===Optional Arguments=== <br />
*'''synchronize:''' Determines whether or not the data will be synchronized with the server.<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the data was set succesfully, ''false'' otherwise.<br />
}}<br />
<br />
===Issues===<br />
{{Issues|<br />
{{Issue|7389|[Fixed in 1.3.5-7389] Problem with floating numbers}}<br />
}}<br />
<br />
==Example== <br />
<section name="Server" class="server" show="false"><br />
This example allows a player to add a custom tag onto their nickname, and also reverts it back to normal if they wish.<br />
<syntaxhighlight lang="lua"><br />
function addPlayerCustomTag ( thePlayer, command, newTag )<br />
--Let's make sure the newTag param has been entered...<br />
if ( newTag ) then<br />
--Grab their current playername for saving.<br />
local sPlayerNickname = getPlayerName ( thePlayer )<br />
--Create their new nickname with their tag<br />
local sNewPlayerNickname = newTag .. " " .. sPlayerNickname<br />
<br />
--Let's first load the element data, see if it's there already<br />
--The reason for this is that if a player were to do /addtag twice,<br />
--the tag would be prepended a second time<br />
local sOldNick = getElementData( thePlayer, "tempdata.originalnick" )<br />
if ( sOldNick == false ) then<br />
--Save their orignal nickname in their element data<br />
setElementData ( thePlayer, "tempdata.originalnick", sPlayerNickname )<br />
end<br />
<br />
--Set their new nickname globally<br />
setPlayerName ( thePlayer, sNewPlayerNickname )<br />
<br />
--Tell them it's done<br />
outputChatBox ( "Your new nickname has been set, to put it back to its original state you can use /deltag", thePlayer )<br />
else<br />
--The newTag param was not entered, give an error message<br />
outputChatBox ( "/addtag - Incorrect syntax, Correct: /addtag <newtag>", thePlayer )<br />
end<br />
end<br />
addCommandHandler ( "addtag", addPlayerCustomTag )<br />
<br />
function removePlayerCustomTag ( thePlayer, command )<br />
--We first need to check that they have already used /addtag, let's do that now<br />
local sOldNick = getElementData( thePlayer, "tempdata.originalnick" )<br />
if ( sOldNick ) then<br />
--Great, they have a tag added, let's reset them<br />
<br />
--First we will want to reset the element data back to its default (that being false)<br />
setElementData ( thePlayer, "tempdata.originalnick", false )<br />
<br />
--Now set the client name back<br />
setPlayerName( thePlayer, sOldNick )<br />
<br />
--Notify them<br />
outputChatBox ( "Your old nickname has been set", thePlayer )<br />
end<br />
end<br />
addCommandHandler ( "deltag", removePlayerCustomTag )<br />
</syntaxhighlight><br />
</section><br />
[[tr:setElementData]]<br />
<br />
==See Also==<br />
[[pt-br:SetElementData]]<br />
{{Element_functions}}</div>Eficienciahttps://wiki.multitheftauto.com/index.php?title=SetElementData&diff=67199SetElementData2020-08-06T22:28:08Z<p>Eficiencia: </p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__ <br />
This function stores [[element data]] under a certain key, attached to an element. Element data set using this is then synced with all clients and the server. The data can contain server created elements, but you should avoid passing data that is not able to be synced such as xmlnodes, acls, aclgroups etc.<br />
<br />
As element data is synced to all clients, it can generate a lot of network traffic and be heavy on performance. Events are much more efficient for sending data from a client to the server only, or from the server to a specific client. <br/><br />
Usage of element data should be disencouraged where your goal can be achieved with events like above, and [[table|tables]] for storing and retrieving data.<br />
<br />
{{Tip|A simple and efficient way to make a variable known to the server and clients is to use setElementData on the [[root]] element.}}<br />
{{Note|See [[Script security]] for tips on preventing cheaters when using events and element data}}<br />
{{Note|For performance reasons, never use setElementData in events that fire often (like [[onClientRender]]) without further optimization or conditions. In fact, using element data in general can take such a toll on performance that not using it unless strictly neccesary (e.g use alternatives such as storing data in tables) is recommended.}}.<br />
<br />
<br />
{{New items|5.0157|1.5.7-9.20477|A subscription mode has been introduced for [[setElementData]] serverside. When setting data in subscription mode, only clients that are added through [[addElementDataSubscriber]] will receive the data, which is good for performance.<br />
Note this mode only works when setting element data serverside. Setting data clientside still sends the update to all clients if 'synchronize' is set to true.<br />
}}<br />
<br />
==Syntax== <br />
<br />
<syntaxhighlight lang="lua"><br />
bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] )<br />
</syntaxhighlight> <br />
{{OOP||[[element]]:setData||getElementData}}<br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The [[element]] you wish to attach the data to.<br />
*'''key:''' The key you wish to store the data under. (Maximum 31 characters.) <br />
*'''value:''' The value you wish to store. See [[element data]] for a list of acceptable datatypes.<br />
<br />
===Optional Arguments=== <br />
*'''synchronize:''' Determines whether or not the data will be synchronized with the clients(server-side variation) or server(client-side variation)<br />
<br />
===Returns===<br />
Returns ''true'' if the data was set succesfully, ''false'' otherwise.<br />
<br />
{{New items|5.0157|1.5.7-9.20477|<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setElementData ( element theElement, string key, var value [, var syncMode="broadcast"] )<br />
</syntaxhighlight> <br />
{{OOP||[[element]]:setData||getElementData}}<br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The [[element]] you wish to attach the data to.<br />
*'''key:''' The key you wish to store the data under. (Maximum 31 characters.) <br />
*'''value:''' The value you wish to store. See [[element data]] for a list of acceptable datatypes.<br />
<br />
===Optional Arguments=== <br />
*'''syncMode:''' Synchronisation mode.<br />
**''"broadcast"'' - Synchronise to all clients (default behavior). You can also parse ''true'' for this option.<br />
**''"local"'' - Don't synchronise. You can also parse ''false'' for this option.<br />
**''"subscribe"'' - Only synchronise to specific clients. See [[addElementDataSubscriber]] and [[removeElementDataSubscriber]].<br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] )<br />
</syntaxhighlight> <br />
{{OOP||[[element]]:setData||getElementData}}<br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The [[element]] you wish to attach the data to.<br />
*'''key:''' The key you wish to store the data under. (Maximum 31 characters.) <br />
*'''value:''' The value you wish to store. See [[element data]] for a list of acceptable datatypes.<br />
<br />
===Optional Arguments=== <br />
*'''synchronize:''' Determines whether or not the data will be synchronized with the server.<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the data was set succesfully, ''false'' otherwise.<br />
}}<br />
<br />
===Issues===<br />
{{Issues|<br />
{{Issue|7389|[Fixed in 1.3.5-7389] Problem with floating numbers}}<br />
}}<br />
<br />
==Example== <br />
<section name="Server" class="server" show="false"><br />
This example allows a player to add a custom tag onto their nickname, and also reverts it back to normal if they wish.<br />
<syntaxhighlight lang="lua"><br />
function addPlayerCustomTag ( thePlayer, command, newTag )<br />
--Let's make sure the newTag param has been entered...<br />
if ( newTag ) then<br />
--Grab their current playername for saving.<br />
local sPlayerNickname = getPlayerName ( thePlayer )<br />
--Create their new nickname with their tag<br />
local sNewPlayerNickname = newTag .. " " .. sPlayerNickname<br />
<br />
--Let's first load the element data, see if it's there already<br />
--The reason for this is that if a player were to do /addtag twice,<br />
--the tag would be prepended a second time<br />
local sOldNick = getElementData( thePlayer, "tempdata.originalnick" )<br />
if ( sOldNick == false ) then<br />
--Save their orignal nickname in their element data<br />
setElementData ( thePlayer, "tempdata.originalnick", sPlayerNickname )<br />
end<br />
<br />
--Set their new nickname globally<br />
setPlayerName ( thePlayer, sNewPlayerNickname )<br />
<br />
--Tell them it's done<br />
outputChatBox ( "Your new nickname has been set, to put it back to its original state you can use /deltag", thePlayer )<br />
else<br />
--The newTag param was not entered, give an error message<br />
outputChatBox ( "/addtag - Incorrect syntax, Correct: /addtag <newtag>", thePlayer )<br />
end<br />
end<br />
addCommandHandler ( "addtag", addPlayerCustomTag )<br />
<br />
function removePlayerCustomTag ( thePlayer, command )<br />
--We first need to check that they have already used /addtag, let's do that now<br />
local sOldNick = getElementData( thePlayer, "tempdata.originalnick" )<br />
if ( sOldNick ) then<br />
--Great, they have a tag added, let's reset them<br />
<br />
--First we will want to reset the element data back to its default (that being false)<br />
setElementData ( thePlayer, "tempdata.originalnick", false )<br />
<br />
--Now set the client name back<br />
setPlayerName( thePlayer, sOldNick )<br />
<br />
--Notify them<br />
outputChatBox ( "Your old nickname has been set", thePlayer )<br />
end<br />
end<br />
addCommandHandler ( "deltag", removePlayerCustomTag )<br />
</syntaxhighlight><br />
</section><br />
[[tr:setElementData]]<br />
<br />
==See Also==<br />
[[pt-br:SetElementData<br />
{{Element_functions}}</div>Eficienciahttps://wiki.multitheftauto.com/index.php?title=PT-BR/SetElementData&diff=67198PT-BR/SetElementData2020-08-06T22:27:22Z<p>Eficiencia: Created page with "{{BR/Funcao compartilhada}} __NOTOC__ Esta função armazena element data sob uma determinada chave anexada a um elemento. A element data é sincronizada com todos os..."</p>
<hr />
<div>{{BR/Funcao compartilhada}}<br />
__NOTOC__ <br />
Esta função armazena [[element data]] sob uma determinada chave anexada a um elemento. A [[element data]] é sincronizada com todos os jogadores e com servidor. Os dados podem conter elementos criados pelo servidor, mas evite transmitir qualquer dado que não possa ser sincronizado como xmlnodes, acls, aclgroups etc.<br />
<br />
Como os dados do elemento são sincronizados com todos os jogadores, eles podem gerar muito tráfego de rede e prejudicar o desempenho. Os eventos são muito mais eficientes para enviar dados de um jogador para o servidor ou do servidor para um jogador específico.<br/><br />
O uso de [[element data]] não é recomendado em casos onde sua meta pode ser alcançada com os eventos citados acima, variáveis ou [[table|tables]] para armazenar dados.<br />
<br />
{{Dica|Uma maneira simples e eficiente de tornar uma variável conhecida pelo servidor e pelos jogadores é usar setElementData no elemento [[root]].}}<br />
{{BR/Nota|Leia [[Script security]] para ver dicas de como evitar trapaceiros ao usar [[element data]] e eventos}}<br />
{{BR/Nota|Por motivos de desempenho nunca utilize setElementData em eventos que são acionados com frequência como [[onClientRender]]. O uso de [[element data]] em geral pode afetar o desempenho, por isso é recomendado que seja usado somente em casos de extrema necessidade (o uso de [[table|tables]] ou variáveis é recomendado para substituir o [[element data]]).}}<br />
<br />
<br />
{{New items|5.0157|1.5.7-9.20477|A subscription mode has been introduced for [[setElementData]] serverside. When setting data in subscription mode, only clients that are added through [[addElementDataSubscriber]] will receive the data, which is good for performance.<br />
Note this mode only works when setting element data serverside. Setting data clientside still sends the update to all clients if 'synchronize' is set to true.<br />
}}<br />
<br />
==Sintaxe== <br />
<br />
<syntaxhighlight lang="lua"><br />
bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] )<br />
</syntaxhighlight> <br />
{{PT-BR/POO||[[element]]:setData||getElementData}}<br />
<br />
===Argumentos necessários=== <br />
*'''theElement:''' o [[element]] que você deseja armazenar dados.<br />
*'''key:''' A chave que você deseja armazenar os dados. (Máximo de 31 caracteres.) <br />
*'''value:''' O valor que você deseja armazenar. Leia [[element data]] para saber quais são os tipos de dados aceitáveis.<br />
<br />
===Argumentos Opcionais=== <br />
*'''synchronize:''' Determina se os dados serão ou não sincronizados com os jogadores ou com o servidor.<br />
<br />
===Retorna===<br />
Retorna ''true'' se a element data foi armazenada com sucesso e ''false'' se não for armazenada.<br />
<br />
{{New items|5.0157|1.5.7-9.20477|<br />
==Sintaxe== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setElementData ( element theElement, string key, var value [, var syncMode="broadcast"] )<br />
</syntaxhighlight> <br />
{{PT-BR/POO||[[element]]:setData||getElementData}}<br />
<br />
===Argumentos necessários=== <br />
*'''theElement:''' o [[element]] que você deseja armazenar dados.<br />
*'''key:''' A chave que você deseja armazenar os dados. (Máximo de 31 caracteres.) <br />
*'''value:''' O valor que você deseja armazenar. Leia [[element data]] para saber quais são os tipos de dados aceitáveis.<br />
<br />
===Argumentos Opcionais=== <br />
*'''syncMode:''' Modo de sincronização.<br />
**''"broadcast"'' - Sincroniza com todos os jogadores.<br />
**''"local"'' - Não sincroniza os dados.<br />
**''"subscribe"'' - Sincroniza apenas com jogadores específicos. Leia [[addElementDataSubscriber]] e [[removeElementDataSubscriber]].<br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] )<br />
</syntaxhighlight> <br />
{{PT-BR/POO||[[element]]:setData||getElementData}}<br />
<br />
===Argumentos necessários=== <br />
*'''theElement:''' o [[element]] que você deseja armazenar dados.<br />
*'''key:''' A chave que você deseja armazenar os dados. (Máximo de 31 caracteres.) <br />
*'''value:''' O valor que você deseja armazenar. Leia [[element data]] para saber quais são os tipos de dados aceitáveis.<br />
<br />
===Argumentos Opcionais=== <br />
*'''synchronize:''' Determina se os dados serão ou não sincronizados com o servidor.<br />
</section><br />
<br />
===Retorna===<br />
Retorna ''true'' se a element data foi armazenada com sucesso e ''false'' se não for armazenada.<br />
}}<br />
<br />
===Problemas===<br />
{{Issues|<br />
{{Issue|7389|[Fixed in 1.3.5-7389] Problema com números decimais}}<br />
}}<br />
<br />
==Exemplos== <br />
<section name="Server" class="server" show="false"><br />
Este exemplo permite que um jogador adicione uma tag personalizada ao apelido e também a reverte ao normal, se desejar.<br />
<syntaxhighlight lang="lua"><br />
function addPlayerCustomTag ( thePlayer, command, newTag )<br />
--Let's make sure the newTag param has been entered...<br />
if ( newTag ) then<br />
--Grab their current playername for saving.<br />
local sPlayerNickname = getPlayerName ( thePlayer )<br />
--Create their new nickname with their tag<br />
local sNewPlayerNickname = newTag .. " " .. sPlayerNickname<br />
<br />
--Let's first load the element data, see if it's there already<br />
--The reason for this is that if a player were to do /addtag twice,<br />
--the tag would be prepended a second time<br />
local sOldNick = getElementData( thePlayer, "tempdata.originalnick" )<br />
if ( sOldNick == false ) then<br />
--Save their orignal nickname in their element data<br />
setElementData ( thePlayer, "tempdata.originalnick", sPlayerNickname )<br />
end<br />
<br />
--Set their new nickname globally<br />
setPlayerName ( thePlayer, sNewPlayerNickname )<br />
<br />
--Tell them it's done<br />
outputChatBox ( "Your new nickname has been set, to put it back to its original state you can use /deltag", thePlayer )<br />
else<br />
--The newTag param was not entered, give an error message<br />
outputChatBox ( "/addtag - Incorrect syntax, Correct: /addtag <newtag>", thePlayer )<br />
end<br />
end<br />
addCommandHandler ( "addtag", addPlayerCustomTag )<br />
<br />
function removePlayerCustomTag ( thePlayer, command )<br />
--We first need to check that they have already used /addtag, let's do that now<br />
local sOldNick = getElementData( thePlayer, "tempdata.originalnick" )<br />
if ( sOldNick ) then<br />
--Great, they have a tag added, let's reset them<br />
<br />
--First we will want to reset the element data back to its default (that being false)<br />
setElementData ( thePlayer, "tempdata.originalnick", false )<br />
<br />
--Now set the client name back<br />
setPlayerName( thePlayer, sOldNick )<br />
<br />
--Notify them<br />
outputChatBox ( "Your old nickname has been set", thePlayer )<br />
end<br />
end<br />
addCommandHandler ( "deltag", removePlayerCustomTag )<br />
</syntaxhighlight><br />
</section><br />
[[tr:setElementData]]<br />
<br />
==Veja também==<br />
[[en:setElementData]]<br />
{{Element_functions}}</div>Eficienciahttps://wiki.multitheftauto.com/index.php?title=PT-BR/GivePlayerMoney&diff=67175PT-BR/GivePlayerMoney2020-08-06T18:50:55Z<p>Eficiencia: </p>
<hr />
<div>__NOTOC__ <br />
{{BR/Funcao compartilhada}}<br />
Esta função adiciona dinheiro a quantia atual do [[player]]. Para definir o dinheiro do jogador utilize [[PT-BR/SetPlayerMoney]]<br><br />
{{BR/Nota|Usar essa função no lado cliente (não recomendável) não irá mudar o dinheiro do jogador no servidor.}}<br />
<br />
==Sintaxe== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">bool givePlayerMoney ( player thePlayer, int amount )</syntaxhighlight> <br />
{{PT-BR/POO||[[player]]:giveMoney|money}}<br />
===Argumentos necessários=== <br />
*'''thePlayer:''' O [[player]] que você deseja dar dinheiro.<br />
*'''amount:''' Valor que você deseja dar ao jogador (deve ser um número inteiro e positivo).<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua">bool givePlayerMoney ( int quantia )</syntaxhighlight> <br />
{{PT-BR/POO||[[Player]].giveMoney}}<br />
===Argumentos necessários=== <br />
*'''amount:''' Valor que você deseja dar ao jogador (deve ser um número inteiro e positivo).<br />
</section><br />
<br />
===Retorna===<br />
Retorna ''true'' se o dinheiro for adicionado ou ''false'' se os parâmetros passados são inválidos.<br />
<br />
==Exemplos== <br />
<section show="true" name="Exemplo 1 - Client e Server" class="server"><br />
Este exemplo dá ao jogador dinheiro ao digitar o comando "givecash".<br />
<syntaxhighlight lang="lua"><br />
function consoleGiveCash ( thePlayer, command, amount ) --when the givecash command is called<br />
givePlayerMoney ( thePlayer, amount ) --give the player money according to the amount<br />
end<br />
addCommandHandler ( "givecash", consoleGiveCash ) --add a handler function for the command "givecash"<br />
</syntaxhighlight><br />
</section><br />
<br />
<section show="true" name="Exemplo 2 - Server" class="server"><br />
Este exemplo dá a um jogador mil dólares, como recompensa por matar outro jogador.<br />
<syntaxhighlight lang="lua"><br />
function rewardOnWasted ( ammo, killer, killerweapon, bodypart )<br />
--if there is a killer, and that killer is not the same person as whoever died<br />
if ( killer ) and ( killer ~= source ) then <br />
givePlayerMoney ( killer, 1000 ) --reward the killer with 1000 cash.<br />
end<br />
end<br />
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) --attach the rewardOnWasted function to the relevant event.<br />
</syntaxhighlight><br />
</section><br />
<section show="true" name="Exemplo 3 - Server" class="server"><br />
Este exemplo dá ao jogador 30000 ao usar um PickUP.<br />
<syntaxhighlight lang="lua"><br />
local money = createPickup (1896.4000244141, -1950.9000244141, 13, 3, 1274, 10000 )<br />
function pickupUse ( player )<br />
givePlayerMoney ( player, 30000 )<br />
end<br />
addEventHandler ( "onPickupUse", money, pickupUse )</syntaxhighlight><br />
</section><br />
<br />
==Veja também==<br />
{{Player functions}}<br />
[[en:givePlayerMoney]]<br />
[[ru:GivePlayerMoney]]</div>Eficienciahttps://wiki.multitheftauto.com/index.php?title=PT-BR/GivePlayerMoney&diff=67174PT-BR/GivePlayerMoney2020-08-06T18:45:07Z<p>Eficiencia: </p>
<hr />
<div>__NOTOC__ <br />
{{BR/Funcao compartilhada}}<br />
Esta função adiciona dinheiro a quantia atual do [[player]]. Para definir o dinheiro do jogador utilize [[pt-br:SetPlayerMoney]]<br><br />
{{BR/Nota|Usar essa função no lado cliente (não recomendável) não irá mudar o dinheiro do jogador no servidor.}}<br />
<br />
==Sintaxe== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">bool givePlayerMoney ( player thePlayer, int amount )</syntaxhighlight> <br />
{{PT-BR/POO||[[player]]:giveMoney|money}}<br />
===Argumentos necessários=== <br />
*'''thePlayer:''' O [[player]] que você deseja dar dinheiro.<br />
*'''amount:''' Valor que você deseja dar ao jogador (deve ser um número inteiro e positivo).<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua">bool givePlayerMoney ( int quantia )</syntaxhighlight> <br />
{{PT-BR/POO||[[Player]].giveMoney}}<br />
===Argumentos necessários=== <br />
*'''amount:''' Valor que você deseja dar ao jogador (deve ser um número inteiro e positivo).<br />
</section><br />
<br />
===Retorna===<br />
Retorna ''true'' se o dinheiro for adicionado ou ''false'' se os parâmetros passados são inválidos.<br />
<br />
==Exemplos== <br />
<section show="true" name="Exemplo 1 - Client e Server" class="server"><br />
Este exemplo dá ao jogador dinheiro ao digitar o comando "givecash".<br />
<syntaxhighlight lang="lua"><br />
function consoleGiveCash ( thePlayer, command, amount ) --when the givecash command is called<br />
givePlayerMoney ( thePlayer, amount ) --give the player money according to the amount<br />
end<br />
addCommandHandler ( "givecash", consoleGiveCash ) --add a handler function for the command "givecash"<br />
</syntaxhighlight><br />
</section><br />
<br />
<section show="true" name="Exemplo 2 - Server" class="server"><br />
Este exemplo dá a um jogador mil dólares, como recompensa por matar outro jogador.<br />
<syntaxhighlight lang="lua"><br />
function rewardOnWasted ( ammo, killer, killerweapon, bodypart )<br />
--if there is a killer, and that killer is not the same person as whoever died<br />
if ( killer ) and ( killer ~= source ) then <br />
givePlayerMoney ( killer, 1000 ) --reward the killer with 1000 cash.<br />
end<br />
end<br />
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) --attach the rewardOnWasted function to the relevant event.<br />
</syntaxhighlight><br />
</section><br />
<section show="true" name="Exemplo 3 - Server" class="server"><br />
Este exemplo dá ao jogador 30000 ao usar um PickUP.<br />
<syntaxhighlight lang="lua"><br />
local money = createPickup (1896.4000244141, -1950.9000244141, 13, 3, 1274, 10000 )<br />
function pickupUse ( player )<br />
givePlayerMoney ( player, 30000 )<br />
end<br />
addEventHandler ( "onPickupUse", money, pickupUse )</syntaxhighlight><br />
</section><br />
<br />
==Veja também==<br />
{{Player functions}}<br />
[[en:givePlayerMoney]]<br />
[[ru:GivePlayerMoney]]</div>Eficienciahttps://wiki.multitheftauto.com/index.php?title=SetPlayerMoney&diff=67173SetPlayerMoney2020-08-06T18:44:59Z<p>Eficiencia: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
Sets a player's money to a certain value, regardless of current player money. It should be noted that setting negative values does not work and in fact gives the player large amounts of money.<br />
{{Note|Using this function client side (not recommended) will not change a players money server side.}}<br />
<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerMoney ( player thePlayer, int amount [, bool instant = false ] ) </syntaxhighlight> <br />
{{OOP||[[player]]:setMoney|money|getPlayerMoney}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' Which player to set the money of.<br />
*'''amount:''' A whole integer specifying the new amount of money the player will have.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
{{New items|3.0140|1.4|<br />
*'''instant:''' If set to ''true'' money will be set instantly without counting up/down like in singleplayer.}}<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerMoney ( int amount [, bool instant = false ] ) </syntaxhighlight> <br />
{{OOP||[[Player]].setMoney||getPlayerMoney}}<br />
===Required Arguments=== <br />
*'''amount:''' A whole integer specifying the new amount of money the local player will have.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
{{New items|3.0140|1.4|<br />
*'''instant:''' If set to ''true'' money will be set instantly without counting up/down like in singleplayer.}}<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the money was added, or ''false'' if invalid parameters were passed.<br />
<br />
==Example== <br />
'''Example 1:''' This example sets the player's money to the desired amount when he types "setcash" in console.<br />
<syntaxhighlight lang="lua"><br />
function setCash(thePlayer, command, amount) -- when the setcash function is called<br />
setPlayerMoney(thePlayer, tonumber(amount)) -- change player's money to the desired amount<br />
end<br />
addCommandHandler("setcash", setCash) -- add a command handler for setcash<br />
</syntaxhighlight><br />
'''Example 2:''' This sets all players the amount of 1337 money when "leet" is typed in console.<br />
<syntaxhighlight lang="lua"><br />
function leetmoney()<br />
setPlayerMoney(root, 1337)<br />
end<br />
addCommandHandler("leet", leetmoney)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}<br />
<br />
[[pt-br:SetPlayerMoney]]<br />
[[ru:setPlayerMoney]]</div>Eficienciahttps://wiki.multitheftauto.com/index.php?title=SetPlayerMoney&diff=67172SetPlayerMoney2020-08-06T18:42:34Z<p>Eficiencia: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
Sets a player's money to a certain value, regardless of current player money. It should be noted that setting negative values does not work and in fact gives the player large amounts of money.<br />
{{Note|Using this function client side (not recommended) will not change a players money server side.}}<br />
<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerMoney ( player thePlayer, int amount [, bool instant = false ] ) </syntaxhighlight> <br />
{{OOP||[[player]]:setMoney|money|getPlayerMoney}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' Which player to set the money of.<br />
*'''amount:''' A whole integer specifying the new amount of money the player will have.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
{{New items|3.0140|1.4|<br />
*'''instant:''' If set to ''true'' money will be set instantly without counting up/down like in singleplayer.}}<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerMoney ( int amount [, bool instant = false ] ) </syntaxhighlight> <br />
{{OOP||[[Player]].setMoney||getPlayerMoney}}<br />
===Required Arguments=== <br />
*'''amount:''' A whole integer specifying the new amount of money the local player will have.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
{{New items|3.0140|1.4|<br />
*'''instant:''' If set to ''true'' money will be set instantly without counting up/down like in singleplayer.}}<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the money was added, or ''false'' if invalid parameters were passed.<br />
<br />
==Example== <br />
'''Example 1:''' This example sets the player's money to the desired amount when he types "setcash" in console.<br />
<syntaxhighlight lang="lua"><br />
function setCash(thePlayer, command, amount) -- when the setcash function is called<br />
setPlayerMoney(thePlayer, tonumber(amount)) -- change player's money to the desired amount<br />
end<br />
addCommandHandler("setcash", setCash) -- add a command handler for setcash<br />
</syntaxhighlight><br />
'''Example 2:''' This sets all players the amount of 1337 money when "leet" is typed in console.<br />
<syntaxhighlight lang="lua"><br />
function leetmoney()<br />
setPlayerMoney(root, 1337)<br />
end<br />
addCommandHandler("leet", leetmoney)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}<br />
<br />
[[pt-br:setPlayerMoney]]<br />
[[ru:setPlayerMoney]]</div>Eficienciahttps://wiki.multitheftauto.com/index.php?title=PT-BR/SetPlayerMoney&diff=67171PT-BR/SetPlayerMoney2020-08-06T18:41:29Z<p>Eficiencia: Created page with "__NOTOC__ {{BR/Funcao compartilhada}} Define o dinheiro de um jogador para um determinado valor, independente do dinheiro atual do jogador. Se o valor definido for um valor ne..."</p>
<hr />
<div>__NOTOC__<br />
{{BR/Funcao compartilhada}}<br />
Define o dinheiro de um jogador para um determinado valor, independente do dinheiro atual do jogador. Se o valor definido for um valor negativo não funcionará e dará ao jogador grandes quantias de dinheiro.<br />
{{BR/Nota|Usar essa função no lado cliente (não recomendável) não irá mudar o dinheiro do jogador no servidor.}}<br />
<br />
==Sintaxe== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerMoney ( player thePlayer, int amount [, bool instant = false ] ) </syntaxhighlight> <br />
{{PT-BR/POO||[[player]]:setMoney|money|getPlayerMoney}}<br />
===Argumentos necessários=== <br />
*'''thePlayer:''' O jogador que você deseja definir o dinheiro.<br />
*'''amount:''' Valor que você deseja definir ao jogador (deve ser um número inteiro e positivo).<br />
<br />
===Argumentos opcionais===<br />
{{BR/ArgOpcional}}<br />
{{New items|3.0140|1.4|<br />
*'''instant:''' Se definido com ''true'', definirá o valor instantaneamente (sem a animação do dinheiro sendo adicionado na hud do GTA SA)}}<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerMoney ( int amount [, bool instant = false ] ) </syntaxhighlight> <br />
{{OOP||[[Player]].setMoney||getPlayerMoney}}<br />
===Argumentos necessários=== <br />
*'''amount:''' Valor que você deseja definir ao jogador (deve ser um número inteiro e positivo).<br />
<br />
===Argumentos opcionais===<br />
{{BR/ArgOpcional}}<br />
{{New items|3.0140|1.4|<br />
*'''instant:''' Se definido com ''true'', definirá o valor instantaneamente (sem a animação do dinheiro sendo adicionado na hud do GTA SA)}}<br />
</section><br />
<br />
===Retorna===<br />
Retorna ''true'' se o dinheiro foi definido com sucesso ou ''false'' se os parâmetros passados são inválidos.<br />
==Exemplos== <br />
'''Exemplo 1:''' Este exemplo define o dinheiro do jogador ao digitar o comando "setcash".<br />
<syntaxhighlight lang="lua"><br />
function setCash(thePlayer, command, amount) -- when the setcash function is called<br />
setPlayerMoney(thePlayer, tonumber(amount)) -- change player's money to the desired amount<br />
end<br />
addCommandHandler("setcash", setCash) -- add a command handler for setcash<br />
</syntaxhighlight><br />
'''Exemplo 2:''' Este exemplo define o dinheiro de todos os jogadores em 1337 quando o comando "leet" é digitado no console.<br />
<syntaxhighlight lang="lua"><br />
function leetmoney()<br />
setPlayerMoney(root, 1337)<br />
end<br />
addCommandHandler("leet", leetmoney)<br />
</syntaxhighlight><br />
<br />
==Veja também==<br />
{{Player functions}}<br />
<br />
[[en:setPlayerMoney]]<br />
[[ru:setPlayerMoney]]</div>Eficienciahttps://wiki.multitheftauto.com/index.php?title=PT-BR/GivePlayerMoney&diff=67161PT-BR/GivePlayerMoney2020-08-06T18:04:28Z<p>Eficiencia: Created page with "__NOTOC__ {{BR/Funcao compartilhada}} Esta função adiciona dinheiro a quantia atual do player. Para definir o dinheiro do jogador utilize setPlayerMoney<br> {{Note|..."</p>
<hr />
<div>__NOTOC__ <br />
{{BR/Funcao compartilhada}}<br />
Esta função adiciona dinheiro a quantia atual do [[player]]. Para definir o dinheiro do jogador utilize [[setPlayerMoney]]<br><br />
{{Note|Usar essa função no lado cliente (não recomendável) não irá mudar o dinheiro do jogador no servidor.}}<br />
<br />
==Sintaxe== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">bool givePlayerMoney ( player thePlayer, int amount )</syntaxhighlight> <br />
{{PT-BR/POO||[[player]]:giveMoney|money}}<br />
===Argumentos necessários=== <br />
*'''thePlayer:''' O [[player]] que você deseja dar dinheiro.<br />
*'''amount:''' Valor que você deseja dar ao jogador (deve ser um número inteiro e positivo).<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua">bool givePlayerMoney ( int quantia )</syntaxhighlight> <br />
{{PT-BR/POO||[[Player]].giveMoney}}<br />
===Argumentos necessários=== <br />
*'''amount:''' Valor que você deseja dar ao jogador (deve ser um número inteiro e positivo).<br />
</section><br />
<br />
===Retorna===<br />
Retorna ''true'' se o dinheiro for adicionado ou ''false'' se os parâmetro passados são inválidos.<br />
<br />
==Exemplos== <br />
<section show="true" name="Exemplo 1 - Client e Server" class="server"><br />
Este exemplo dá ao jogador dinheiro ao digitar o comando "givecash".<br />
<syntaxhighlight lang="lua"><br />
function consoleGiveCash ( thePlayer, command, amount ) --when the givecash command is called<br />
givePlayerMoney ( thePlayer, amount ) --give the player money according to the amount<br />
end<br />
addCommandHandler ( "givecash", consoleGiveCash ) --add a handler function for the command "givecash"<br />
</syntaxhighlight><br />
</section><br />
<br />
<section show="true" name="Exemplo 2 - Server" class="server"><br />
Este exemplo dá a um jogador mil dólares, como recompensa por matar outro jogador.<br />
<syntaxhighlight lang="lua"><br />
function rewardOnWasted ( ammo, killer, killerweapon, bodypart )<br />
--if there is a killer, and that killer is not the same person as whoever died<br />
if ( killer ) and ( killer ~= source ) then <br />
givePlayerMoney ( killer, 1000 ) --reward the killer with 1000 cash.<br />
end<br />
end<br />
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) --attach the rewardOnWasted function to the relevant event.<br />
</syntaxhighlight><br />
</section><br />
<section show="true" name="Exemplo 3 - Server" class="server"><br />
Este exemplo dá ao jogador 30000 ao usar um PickUP.<br />
<syntaxhighlight lang="lua"><br />
local money = createPickup (1896.4000244141, -1950.9000244141, 13, 3, 1274, 10000 )<br />
function pickupUse ( player )<br />
givePlayerMoney ( player, 30000 )<br />
end<br />
addEventHandler ( "onPickupUse", money, pickupUse )</syntaxhighlight><br />
</section><br />
<br />
==Veja também==<br />
{{Player functions}}<br />
[[pt-br:givePlayerMoney]]<br />
[[ru:GivePlayerMoney]]</div>Eficienciahttps://wiki.multitheftauto.com/index.php?title=User:Eficiencia&diff=67155User:Eficiencia2020-08-06T17:20:29Z<p>Eficiencia: Created page with "[https://forum.mtasa.com/profile/69598-eficiencia/|<span style="color: black">MTA forum profile</span>]"</p>
<hr />
<div>[https://forum.mtasa.com/profile/69598-eficiencia/|<span style="color: black">MTA forum profile</span>]</div>Eficiencia