<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/ES/callServerFunction?action=history&amp;feed=atom</id>
	<title>ES/callServerFunction - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/ES/callServerFunction?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ES/callServerFunction&amp;action=history"/>
	<updated>2026-05-03T13:27:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ES/callServerFunction&amp;diff=64161&amp;oldid=prev</id>
		<title>Qaisjp: prefer normal note</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ES/callServerFunction&amp;diff=64161&amp;oldid=prev"/>
		<updated>2019-09-07T08:40:34Z</updated>

		<summary type="html">&lt;p&gt;prefer normal note&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:40, 7 September 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Useful Function}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Useful Function}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;lowercasetitle/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;lowercasetitle/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;__NOTOC__&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;__NOTOC__ {{&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Note&lt;/ins&gt;|Se recomienda encerecidamente que valides la funcion que está siendo llamada o potencialmente un cliente puede hacer lo que quiera con tu servidor - banear jugadores, agregarse a sí mismo como admin (dependiende de que tan bien estén configuradas las ACL ) etc. Por esta razón es que esta función no viene incluida dentro de MTA.}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Note_box&lt;/del&gt;|Se recomienda encerecidamente que valides la funcion que está siendo llamada o potencialmente un cliente puede hacer lo que quiera con tu servidor - banear jugadores, agregarse a sí mismo como admin (dependiende de que tan bien estén configuradas las ACL ) etc. Por esta razón es que esta función no viene incluida dentro de MTA.}}&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Esta funcion te permite llamar cualquier funcion de servidor desde el lado del cliente. Obviamente solo aquellas que están disponibles del lado del servidor. No importa si es una funcion MTA, una funcion estándar Lua o una funcion creada.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Esta funcion te permite llamar cualquier funcion de servidor desde el lado del cliente. Obviamente solo aquellas que están disponibles del lado del servidor. No importa si es una funcion MTA, una funcion estándar Lua o una funcion creada.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki-wiki_dev_:diff::1.12:old-30921:rev-64161 --&gt;
&lt;/table&gt;</summary>
		<author><name>Qaisjp</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ES/callServerFunction&amp;diff=30921&amp;oldid=prev</id>
		<title>Kzman: Created page with &quot;{{Useful Function}} &lt;lowercasetitle/&gt; __NOTOC__ {{Note_box|Se recomienda encerecidamente que valides la funcion que está siendo llamada o potencialmente un cliente puede hacer l...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ES/callServerFunction&amp;diff=30921&amp;oldid=prev"/>
		<updated>2012-05-19T05:55:45Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Useful Function}} &amp;lt;lowercasetitle/&amp;gt; __NOTOC__ {{Note_box|Se recomienda encerecidamente que valides la funcion que está siendo llamada o potencialmente un cliente puede hacer l...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle/&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{Note_box|Se recomienda encerecidamente que valides la funcion que está siendo llamada o potencialmente un cliente puede hacer lo que quiera con tu servidor - banear jugadores, agregarse a sí mismo como admin (dependiende de que tan bien estén configuradas las ACL ) etc. Por esta razón es que esta función no viene incluida dentro de MTA.}}&lt;br /&gt;
Esta funcion te permite llamar cualquier funcion de servidor desde el lado del cliente. Obviamente solo aquellas que están disponibles del lado del servidor. No importa si es una funcion MTA, una funcion estándar Lua o una funcion creada.&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Los numeros se convierten automáticamente a string y vice versa en el servidor para evitar pérdida de datos. Si no necesitas esta caracterñistica, solo elimínala.&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Nota Importante:''' Ten presente que ¡el nombre de la función debe ser un '''string'''!&lt;br /&gt;
&lt;br /&gt;
==Sintaxis==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;void callServerFunction( string funcname, [ var arg1, ... ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Argumentos Requeridos===&lt;br /&gt;
* '''funcname''': El nombre de la funcion de servidor que será llamada. Tambien puede ser una funcion dentro de una tabla, p.ej. &amp;quot;math.round&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Argumentos Opcionales===&lt;br /&gt;
{{ArgOpcionales}}&lt;br /&gt;
* '''arg1-argn''': The arguments that should be passed to the function.&lt;br /&gt;
&lt;br /&gt;
==Código==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside Script&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function callServerFunction(funcname, ...)&lt;br /&gt;
    local arg = { ... }&lt;br /&gt;
    if (arg[1]) then&lt;br /&gt;
        for key, value in next, arg do&lt;br /&gt;
            if (type(value) == &amp;quot;number&amp;quot;) then arg[key] = tostring(value) end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    -- Si el controlador de eventos en el servidor no está dentro de mismo resource, reemplaza 'resourceRoot' con el elemento apropiado&lt;br /&gt;
    triggerServerEvent(&amp;quot;onClientCallsServerFunction&amp;quot;, resourceRoot , funcname, unpack(arg))&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Serverside Script&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function callServerFunction(funcname, ...)&lt;br /&gt;
    local arg = { ... }&lt;br /&gt;
    if (arg[1]) then&lt;br /&gt;
        for key, value in next, arg do arg[key] = tonumber(value) or value end&lt;br /&gt;
    end&lt;br /&gt;
    loadstring(&amp;quot;return &amp;quot;..funcname)()(unpack(arg))&lt;br /&gt;
end&lt;br /&gt;
addEvent(&amp;quot;onClientCallsServerFunction&amp;quot;, true)&lt;br /&gt;
addEventHandler(&amp;quot;onClientCallsServerFunction&amp;quot;, resourceRoot , callServerFunction)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Ejemplo==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Cliente&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
En este ejemplo se quitan a los jugaores de su equipo.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- obtiene el elemento de jugador local&lt;br /&gt;
local _local = getLocalPlayer()&lt;br /&gt;
-- define el la funcion del controlador de comandos&lt;br /&gt;
function cmdLeaveTeam()&lt;br /&gt;
    -- establece el equipo del jugador a nil&lt;br /&gt;
    callServerFunction(&amp;quot;setPlayerTeam&amp;quot;, _local)&lt;br /&gt;
end&lt;br /&gt;
-- y en controlador de eme&lt;br /&gt;
addCommandHandler(&amp;quot;leaveTeam&amp;quot;, cmdLeaveTeam, false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Vea También==&lt;br /&gt;
{{Funciones Útiles}}&lt;br /&gt;
[[en:callServerFunction]]&lt;/div&gt;</summary>
		<author><name>Kzman</name></author>
	</entry>
</feed>