<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Cecer1</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Cecer1"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Cecer1"/>
	<updated>2026-04-18T12:07:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AddCommandHandler&amp;diff=24188</id>
		<title>AddCommandHandler</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AddCommandHandler&amp;diff=24188"/>
		<updated>2010-08-07T14:46:00Z</updated>

		<summary type="html">&lt;p&gt;Cecer1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
{{Note_box|It is strongly advised that you do not use the same name for your handler function as the command name, as this can lead to confusion if multiple handler functions are used. Use a name that describes your handler's purpose more specifically.}}&lt;br /&gt;
This function will attach a scripting function (handler) to a console command, so that whenever a player or administrator uses the command the function is called.&lt;br /&gt;
&lt;br /&gt;
Multiple command handlers can be attached to a single command, and they will be called in the order that the handlers were attached. Equally, multiple commands can be handled by a single function, and the ''commandName'' parameter used to decide the course of action.&lt;br /&gt;
&lt;br /&gt;
For users, a command is in the format:&lt;br /&gt;
&lt;br /&gt;
''commandName'' ''argument1'' ''argument2''&lt;br /&gt;
&lt;br /&gt;
This can be triggered from the player's console or directly from the chat box by prefixing the message with a forward slash (''/''). For server side handlers, the server admin is also able to trigger these directly from the server's console in the same way as they are triggered from a player's console.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&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;
bool addCommandHandler ( string commandName, function handlerFunction, [bool restricted = false, bool caseSensitive = true] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''commandName:''' This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function.&lt;br /&gt;
*'''handlerFunction:''' This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional.&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''restricted:''' Specify whether or not this command should be restricted by default. Use this on commands that should be inaccessible to everyone as default except special users specified in the ACL (Access Control List). This is to make sure admin commands such as ie. 'punish' won't be available to everyone if a server administrator forgets masking it in ACL. This argument defaults to false if nothing is specified.&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&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;
bool addCommandHandler ( string commandName, function handlerFunction, [bool caseSensitive = true] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''commandName:''' This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function.&lt;br /&gt;
*'''handlerFunction:''' This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional.&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Handler function parameters====&lt;br /&gt;
These are the parameters for the handler function that is called when the command is used.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&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;player playerSource, string commandName, [string arg1, string arg2, ...] &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''playerSource:''' The player who triggered the command. If not triggered by a player (e.g. by admin), this will be ''false''.&lt;br /&gt;
* '''commandName:''' The name of the command triggered. This is useful if multiple commands go through one function.&lt;br /&gt;
* '''arg1, arg2, ...:''' Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain [[nil]]. You can deal with a variable number of arguments using the vararg expression, as shown in '''Example 4''' below.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&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; string commandName, [string arg1, string arg2, ...] &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''commandName:''' The name of the command triggered. This is useful if multiple commands go through one function.&lt;br /&gt;
* '''arg1, arg2, ...:''' Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain [[nil]]. You can deal with a variable number of arguments using the vararg expression, as shown in '''Example 4''' below.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the command handler was added successfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 1:''' This example defines a command handler for the command ''createmarker''. This will create a red marker at the position of the player player who uses it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle this command&lt;br /&gt;
function consoleCreateMarker ( playerSource )&lt;br /&gt;
	-- If a player triggered it (rather than the admin) then&lt;br /&gt;
	if ( playerSource ) then&lt;br /&gt;
		-- Get that player's position&lt;br /&gt;
		local x, y, z = getElementPosition ( playerSource )&lt;br /&gt;
		-- Create a size 2, red checkpoint marker at their position&lt;br /&gt;
		createMarker ( x, y, z, &amp;quot;checkpoint&amp;quot;, 2, 255, 0, 0, 255 )&lt;br /&gt;
		-- Output it in his chat box&lt;br /&gt;
		outputChatBox ( &amp;quot;You got a red marker&amp;quot;, playerSource )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- Attach the 'consoleCreateMarker' function to the &amp;quot;createmarker&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;createmarker&amp;quot;, consoleCreateMarker )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' A simple health setting command. If a player types ''/sethealth X'' in the chatbox his health will be set to X. Note that the function [[setElementHealth]] is used rather than something like &amp;quot;setPlayerHealth&amp;quot;. This function is more generic and can also be used to set the health of vehicles.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function consoleSetHealth(playerSource, commandName, health)&lt;br /&gt;
	setElementHealth(playerSource, tonumber(health))&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;sethealth&amp;quot;, consoleSetHealth)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 3:''' This example implements a ''set_vehicle_color'' command.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle this command&lt;br /&gt;
function consoleSetVehicleColor ( playerSource, commandName, col1, col2, col3, col4 )&lt;br /&gt;
	-- If a player triggered this in-game&lt;br /&gt;
	if ( playerSource ) then&lt;br /&gt;
		-- Get the player's vehicle&lt;br /&gt;
		local playerVehicle = getPedOccupiedVehicle ( playerSource )&lt;br /&gt;
		-- If the player is in a vehicle and we've got at least 1 parameter&lt;br /&gt;
		if ( playerVehicle and col1 ) then&lt;br /&gt;
			-- Get the vehicle's existing color and use it if fewer than 4 arguments were passed&lt;br /&gt;
			local exCol1, exCol2, exCol3, exCol4 = getVehicleColor ( playerVehicle )&lt;br /&gt;
&lt;br /&gt;
			if not col2 then col2 = exCol2 end&lt;br /&gt;
			if not col3 then col3 = exCol3 end&lt;br /&gt;
			if not col4 then col4 = exCol4 end&lt;br /&gt;
&lt;br /&gt;
			-- Set the vehicle's color&lt;br /&gt;
			setVehicleColor ( playerVehicle, col1, col2, col3, col4 )&lt;br /&gt;
		else&lt;br /&gt;
			-- If we didn't get at least 1 parameter or the player doesn't have a vehicle, display some help text&lt;br /&gt;
			outputConsole ( &amp;quot;This function will set your current vehicle's colors. A vehicle can have up to 4 colors.&amp;quot;, playerSource )&lt;br /&gt;
			outputConsole ( &amp;quot;Syntax: set_vehicle_color color1 [ color2 color3 color4 ]&amp;quot;, playerSource )&lt;br /&gt;
			outputConsole ( &amp;quot;You must be in a vehicle to use this function.&amp;quot;, playerSource )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- Attach the 'consoleSetVehicleColor' function to the &amp;quot;set_vehicle_color&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;set_vehicle_color&amp;quot;, consoleSetVehicleColor )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 4:''' This example makes use of Lua's vararg expression to implement a ''check_parameters'' command to count the number of parameters passed, merge them all into a single string and output it. This is also shows you how you can use table.concat to merge all the passed arguments. This is particularly useful when you want to read in a sentence of text passed from the user. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle this command (which can accept a variable number of arguments after commandName)&lt;br /&gt;
function consoleCheckParameters ( playerSource, commandName, ... )&lt;br /&gt;
	-- If a player, not an admin, triggered it,&lt;br /&gt;
	if playerSource then&lt;br /&gt;
		-- Pack all extra arguments passed in a table&lt;br /&gt;
		local parametersTable = {...}&lt;br /&gt;
		-- Get the number of arguments in that table&lt;br /&gt;
		local parameterCount = #parametersTable&lt;br /&gt;
		-- Output it to the player's chatbox&lt;br /&gt;
		outputChatBox ( &amp;quot;Number of parameters: &amp;quot; .. parameterCount, playerSource )&lt;br /&gt;
		-- Join them together in a single comma-separated string&lt;br /&gt;
		local stringWithAllParameters = table.concat( parametersTable, &amp;quot;, &amp;quot; )&lt;br /&gt;
		-- Output this parameter list to the player's chatbox&lt;br /&gt;
		outputChatBox ( &amp;quot;Parameters passed: &amp;quot; .. stringWithAllParameters, playerSource )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- Attach the 'consoleCheckParameters' function to the &amp;quot;check_parameters&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;check_parameters&amp;quot;, consoleCheckParameters )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 5:''' This example shows using a single function to handle multiple command handlers. This isn't advised for general usage, as it makes code harder to understand, but where multiple command handlers share some logic, it can be a useful way of reducing duplicated code. Generally, it would be preferable to put this shared logic in a separate function instead, as this gives you more control over the flow.&lt;br /&gt;
&amp;lt;!-- commands are case sensitive by default, in this example too --&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- make the function&lt;br /&gt;
function moneyCmd(player, cmd, amount)&lt;br /&gt;
    if getElementData(player, &amp;quot;canUseMoneyFunctions&amp;quot;) then -- the shared logic&lt;br /&gt;
        if cmd == &amp;quot;givemoney&amp;quot; then&lt;br /&gt;
            amount  = tonumber(amount)&lt;br /&gt;
            if amount then&lt;br /&gt;
                givePlayerMoney(player, amount)&lt;br /&gt;
            else&lt;br /&gt;
                outputChatBox(&amp;quot;[usage] /givemoney [amount]&amp;quot;, player)&lt;br /&gt;
            end&lt;br /&gt;
        else if cmd == &amp;quot;takemoney&amp;quot; then&lt;br /&gt;
            amount = tonumber(amount)&lt;br /&gt;
            if amount then&lt;br /&gt;
                takePlayerMoney(player, amount)&lt;br /&gt;
            else&lt;br /&gt;
                outputChatBox(&amp;quot;[usage] /takemoney [amount]&amp;quot;, player)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;You aren't able to use this command&amp;quot;, player)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
addCommandHandler(&amp;quot;givemoney&amp;quot;, moneyCmd);&lt;br /&gt;
addCommandHandler(&amp;quot;takemoney&amp;quot;, moneyCmd);&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;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 1:''' This creates a GUI window and allows a player to change its alpha (transparency) value with a command. Note that, in a clientside script, the player using the command is not passed as a parameter to the handler function, since it is always the local player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;--Create a window&lt;br /&gt;
myWindow = guiCreateWindow ( 0.30, 0.10, 0.5, 0.60, &amp;quot;GUI window title&amp;quot;, true )&lt;br /&gt;
&lt;br /&gt;
--Add a command handler to change the alpha of the GUI window. Usage example: 'alpha 0.15'&lt;br /&gt;
function changeAlpha ( commandName, alphaAmount )&lt;br /&gt;
	-- All command parameters are strings, so we'll convert the value to a number first&lt;br /&gt;
	alphaAmount = tonumber(alphaAmount)&lt;br /&gt;
	guiSetAlpha ( myWindow, alphaAmount )&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;alpha&amp;quot;, changeAlpha )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Server functions}}&lt;/div&gt;</summary>
		<author><name>Cecer1</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetCameraTarget&amp;diff=22786</id>
		<title>SetCameraTarget</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetCameraTarget&amp;diff=22786"/>
		<updated>2010-04-03T05:07:42Z</updated>

		<summary type="html">&lt;p&gt;Cecer1: Misleading information regarding peds. Added vehicles to the list for completeness.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function allows you to set a player's camera to follow other elements instead. Currently supported element types are:&lt;br /&gt;
*[[Player]]s&lt;br /&gt;
*&amp;lt;s&amp;gt;[[Ped]]s&amp;lt;/s&amp;gt; - '''Currently planned for V1.2 Doesn't work yet'''&lt;br /&gt;
*&amp;lt;s&amp;gt;[[Vehicle]]s&amp;lt;/s&amp;gt; - '''Currently planned for V1.2 Doesn't work yet'''&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&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;
bool setCameraTarget ( player thePlayer, [ element target ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePlayer:''' The player whose camera you wish to modify.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''target:''' The element that you want the camera to follow. If none is specified, the camera will target the player.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&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;
bool setCameraTarget ( element target )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''target:''' The element that you want the local camera to follow.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This is an example of how one could implement a spectator function. Using the left and right arrow keys you can view other players. Note that this code isn't complete as it doesn't take into account joining or quitting players.&lt;br /&gt;
&amp;lt;section class=&amp;quot;client&amp;quot; name=&amp;quot;Client script&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;
g_Players = getElementsByType(&amp;quot;player&amp;quot;)        -- get a list of all players in the server&lt;br /&gt;
for i,aPlayer in ipairs(g_Players) do          -- find out what index the local player has in the list&lt;br /&gt;
    if aPlayer == getLocalPlayer() then&lt;br /&gt;
        g_CurrentSpectated = i&lt;br /&gt;
        break&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function spectatePrevious()                    -- decrement the spectate index and spectate the corresponding player&lt;br /&gt;
     if g_CurrentSpectated == 1 then&lt;br /&gt;
         g_CurrentSpectated = #g_Players&lt;br /&gt;
     else&lt;br /&gt;
         g_CurrentSpectated = g_CurrentSpectated - 1&lt;br /&gt;
     end&lt;br /&gt;
    setCameraTarget(g_Players[g_CurrentSpectated])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function spectateNext()                        -- increment the spectate index and spectate the corresponding player&lt;br /&gt;
     if g_CurrentSpectated == #g_Players then&lt;br /&gt;
         g_CurrentSpectated = 1&lt;br /&gt;
     else&lt;br /&gt;
         g_CurrentSpectated = g_CurrentSpectated + 1&lt;br /&gt;
     end&lt;br /&gt;
    setCameraTarget(g_Players[g_CurrentSpectated])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Bind above functions to arrow keys&lt;br /&gt;
bindKey(&amp;quot;arrow_l&amp;quot;, &amp;quot;down&amp;quot;, spectatePrevious)&lt;br /&gt;
bindKey(&amp;quot;arrow_r&amp;quot;, &amp;quot;down&amp;quot;, spectateNext)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Camera functions}}&lt;/div&gt;</summary>
		<author><name>Cecer1</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Modules/MTA-MySQL/mysql_field_length&amp;diff=21975</id>
		<title>Modules/MTA-MySQL/mysql field length</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Modules/MTA-MySQL/mysql_field_length&amp;diff=21975"/>
		<updated>2009-11-24T19:11:07Z</updated>

		<summary type="html">&lt;p&gt;Cecer1: Fixed the link to mysql_num_fields()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{ModuleFunction|MTA-MySQL}}&lt;br /&gt;
Returns the length of a given field in the last retreived row. The offset of the field must be an integer between '''1''' and '''[[Modules/MTA-MySQL/mysql_num_fields|mysql_num_fields()]]'''&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int mysql_field_length ( MySQLResult result, int offset )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''result:''' A valid MySQL result&lt;br /&gt;
* '''offset:''' A valid offset&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
The given field data length.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
'''Example 1:'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local result = mysql_query(handler, &amp;quot;SELECT name FROM account WHERE id='1' LIMIT 1&amp;quot;) -- Execute the query&lt;br /&gt;
if (result) then&lt;br /&gt;
  local row = mysql_fetch_row(result)&lt;br /&gt;
  local length = mysql_field_length(result, 1)&lt;br /&gt;
  outputDebugString(&amp;quot;The length of &amp;quot; .. row[1] .. &amp;quot; is &amp;quot; .. length)&lt;br /&gt;
  mysql_free_result(result) -- Free the result&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Modules/MTA-MySQL/Result_functions}}&lt;/div&gt;</summary>
		<author><name>Cecer1</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Talk:SetVehicleGravityPoint&amp;diff=21932</id>
		<title>Talk:SetVehicleGravityPoint</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Talk:SetVehicleGravityPoint&amp;diff=21932"/>
		<updated>2009-11-14T14:01:24Z</updated>

		<summary type="html">&lt;p&gt;Cecer1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wouldn't setVehicleCenterOfGravity be a better name? Center-of-gravity (or center-of-mass) is the standard name for this position. [[User:EAi|eAi]] 00:25, 14 November 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
I am fine either way.&lt;br /&gt;
The function still does the same after all.&lt;/div&gt;</summary>
		<author><name>Cecer1</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetVehicleGravityPoint&amp;diff=21930</id>
		<title>SetVehicleGravityPoint</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetVehicleGravityPoint&amp;diff=21930"/>
		<updated>2009-11-13T19:25:57Z</updated>

		<summary type="html">&lt;p&gt;Cecer1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setVehicleGravityPoint( vehicle targetVehicle, float pointX, float pointY, float pointZ, float strength )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''targetVehicle''': The vehicle you want to set the gravity of.&lt;br /&gt;
* '''pointX''': The X position of the gravity point. &lt;br /&gt;
* '''pointY''': The Y position of the gravity point. &lt;br /&gt;
* '''pointZ''': The Z position of the gravity point. &lt;br /&gt;
* '''strength''': The strength of the gravity as a multiple of the global gravity.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&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 setVehicleGravityPoint( targetVehicle, pointX, pointY, pointZ, strength )&lt;br /&gt;
	if isElement( targetVehicle ) and getElementType( targetVehicle ) == &amp;quot;vehicle&amp;quot; then&lt;br /&gt;
		local vehicleX,vehicleY,vehicleZ = getElementPosition( targetVehicle )&lt;br /&gt;
		local vectorX = vehicleX-pointX&lt;br /&gt;
		local vectorY = vehicleY-pointY&lt;br /&gt;
		local vectorZ = vehicleZ-pointZ&lt;br /&gt;
		local length = ( vectorX^2 + vectorY^2 + vectorZ^2 )^0.5&lt;br /&gt;
		&lt;br /&gt;
		local propX = vectorX^2 / length^2&lt;br /&gt;
		local propY = vectorY^2 / length^2&lt;br /&gt;
		local propZ = vectorZ^2 / length^2&lt;br /&gt;
		&lt;br /&gt;
		local finalX = ( strength^2 * propX )^0.5&lt;br /&gt;
		local finalY = ( strength^2 * propY )^0.5&lt;br /&gt;
		local finalZ = ( strength^2 * propZ )^0.5&lt;br /&gt;
		&lt;br /&gt;
		if vectorX &amp;gt; 0 then finalX = finalX * -1 end&lt;br /&gt;
		if vectorY &amp;gt; 0 then finalY = finalY * -1 end&lt;br /&gt;
		if vectorZ &amp;gt; 0 then finalZ = finalZ * -1 end&lt;br /&gt;
		&lt;br /&gt;
		return setVehicleGravity( targetVehicle, finalX, finalY, finalZ )&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example makes a command that will make the player's current vehicle &amp;quot;fall&amp;quot; towards 0,0,50 with 5 times the global gravity.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function toFarm()&lt;br /&gt;
		setVehicleGravityPoint(getPedOccupiedVehicle(getLocalPlayer()), 0, 0, 50, 5) -- Make the vehicle &amp;quot;fall&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;tofarm&amp;quot;, toFarm, false) -- Create the tofarm command&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: Cecer1&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Cecer1</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&amp;diff=21929</id>
		<title>Template:Useful Functions</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&amp;diff=21929"/>
		<updated>2009-11-13T19:25:25Z</updated>

		<summary type="html">&lt;p&gt;Cecer1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[callClientFunction]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to call any clientside function from the server's side.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[callServerFunction]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to call any server-side function from the client's side.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[Check]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function checks if it's arguments are of the right types and calls the error-function if one isn't.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[doForAllElements]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function can be used to execute a specified function for all elements of a specified type.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[findRotation]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Takes two points and returns the direction from point A to point B.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[FormatDate]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Formats a date on the basis of a format string and returns it.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getPointFromDistanceRotation]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Finds a point based on a starting point, direction and distance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[GetTimestamp]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» With this function you can get the [http://en.wikipedia.org/wiki/Unix_time UNIX timestamp].&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[IfElse]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Returns one of two values based on a boolean expression.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[IsYearALeapYear]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Checks if the given year is a leap year.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[math.round]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Rounds a number whereas the number of decimals to keep and the method may be set.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[setTableProtected]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Protects a table and makes it read-only.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[setVehicleGravityPoint]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[string.explode]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function splits a string at a given separator pattern and returns a table with the pieces.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[table.copy]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function copies a whole table and all the tables in that table.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[table.map]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[table.size]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Finds the absolute size of a table.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[var_dump]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;»This function outputs information about one or more variables using outputConsole(). &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Useful Functions]]&lt;/div&gt;</summary>
		<author><name>Cecer1</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetVehicleGravityPoint&amp;diff=21928</id>
		<title>SetVehicleGravityPoint</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetVehicleGravityPoint&amp;diff=21928"/>
		<updated>2009-11-13T19:11:40Z</updated>

		<summary type="html">&lt;p&gt;Cecer1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setVehicleGravityPoint( vehicle targetVehicle, float pointX, float pointY, float pointZ, float strength )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''targetVehicle''': The vehicle you want to set the gravity of.&lt;br /&gt;
* '''pointX''': The X position of the gravity point. &lt;br /&gt;
* '''pointY''': The Y position of the gravity point. &lt;br /&gt;
* '''pointZ''': The Z position of the gravity point. &lt;br /&gt;
* '''strength''': The strength of the gravity as a multiple of the global gravity.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&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 setVehicleGravityPoint( targetVehicle, pointX, pointY, pointZ, strength )&lt;br /&gt;
	if isElement( targetVehicle ) and getElementType( targetVehicle ) == &amp;quot;vehicle&amp;quot; then&lt;br /&gt;
		local vehicleX,vehicleY,vehicleZ = getElementPosition( targetVehicle )&lt;br /&gt;
		local vectorX = vehicleX-pointX&lt;br /&gt;
		local vectorY = vehicleY-pointY&lt;br /&gt;
		local vectorZ = vehicleZ-pointZ&lt;br /&gt;
		local length = ( vectorX^2 + vectorY^2 + vectorZ^2 )^0.5&lt;br /&gt;
		&lt;br /&gt;
		local propX = vectorX^2 / length^2&lt;br /&gt;
		local propY = vectorY^2 / length^2&lt;br /&gt;
		local propZ = vectorZ^2 / length^2&lt;br /&gt;
		&lt;br /&gt;
		local finalX = ( strength^2 * propX )^0.5&lt;br /&gt;
		local finalY = ( strength^2 * propY )^0.5&lt;br /&gt;
		local finalZ = ( strength^2 * propZ )^0.5&lt;br /&gt;
		&lt;br /&gt;
		if vectorX &amp;gt; 0 then finalX = finalX * -1 end&lt;br /&gt;
		if vectorY &amp;gt; 0 then finalY = finalY * -1 end&lt;br /&gt;
		if vectorZ &amp;gt; 0 then finalZ = finalZ * -1 end&lt;br /&gt;
		&lt;br /&gt;
		return setVehicleGravity( targetVehicle, finalX, finalY, finalZ )&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example makes a command that will make the player's current vehicle &amp;quot;fall&amp;quot; towards 0,0,50 with 5 times the global gravity.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function toFarm()&lt;br /&gt;
		setVehicleGravityPoint(getPedOccupiedVehicle(getLocalPlayer()), 0, 0, 50, 5) -- Make the vehicle &amp;quot;fall&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;tofarm&amp;quot;, toFarm, false) -- Create the tofarm command&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: Cecer1&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Cecer1</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetVehicleGravityPoint&amp;diff=21927</id>
		<title>SetVehicleGravityPoint</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetVehicleGravityPoint&amp;diff=21927"/>
		<updated>2009-11-13T19:07:37Z</updated>

		<summary type="html">&lt;p&gt;Cecer1: Created page with '{{Useful Function}} __NOTOC__ This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified..  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;[lu…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified..&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setVehicleGravityPoint( vehicle targetVehicle, float pointX, float pointY, float pointZ, float strength )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''targetVehicle''': The vehicle you want to set the gravity of.&lt;br /&gt;
* '''pointX''': The X position of the gravity point. &lt;br /&gt;
* '''pointY''': The Y position of the gravity point. &lt;br /&gt;
* '''pointZ''': The Z position of the gravity point. &lt;br /&gt;
* '''strength''': The strength of the gravity as a multiple of the global gravity.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&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 setVehicleGravityPoint( targetVehicle, pointX, pointY, pointZ, strength )&lt;br /&gt;
	if isElement( targetVehicle ) and getElementType( targetVehicle ) == &amp;quot;vehicle&amp;quot; then&lt;br /&gt;
		local vehicleX,vehicleY,vehicleZ = getElementPosition( targetVehicle )&lt;br /&gt;
		local vectorX = vehicleX-pointX&lt;br /&gt;
		local vectorY = vehicleY-pointY&lt;br /&gt;
		local vectorZ = vehicleZ-pointZ&lt;br /&gt;
		local length = ( vectorX^2 + vectorY^2 + vectorZ^2 )^0.5&lt;br /&gt;
		&lt;br /&gt;
		local propX = vectorX^2 / length^2&lt;br /&gt;
		local propY = vectorY^2 / length^2&lt;br /&gt;
		local propZ = vectorZ^2 / length^2&lt;br /&gt;
		&lt;br /&gt;
		local finalX = ( strength^2 * propX )^0.5&lt;br /&gt;
		local finalY = ( strength^2 * propY )^0.5&lt;br /&gt;
		local finalZ = ( strength^2 * propZ )^0.5&lt;br /&gt;
		&lt;br /&gt;
		if vectorX &amp;gt; 0 then finalX = finalX * -1 end&lt;br /&gt;
		if vectorY &amp;gt; 0 then finalY = finalY * -1 end&lt;br /&gt;
		if vectorZ &amp;gt; 0 then finalZ = finalZ * -1 end&lt;br /&gt;
		&lt;br /&gt;
		return setVehicleGravity( targetVehicle, finalX, finalY, finalZ )&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example makes a command that will make the player's current vehicle &amp;quot;fall&amp;quot; towards 0,0,50 with 5 times the global gravity.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function toFarm()&lt;br /&gt;
		setVehicleGravityPoint(getPedOccupiedVehicle(getLocalPlayer()), 0, 0, 50, 5) -- Make the vehicle &amp;quot;fall&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;tofarm&amp;quot;, toFarm, false) -- Create the tofarm command&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: Cecer1&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Cecer1</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Call&amp;diff=18529</id>
		<title>Call</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Call&amp;diff=18529"/>
		<updated>2009-03-03T19:58:25Z</updated>

		<summary type="html">&lt;p&gt;Cecer1: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function is used to call a function from another resource (which must be running). &lt;br /&gt;
&lt;br /&gt;
The function which you wish to call '''must''' first be exported within the resource's meta.  For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;jbeta&amp;quot; type=&amp;quot;script&amp;quot; description=&amp;quot;Scoreboard resource&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;scoreboard_client.lua&amp;quot; type=&amp;quot;client&amp;quot;/&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;scoreboard_exports.lua&amp;quot; type=&amp;quot;server&amp;quot;/&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;script src=&amp;quot;scoreboard_http.lua&amp;quot; type=&amp;quot;server&amp;quot;/&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;export function=&amp;quot;getScoreboardColumns&amp;quot; http=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;export function=&amp;quot;getScoreboardRows&amp;quot; http=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;export function=&amp;quot;addScoreboardColumn&amp;quot; type=&amp;quot;server&amp;quot;/&amp;gt;&lt;br /&gt;
	&amp;lt;export function=&amp;quot;removeScoreboardColumn&amp;quot; type=&amp;quot;server&amp;quot;/&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;export function=&amp;quot;setPlayerScoreboardForced&amp;quot; type=&amp;quot;server&amp;quot;/&amp;gt;&lt;br /&gt;
	&amp;lt;export function=&amp;quot;setScoreboardForced&amp;quot; type=&amp;quot;client&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This enables other resources to call a function from this resource.&lt;br /&gt;
&lt;br /&gt;
You cannot call a server function from the client or vice versa. See [[triggerServerEvent]] and [[triggerClientEvent]] for possibilities to do that.&lt;br /&gt;
&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
There is an easier syntax replacing this function. For example, you can instead of:&amp;lt;br&amp;gt;&lt;br /&gt;
  call ( getResourceFromName ( &amp;quot;resource&amp;quot; ), &amp;quot;exportedFunction&amp;quot;, 1, &amp;quot;2&amp;quot;, &amp;quot;three&amp;quot; )&lt;br /&gt;
do much like a normal call:&amp;lt;br&amp;gt;&lt;br /&gt;
  exports.resource:exportedFunction ( 1, &amp;quot;2&amp;quot;, &amp;quot;three&amp;quot; )&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
var... call ( resource theResource, string theFunction, [ arguments... ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theResource:''' This is a resource pointer which refers to the resource you are calling a function from.&lt;br /&gt;
*'''theFunction:''' This is a string with the name of the function which you want to call.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''arguments:''' Any arguments you may want to pass to the function when it is called. Any number of arguments of can be specified, each being passed to the designated function.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns anything that the designated function has returned appropriately.  If the function does not exist, is not exported, or the call was not successful it will return ''nil''.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt; &lt;br /&gt;
This extract shows adding of a &amp;quot;kills&amp;quot; column to the scoreboard resource. This then sets the ''gameShowKills'' variable to true, telling the rest of the script to start outputting kills.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function showKills ( option )&lt;br /&gt;
	if option == false then&lt;br /&gt;
		-- Remove the &amp;quot;kills&amp;quot; column&lt;br /&gt;
		gameShowKills = false&lt;br /&gt;
		call(getResourceFromName(&amp;quot;scoreboard&amp;quot;), &amp;quot;removeScoreboardColumn&amp;quot;, &amp;quot;kills&amp;quot;)&lt;br /&gt;
	else&lt;br /&gt;
		-- Add the &amp;quot;kills&amp;quot; column&lt;br /&gt;
		gameShowKills = true&lt;br /&gt;
		call(getResourceFromName(&amp;quot;scoreboard&amp;quot;), &amp;quot;addScoreboardColumn&amp;quot;, &amp;quot;kills&amp;quot;)&lt;br /&gt;
		outputDebugString ( &amp;quot;Showing kills now...&amp;quot; )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Resource_functions}}&lt;/div&gt;</summary>
		<author><name>Cecer1</name></author>
	</entry>
</feed>