https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=Sebassje&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-28T14:34:12ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=CountPlayersInRange&diff=24376CountPlayersInRange2010-08-18T18:59:19Z<p>Sebassje: /* Code */</p>
<hr />
<div>{{Useful Function}}<br />
This function allows you to set '''moving''' element speed in kph or mph units.<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setElementSpeed (element theElement, [ int/string unit="kph", int speed=0 ])<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''theElement''': Element you want to set speed of<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
* '''unit''': Units in which speed should be set. This can be 1 or "mph" for mph, any other value for kph.<br />
* '''speed''': Speed in selected unit<br />
<br />
==Code==<br />
{{RequiredFunctions|getElementSpeed}}<br />
<section name="Function source" class="both" show="true"><br />
<syntaxhighlight lang="lua"><br />
function setElementSpeed(element, unit, speed) -- only work if element is moving!<br />
if (unit == nil) then unit = 0 end<br />
if (speed == nil) then speed = 0 end<br />
speed = tonumber(speed)<br />
local acSpeed = getElementSpeed(element, unit)<br />
if (acSpeed~=false) then -- if true - element is valid, no need to check again<br />
local diff = speed/acSpeed<br />
local x,y,z = getElementVelocity(element)<br />
setElementVelocity(element,x*diff,y*diff,z*diff)<br />
return true<br />
end<br />
<br />
return false<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Server-side example" class="server" show="true"><br />
This example adds command that set player vehicle speed to provided one (in predefined unit kph). Note: It doesn't care if player is driver or passenger.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler("setmyspeed",<br />
function (player, cmd, arg1)<br />
local veh = getPedOccupiedVehicle(player)<br />
if (veh) then<br />
setElementSpeed(veh, "kph", tonumber(arg1))<br />
else<br />
outputChatBox("You have to sit in vehicle", player)<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
By '''varez'''.<br />
<br />
==See Also==<br />
{{Useful_Functions}}<br />
<nowiki>Insert non-formatted text here</nowiki></div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GuiSetInputEnabled&diff=24361GuiSetInputEnabled2010-08-15T08:17:56Z<p>Sebassje: Undo revision 24360 by Cilyotri (Talk)</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function enables or disables input focus for the GUI. This means that any keybinds or MTA binds are overidden so that text can be input into an editbox, for example. In other words, keys such as ''t'' and ''y'' which activate the chatbox are disabled.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool guiSetInputEnabled ( bool enabled )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments===<br />
* '''enabled:''' true if input should go to GUI, false if it should go to the game.<br />
<br />
===Returns===<br />
Returns ''true'' if input mode could be changed, ''false'' if invalid parameters are passed.<br />
<br />
==Example== <br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
--This line does...<br />
blabhalbalhb --abababa<br />
--This line does this...<br />
mooo<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{GUI_functions}}<br />
[[Category:Needs Example]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=Call&diff=24359Call2010-08-14T16:23:33Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function is used to call a function from another resource (which must be running). <br />
<br />
The function which you wish to call '''must''' first be exported within the resource's meta. For example:<br />
<syntaxhighlight lang="xml"><meta><br />
<info author="jbeta" type="script" description="Scoreboard resource" /><br />
<script src="scoreboard_client.lua" type="client"/><br />
<script src="scoreboard_exports.lua" type="server"/><br />
<br />
<script src="scoreboard_http.lua" type="server"/><br />
<br />
<export function="getScoreboardColumns" http="true" /><br />
<export function="getScoreboardRows" http="true" /><br />
<br />
<export function="addScoreboardColumn" type="server"/><br />
<export function="removeScoreboardColumn" type="server"/><br />
<br />
<export function="setPlayerScoreboardForced" type="server"/><br />
<export function="setScoreboardForced" type="client"/><br />
</meta></syntaxhighlight><br />
This enables other resources to call a function from this resource.<br />
<br />
You cannot call a server function from the client or vice versa. See [[triggerServerEvent]] and [[triggerClientEvent]] for possibilities to do that.<br />
<br />
{{New feature|3|1.0|<br />
There is an easier syntax replacing this function. For example, you can instead of:<br><br />
call ( getResourceFromName ( "resource" ), "exportedFunction", 1, "2", "three" )<br />
do much like a normal call:<br><br />
exports.resource:exportedFunction ( 1, "2", "three" )<br />
If the resource name contains illegal characters (such as hyphens), you can also do:<br><br />
exports["resource-name"]:exportedFunction ( 1, "2", "three" )<br />
<br />
When using the [[call]] function, two extra "hidden" variables are passed to the exported function:<br />
* '''sourceResource''' - The resource that called the exported function<br />
* '''sourceResourceRoot''' - The resource root element of the resource which called the exported function.<br />
}}<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
var... call ( resource theResource, string theFunction, [ arguments... ] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''theResource:''' This is a resource pointer which refers to the resource you are calling a function from.<br />
*'''theFunction:''' This is a string with the name of the function which you want to call.<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''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.<br />
<br />
===Returns===<br />
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''.<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"> <br />
This extract shows adding of a "kills" column to the scoreboard resource. This then sets the ''gameShowKills'' variable to true, telling the rest of the script to start outputting kills.<br />
<br />
<syntaxhighlight lang="lua"><br />
function showKills ( option )<br />
if option == false then<br />
-- Remove the "kills" column<br />
gameShowKills = false<br />
call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "kills")<br />
else<br />
-- Add the "kills" column<br />
gameShowKills = true<br />
call(getResourceFromName("scoreboard"), "addScoreboardColumn", "kills")<br />
outputDebugString ( "Showing kills now..." )<br />
end<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Resource_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=ResetTimer&diff=24354ResetTimer2010-08-12T18:40:07Z<p>Sebassje: /* Yes. */</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__<br />
This function allows you to reset the elapsed time in existing timers to zero. The function does not reset the 'times to execute' count on timers which have a limited amout of repetitions.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool resetTimer ( timer theTimer )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''theTimer:''' The [[timer]] whose elapsed time you wish to reset.<br />
<br />
===Returns===<br />
Returns ''true'' if the timer was successfully reset, ''false'' otherwise.<br />
<br />
==Example== <br />
<syntaxhighlight lang="lua"><br />
--TODO<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Utility functions}}<br />
[[Category:Needs_Example]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=SetTime&diff=24348SetTime2010-08-12T12:55:00Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function sets the current GTA time to the given time.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setTime ( int hour, int minute )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''hour''': The hour of the new time (range 0-23).<br />
*'''minute''': The minute of the new time (range 0-59).<br />
<br />
==Returns==<br />
Returns ''true'' if the new time was successfully set, ''false'' otherwise.<br />
<br />
==Example==<br />
This serverside function sets the time and notifies players.<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
function setTimeAndNotify( hour, minute )<br />
-- set the time first<br />
setTime ( hour, minute )<br />
-- format a notification message, adding leading zeros (e.g. 12:03 instead of 12:3)<br />
local notifyMessage = string.format("Time changed to %02d:%02d!", hour, minute)<br />
-- output the message<br />
outputChatBox ( notifyMessage )<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{World functions}}<br />
<br />
[[ru:setTime]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=Optional_Arguments&diff=24340Optional Arguments2010-08-11T18:47:27Z<p>Sebassje: </p>
<hr />
<div>[[Optional Arguments]] are arguments that are passed to a function but are not required for the function to run. Often, if you do not specify them, default values will be used instead.<br />
<br />
When looking at the Syntax for an argument, Optional arguments are always enclosed in Square brackets.<br />
<br />
Example:<br />
<br />
<syntaxhighlight lang="lua">theVehicle = createVehicle ( int model, float x, float y, float z, [ float rx, float ry, float rz ] )</syntaxhighlight><br />
<br />
In this example, '''rx''', '''ry''', and '''rz''' are [[Optional Arguments]].<br />
<br />
==Using Optional Arguments==<br />
<br />
[[Optional Arguments]] have one limitation. You cannot use any optional arguments unless ''all previous arguments are also supplied.''<br />
<br />
This means that in the previous example, if you wanted to supply '''rz''', you would also need to supply '''rx''', and '''ry''' ''in order.''<br />
<br />
[[pl:Argumenty opcjonalne]]<br />
[[Category:Scripting Concepts]]<br />
[[ru:Optional Arguments]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=ResetSkyGradient&diff=24339ResetSkyGradient2010-08-11T18:44:56Z<p>Sebassje: /* Example */</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function allows restoring of a changed sky gradient as a result of [[setSkyGradient]].<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool resetSkyGradient()<br />
</syntaxhighlight><br />
<br />
===Returns===<br />
Returns ''true'' if sky color was reset correctly, ''false'' otherwise.<br />
<br />
==Example==<br />
This example reset the sky gradient.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler("resetsky",<br />
function()<br />
resetSkyGradient()<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{World functions}}<br />
<br />
[[ru:ResetSkyGradient]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=RemovePlayerFromTeam&diff=24338RemovePlayerFromTeam2010-08-10T20:21:38Z<p>Sebassje: </p>
<hr />
<div>{{Server function}}<br />
__NOTOC__<br />
{{Deprecated}}<br />
This function is for removing a player from his current team.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool removePlayerFromTeam ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''thePlayer:''' The player you wish to remove from his team.<br />
<br />
===Returns===<br />
Returns ''true'' if the player was on a team and was successfully removed it, ''false'' otherwise.<br />
<br />
==Example==<br />
This example adds two new commands in console. One to create a new team for a player, and another to remove the player from that team<br />
<syntaxhighlight lang="lua"><br />
function gimmeATeam ( source, key, teamName )<br />
local newTeam = createTeam ( teamName ) -- create a new team with the specified name<br />
if ( newTeam ) then -- if it was successfully created<br />
setPlayerTeam ( source, newTeam ) -- add the player to the new team<br />
end<br />
end<br />
addCommandHandler ( "gimmeateam", gimmeATeam )<br />
<br />
function removeMyTeam ( source, key, teamName )<br />
local myTeam = getPlayerTeam ( source )--get his team<br />
if ( myTeam ) then --if he does have a team<br />
setPlayerTeam ( source, nil ) -- remove him from the team<br />
destroyElement ( myTeam ) --destroy his team<br />
end<br />
end<br />
addCommandHandler ( "removemyteam", removeMyTeam )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Team_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GetPlayerSerial&diff=24329GetPlayerSerial2010-08-10T10:38:48Z<p>Sebassje: /* Example 2 */</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function returns the [[serial]] for a specified [[player]].<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
string getPlayerSerial ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''thePlayer:''' A [[player]] object referencing the specified player.<br />
<br />
==Returns==<br />
Returns the serial as a ''string'' if it was found, ''false'' otherwise.<br />
<br />
{{New feature|3|1.0|<br />
The format of the serial has been changed.<br />
}}<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This example creates a command with which player can check their own serial.<br />
<syntaxhighlight lang="lua"><br />
function checkMySerial( thePlayer, command )<br />
local theSerial = getPlayerSerial( thePlayer )<br />
if theSerial then<br />
outputChatBox( "Your serial is: " .. theSerial, thePlayer )<br />
else<br />
outputChatBox( "Sorry, you have no serial. =(", thePlayer )<br />
end<br />
end<br />
addCommandHandler( "serial", checkMySerial )<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example 2==<br />
<section name="Server" class="server" show="true"><br />
This example add command to ban player serial.<br />
<syntaxhighlight lang="lua"><br />
function banSerial( source, command, noob, reason )<br />
if ( noob ) then<br />
local theNoob = getPlayerFromName( noob )<br />
local theNoobSerial = getPlayerSerial( theNoob )<br />
if ( theNoob ) then<br />
addBan( theNoobSerial, source, reason )<br />
end<br />
end<br />
end<br />
addCommandHandler( "banserial", banSerial )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Serial functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=EngineLoadTXD&diff=24328EngineLoadTXD2010-08-10T10:36:42Z<p>Sebassje: Undo revision 24317 by The Ex (Talk)</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function loads a RenderWare Texture Dictionary (TXD) file into GTA. The texture dictionary can then be used to provide textures.<br />
<br />
This is a client side function. Be sure to transfer your TXD file by including it in the meta file.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
txd engineLoadTXD ( string txd_file [, bool filteringEnabled = true ] ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''txd_file:''' The [[filepath]] to the txd file you want to load<br />
<br />
===Optional Arguments===<br />
*'''filteringEnabled:''' Texture filtering<br />
<br />
===Returns===<br />
Returns a [[TXD]] if the file was loaded, ''false'' otherwise.<br />
<br />
==Example== <br />
'''Example 1:''' This example loads a combination of a custom DFF and TXD file to replace the Euros vehicle in-game. The collisions are embedded inside the DFF file.<br />
<syntaxhighlight lang="lua"><br />
outputChatBox ( "> replacing the euros vehicle" )<br />
<br />
txd = engineLoadTXD ( "data/euros.txd" )<br />
engineImportTXD ( txd, 587 )<br />
dff = engineLoadDFF ( "data/euros.dff", 587 )<br />
engineReplaceModel ( dff, 587 )<br />
</syntaxhighlight><br />
<br />
<br />
'''Example 2:''' This example loads a combination of custom DFF, TXD and COL files to replace an in-game model of a set of floors.<br />
<syntaxhighlight lang="lua"><br />
outputChatBox ( "> loading floor objects" )<br />
txd_floors = engineLoadTXD ( "models/office_floors.txd" )<br />
engineImportTXD ( txd_floors, 3781 )<br />
col_floors = engineLoadCOL ( "models/office_floors.col" )<br />
dff_floors = engineLoadDFF ( "models/office_floors.dff", 0 )<br />
engineReplaceCOL ( col_floors, 3781 )<br />
engineReplaceModel ( dff_floors, 3781 )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Engine_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=Modules/Sockets/sockOpen&diff=24299Modules/Sockets/sockOpen2010-08-09T17:07:09Z<p>Sebassje: </p>
<hr />
<div><pageclass class="#AA7592" subcaption="Sockets Module"></pageclass><br />
__NOTOC__<br />
{{ModuleFunction|Sockets}}<br />
This function creates a socket.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
socket sockOpen ( string hostname, int port )<br />
</syntaxhighlight><br />
===Required arguments===<br />
* '''hostname:''' The DNS or IP to connect to e.g. "www.google.com"<br />
* '''port:''' The port to bind the socket to e.g. 80<br />
<!--* '''secure:''' A boolean specifying whether the connection should be secure (ssl)--><br />
<br />
===Returns===<br />
Returns ''userdata'' that represents the socket if you correct arguments were given, ''false'' otherwise.<br />
<br />
==Example==<br />
This piece of code connects to irc.gtanet.com, joins #mta and quits in 10 seconds.<br />
<syntaxhighlight lang="lua"><br />
local root = getRootElement()<br />
local ircSocket = sockOpen("irc.gtanet.com",6667)<br />
<br />
addEventHandler("onSockOpened",root,<br />
function (socket)<br />
if socket == ircSocket then<br />
sockWrite(socket,"USER mta mta * :Bot\r\n")<br />
sockWrite(socket,"NICK mta\r\n")<br />
sockWrite(socket,"JOIN #mta\r\n")<br />
<br />
outputServerLog("IRC: Connected!")<br />
setTimer(disconnect,10000,1)<br />
end<br />
end<br />
)<br />
<br />
addEventHandler("onSockData",root,<br />
function (socket,data)<br />
if socket == ircSocket then<br />
outputServerLog(data)<br />
end<br />
end<br />
)<br />
<br />
addEventHandler("onSockClosed",root,<br />
function (socket)<br />
if socket == ircSocket then<br />
outputServerLog("IRC: disconnected!")<br />
end<br />
end<br />
)<br />
<br />
function disconnect ()<br />
sockClose(ircSocket)<br />
end<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===Functions===<br />
{{Modules/Sockets/Functions}}<br />
<br />
===Events===<br />
{{Modules/Sockets/Events}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GetElementSpeed&diff=24259GetElementSpeed2010-08-08T20:18:24Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__<br />
{{Useful Function}}<br />
This function allows you to get element speed in kph or mph units.<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
int/bool getElementSpeed (element theElement, [ int/string unit="kph" ])<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''theElement''': Element you want to get speed of<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
* '''unit''': Units in which speed should be returned. This can be 1 or "mph" for mph, any other value for kph.<br />
<br />
==Code==<br />
<section name="Function source" class="both" show="true"><br />
<syntaxhighlight lang="lua"><br />
function getElementSpeed(element,unit)<br />
if (unit == nil) then unit = 0 end<br />
if (isElement(element)) then<br />
local x,y,z = getElementVelocity(element)<br />
if (unit=="mph" or unit==1 or unit =='1') then<br />
return (x^2 + y^2 + z^2) ^ 0.5 * 100<br />
else<br />
return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100<br />
end<br />
else<br />
outputDebugString("Not an element. Can't get speed")<br />
return false<br />
end<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
==Example==<br />
<section name="Server-side example" class="server" show="true"><br />
This example adds command that outputs to chat current player speed in both mph and kph. Notice: When player is in car his ped is having same velocity as car, so it isn't needed to get his car element.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler("getmyspeed",<br />
function (player, cmd)<br />
outputChatBox ("Your speed in mph: "..getElementSpeed(player, "mph"),player)<br />
outputChatBox ("Your speed in kph: "..getElementSpeed(player, "kph"),player)<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
Original function by author of '''speedx''' resource. Modified, wiki-fied etc by '''varez'''.<br />
<br />
==See Also==<br />
{{Useful_Functions}}<br />
<nowiki>Insert non-formatted text here</nowiki></div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GetTrafficLightState&diff=24258GetTrafficLightState2010-08-08T20:16:48Z<p>Sebassje: /* Syntax */</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
Gets the current traffic light state. This state controls the traffic light colors. For instance, state '''1''' will cause the north and south traffic lights to be amber, and the ones left and east will turn red.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
int getTrafficLightState ( )<br />
</syntaxhighlight><br />
<br />
===Returns===<br />
Returns the current [[Traffic_light_states|state]] of the traffic lights.<br />
<br />
==Example==<br />
This example doesn't exist<br />
<br />
==See Also==<br />
{{World_functions}}<br />
<br />
[[Category:Needs_Example]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=Modules/MTA-MySQL&diff=24181Modules/MTA-MySQL2010-08-06T20:54:37Z<p>Sebassje: </p>
<hr />
<div>{{Module_Info|<br />
name = MTA MySQL |<br />
version = 0.41 |<br />
author = [[User:ryden|Alberto Alonso (ryden)]] |<br />
module_website = ''Not available'' |<br />
download_link = [http://code.google.com/p/multitheftauto-modules/downloads/list Here] |<br />
license = [http://www.opensource.org/licenses/bsd-license.php BSD]<br />
}}<br />
MTA MySQL is an alternative to the default [[Modules/MySQL|ml_mysql]] module provided by the MTA team.<br />
It is available for Windows and GNU/Linux and provides the source code.<br />
<br />
''Note: From version 0.4 it supports both DP2.3 and 1.0 servers.''<br />
<br />
==Installation==<br />
===Windows===<br />
Uncompress the file mta_mysql.dll into your ''C:\Program files\MTA San Andreas\server\mods\deathmatch\modules\'' directory and the file libmysql.dll into your ''C:\Program files\MTA San Andreas\server\'' directory.<br />
<br />
Then, add the following line in mtaserver.conf:<br />
<syntaxhighlight lang="xml"><br />
<module src="mta_mysql.dll" /><br />
</syntaxhighlight><br />
<br />
===GNU/Linux===<br />
Uncompress the file mta_mysql.so in the ''mods/deathmatch/modules/'' directory.<br />
<br />
Then, add the following line in mtaserver.conf:<br />
<syntaxhighlight lang="xml"><br />
<module src="mta_mysql.so" /><br />
</syntaxhighlight><br />
<br />
'''If you experience an error on Unix systems:'''<br />
Try to add port and socket parameters to your mysql_connect.<br />
<br />
==Linux 1.0.3+ servers==<br />
It appears that the current version does not work with the 1.0.3 linux servers, a recompiled MTA-MySQL.so is available for download here: http://forum.multitheftauto.com/download/file.php?id=217<br />
<br />
==Handler functions==<br />
{{Modules/MTA-MySQL/Handler_functions}}<br />
<br />
==Result managing functions==<br />
{{Modules/MTA-MySQL/Result_functions}}<br />
<br />
[[Category:Modules]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=User:Sebassje&diff=24172User:Sebassje2010-08-04T16:01:05Z<p>Sebassje: Replaced content with '__NOTOC__
==Module(s)==
* Socket module: click here'</p>
<hr />
<div>__NOTOC__<br />
<br />
==Module(s)==<br />
* Socket module: [[Modules/Sockets | click here]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=SetVehicleGunsEnabled&diff=24169SetVehicleGunsEnabled2010-08-03T15:29:45Z<p>Sebassje: /* Example */</p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
This function enables or disables the weapons on a vehicle<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool setVehicleGunsEnabled ( vehicle theVehicle, bool gunsEnabled )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''theVehicle''': The [[element]] representing the [[vehicle]] whose guns you want to toggle.<br />
*'''gunsEnabled''': A bool representing whether guns are enabled or disabled. ''false'' will disable them, ''true'' will enable them.<br />
<br />
===Returns===<br />
Returns ''true'' if the guns were toggled succesfully, ''false'' if arguments passed were invalid.<br />
<br />
==Example==<br />
<section name="Example 1" class="server" show="true"><br />
This function will disables the ability to fire rockets on a hydra.<br />
<syntaxhighlight lang="lua"><br />
function disableFireForHydra ( theVehicle, seat, jacked )<br />
if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra<br />
setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns<br />
else -- if they entered another vehicle<br />
setVehicleGunsEnabled ( theVehicle, true ) -- enable their guns<br />
end<br />
end<br />
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra )<br />
</syntaxhighlight><br />
</section><br />
<section name="Example 2" class="client" show="false"><br />
This function will disables the ability to fire rockets on a hydra.<br />
<syntaxhighlight lang="lua"><br />
function disableFireForHydra ( theVehicle, seat )<br />
if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra<br />
setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns<br />
else -- if they entered another vehicle<br />
setVehicleGunsEnabled ( theVehicle, true ) -- enable their guns<br />
end<br />
end<br />
addEventHandler ( "onClientPlayerEnterVehicle", getLocalPlayer(), disableFireForHydra )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Vehicle functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=EngineLoadTXD&diff=24161EngineLoadTXD2010-07-31T20:55:52Z<p>Sebassje: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function loads a RenderWare Texture Dictionary (TXD) file into GTA. The texture dictionary can then be used to provide textures.<br />
<br />
This is a client side function. Be sure to transfer your TXD file by including it in the meta file.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
txd engineLoadTXD ( string txd_file [, bool filteringEnabled = true ] ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''txd_file:''' The [[filepath]] to the txd file you want to load<br />
*'''filteringEnabled:''' Texture filtering<br />
<br />
===Returns===<br />
Returns a [[TXD]] if the file was loaded, ''false'' otherwise.<br />
<br />
==Example== <br />
'''Example 1:''' This example loads a combination of a custom DFF and TXD file to replace the Euros vehicle in-game. The collisions are embedded inside the DFF file.<br />
<syntaxhighlight lang="lua"><br />
outputChatBox ( "> replacing the euros vehicle" )<br />
<br />
txd = engineLoadTXD ( "data/euros.txd" )<br />
engineImportTXD ( txd, 587 )<br />
dff = engineLoadDFF ( "data/euros.dff", 587 )<br />
engineReplaceModel ( dff, 587 )<br />
</syntaxhighlight><br />
<br />
<br />
'''Example 2:''' This example loads a combination of custom DFF, TXD and COL files to replace an in-game model of a set of floors.<br />
<syntaxhighlight lang="lua"><br />
outputChatBox ( "> loading floor objects" )<br />
txd_floors = engineLoadTXD ( "models/office_floors.txd" )<br />
engineImportTXD ( txd_floors, 3781 )<br />
col_floors = engineLoadCOL ( "models/office_floors.col" )<br />
dff_floors = engineLoadDFF ( "models/office_floors.dff", 0 )<br />
engineReplaceCOL ( col_floors, 3781 )<br />
engineReplaceModel ( dff_floors, 3781 )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Engine_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=ResetTimer&diff=24097ResetTimer2010-07-24T09:41:23Z<p>Sebassje: </p>
<hr />
<div>{{Server function}}<br />
__NOTOC__<br />
This function allows you to reset the elapsed time in existing timers to zero. The function does not reset the 'times to execute' count on timers which have a limited amout of repetitions.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool resetTimer ( timer theTimer )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''theTimer:''' The [[timer]] whose elapsed time you wish to reset.<br />
<br />
===Returns===<br />
Returns ''true'' if the timer was successfully reset, ''false'' otherwise.<br />
<br />
==Example== <br />
<syntaxhighlight lang="lua"><br />
--TODO<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Utility functions}}<br />
[[Category:Needs_Example]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=AddAccount&diff=24087AddAccount2010-07-22T17:10:43Z<p>Sebassje: Undo revision 24086 by Arhang3L (Talk)</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__<br />
This function adds an account to the list of registered accounts of the current server.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
{{New feature|3|1.0 r848|<br />
<syntaxhighlight lang="lua"><br />
account addAccount ( string name, string pass )<br />
</syntaxhighlight><br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
<syntaxhighlight lang="lua"><br />
bool addAccount ( string name, string pass )<br />
</syntaxhighlight> <br />
}}<br />
<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''name:''' The name of the account you wish to make, this normally is the player's name.<br />
*'''pass:''' The password to set for this account for future logins.<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
{{New feature|3|1.0 r848|<br />
Returns the ''account'' element if the account was created, ''false'' if the account already exists or an error occured.<br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
Returns ''true'' if the account was created, ''false'' if the account already exists or an error occured.<br />
}}<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
'''Example 1:''' This enables players to register on your server by using /register <password> in the chat window.<br />
<syntaxhighlight lang="lua"><br />
function registerPlayer ( source, commandName, password )<br />
-- Check if the password field is blank or not (only blank if they didnt enter one)<br />
if ( password ~= "" and password ~= nil ) then<br />
--Attempt to add the account, and save its value in a var<br />
local accountAdded = addAccount( getPlayerName(source), password )<br />
if ( accountAdded ) then<br />
-- Tell the user all is done<br />
outputChatBox ( "Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login", source )<br />
else<br />
-- There was an error making the account, tell the user<br />
outputChatBox ( "Error creating account, contact the server admin", source )<br />
end<br />
else<br />
-- There was an error in the syntax, tell the user the correct syntax.<br />
outputChatBox ( "Error creating account, correct syntax: /register <password>", source )<br />
end<br />
end<br />
addCommandHandler ( "register", registerPlayer ) -- add the command handler<br />
</syntaxhighlight><br />
<br />
'''This code differs by allowing the user to change their username that they wish to use.'''<br />
<br />
'''Example 2:''' This enables players to register on your server by using /register <username> <password> in the chat window.<br />
<syntaxhighlight lang="lua"><br />
function registerPlayer ( source, commandName, username, password )<br />
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil) then<br />
local accountAdded = addAccount(username,password)<br />
if(accountAdded) then<br />
outputChatBox("Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login",source)<br />
else<br />
outputChatBox("Error creating account, contact the server admin.",source)<br />
end<br />
else<br />
outputChatBox("Error creating account, correct syntax: /register <nick> <pass>",source)<br />
end<br />
end<br />
addCommandHandler ( "register", registerPlayer ) -- add the command handler<br />
</syntaxhighlight><br />
<br />
'''Example 3:''' This code differs again so the user can only register once /register <username> <password>.<br />
<syntaxhighlight lang="lua"><br />
local bRegisteredOnce = false<br />
<br />
function registerPlayer ( source, commandName, username, password )<br />
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil and bRegisteredOnce == false) then<br />
local accountAdded = addAccount(username,password)<br />
if(accountAdded) then<br />
outputChatBox("Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login",source)<br />
bRegisteredOnce = true<br />
else<br />
outputChatBox("Error creating account, contact the server admin.",source)<br />
end<br />
else<br />
if bRegisteredOnce == true then<br />
outputChatBox("You already registered on this server!",source)<br />
else<br />
outputChatBox("Error creating account, correct syntax: /register <nick> <pass>",source)<br />
end<br />
end<br />
end<br />
addCommandHandler ( "register", registerPlayer ) -- add the command handler<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{Account_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=AddAccount&diff=24085AddAccount2010-07-22T15:41:56Z<p>Sebassje: Undo revision 24082 by Arhang3L (Talk)</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__<br />
This function adds an account to the list of registered accounts of the current server.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
{{New feature|3|1.0 r848|<br />
<syntaxhighlight lang="lua"><br />
account addAccount ( string name, string pass )<br />
</syntaxhighlight><br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
<syntaxhighlight lang="lua"><br />
bool addAccount ( string name, string pass )<br />
</syntaxhighlight> <br />
}}<br />
<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''name:''' The name of the account you wish to make, this normally is the player's name.<br />
*'''pass:''' The password to set for this account for future logins.<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
{{New feature|3|1.0 r848|<br />
Returns the ''account'' element if the account was created, ''false'' if the account already exists or an error occured.<br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
Returns ''true'' if the account was created, ''false'' if the account already exists or an error occured.<br />
}}<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
'''Example 1:''' This enables players to register on your server by using /register <password> in the chat window.<br />
<syntaxhighlight lang="lua"><br />
function registerPlayer ( source, commandName, password )<br />
-- Check if the password field is blank or not (only blank if they didnt enter one)<br />
if ( password ~= "" and password ~= nil ) then<br />
--Attempt to add the account, and save its value in a var<br />
local accountAdded = addAccount( getPlayerName(source), password )<br />
if ( accountAdded ) then<br />
-- Tell the user all is done<br />
outputChatBox ( "Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login", source )<br />
else<br />
-- There was an error making the account, tell the user<br />
outputChatBox ( "Error creating account, contact the server admin", source )<br />
end<br />
else<br />
-- There was an error in the syntax, tell the user the correct syntax.<br />
outputChatBox ( "Error creating account, correct syntax: /register <password>", source )<br />
end<br />
end<br />
addCommandHandler ( "register", registerPlayer ) -- add the command handler<br />
</syntaxhighlight><br />
<br />
'''This code differs by allowing the user to change their username that they wish to use.'''<br />
<br />
'''Example 2:''' This enables players to register on your server by using /register <username> <password> in the chat window.<br />
<syntaxhighlight lang="lua"><br />
function registerPlayer ( source, commandName, username, password )<br />
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil) then<br />
local accountAdded = addAccount(username,password)<br />
if(accountAdded) then<br />
outputChatBox("Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login",source)<br />
else<br />
outputChatBox("Error creating account, contact the server admin.",source)<br />
end<br />
else<br />
outputChatBox("Error creating account, correct syntax: /register <nick> <pass>",source)<br />
end<br />
end<br />
addCommandHandler ( "register", registerPlayer ) -- add the command handler<br />
</syntaxhighlight><br />
<br />
'''Example 3:''' This code differs again so the user can only register once /register <username> <password>.<br />
<syntaxhighlight lang="lua"><br />
local bRegisteredOnce = false<br />
<br />
function registerPlayer ( source, commandName, username, password )<br />
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil and bRegisteredOnce == false) then<br />
local accountAdded = addAccount(username,password)<br />
if(accountAdded) then<br />
outputChatBox("Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login",source)<br />
bRegisteredOnce = true<br />
else<br />
outputChatBox("Error creating account, contact the server admin.",source)<br />
end<br />
else<br />
if bRegisteredOnce == true then<br />
outputChatBox("You already registered on this server!",source)<br />
else<br />
outputChatBox("Error creating account, correct syntax: /register <nick> <pass>",source)<br />
end<br />
end<br />
end<br />
addCommandHandler ( "register", registerPlayer ) -- add the command handler<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{Account_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=AddAccount&diff=24084AddAccount2010-07-22T15:41:44Z<p>Sebassje: Undo revision 24083 by Arhang3L (Talk)</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__<br />
This function adds an account to the list of registered accounts of the current server.<br />
<br />
==Синтаксис== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
{{New feature|3|1.0 r848|<br />
<syntaxhighlight lang="lua"><br />
account addAccount ( string name, string pass )<br />
</syntaxhighlight><br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
<syntaxhighlight lang="lua"><br />
bool addAccount ( string name, string pass )<br />
</syntaxhighlight> <br />
}}<br />
<br />
===Необходимые аргументы=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''name:''' Имя аккаунта, который вы хотите создать.<br />
*'''pass:''' Установленный пароль для аккаунта.<br />
<br />
===Возвраты===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
{{New feature|3|1.0 r848|<br />
Returns the ''account'' element if the account was created, ''false'' if the account already exists or an error occured.<br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
Returns ''true'' if the account was created, ''false'' if the account already exists or an error occured.<br />
}}<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
'''Example 1:''' This enables players to register on your server by using /register <password> in the chat window.<br />
<syntaxhighlight lang="lua"><br />
function registerPlayer ( source, commandName, password )<br />
-- Check if the password field is blank or not (only blank if they didnt enter one)<br />
if ( password ~= "" and password ~= nil ) then<br />
--Attempt to add the account, and save its value in a var<br />
local accountAdded = addAccount( getPlayerName(source), password )<br />
if ( accountAdded ) then<br />
-- Tell the user all is done<br />
outputChatBox ( "Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login", source )<br />
else<br />
-- There was an error making the account, tell the user<br />
outputChatBox ( "Error creating account, contact the server admin", source )<br />
end<br />
else<br />
-- There was an error in the syntax, tell the user the correct syntax.<br />
outputChatBox ( "Error creating account, correct syntax: /register <password>", source )<br />
end<br />
end<br />
addCommandHandler ( "register", registerPlayer ) -- add the command handler<br />
</syntaxhighlight><br />
<br />
'''This code differs by allowing the user to change their username that they wish to use.'''<br />
<br />
'''Example 2:''' This enables players to register on your server by using /register <username> <password> in the chat window.<br />
<syntaxhighlight lang="lua"><br />
function registerPlayer ( source, commandName, username, password )<br />
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil) then<br />
local accountAdded = addAccount(username,password)<br />
if(accountAdded) then<br />
outputChatBox("Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login",source)<br />
else<br />
outputChatBox("Error creating account, contact the server admin.",source)<br />
end<br />
else<br />
outputChatBox("Error creating account, correct syntax: /register <nick> <pass>",source)<br />
end<br />
end<br />
addCommandHandler ( "register", registerPlayer ) -- add the command handler<br />
</syntaxhighlight><br />
<br />
'''Example 3:''' This code differs again so the user can only register once /register <username> <password>.<br />
<syntaxhighlight lang="lua"><br />
local bRegisteredOnce = false<br />
<br />
function registerPlayer ( source, commandName, username, password )<br />
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil and bRegisteredOnce == false) then<br />
local accountAdded = addAccount(username,password)<br />
if(accountAdded) then<br />
outputChatBox("Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login",source)<br />
bRegisteredOnce = true<br />
else<br />
outputChatBox("Error creating account, contact the server admin.",source)<br />
end<br />
else<br />
if bRegisteredOnce == true then<br />
outputChatBox("You already registered on this server!",source)<br />
else<br />
outputChatBox("Error creating account, correct syntax: /register <nick> <pass>",source)<br />
end<br />
end<br />
end<br />
addCommandHandler ( "register", registerPlayer ) -- add the command handler<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{Account_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=CreatePed&diff=24066CreatePed2010-07-19T18:26:33Z<p>Sebassje: /* Syntax */</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
{{Needs_Checking|CPP has code for a serverside extra argument called bSynced}} <br />
Creates a Ped in the GTA world.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua">ped createPed ( int modelid, float x, float y, float z [, float rot = 0.0 ] )</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''modelid:''' A whole integer specifying the [[Character_Skins|GTASA skin ID]].<br />
*'''x:''' A floating point number representing the X coordinate on the map.<br />
*'''y:''' A floating point number representing the Y coordinate on the map.<br />
*'''z:''' A floating point number representing the Z coordinate on the map.<br />
*'''rot:''' A floating point number representing the rotation in degrees. <br />
<br />
===Returns===<br />
Returns the ped element.<br />
<br />
==Example== <br />
<br />
<section name="Server" class="server" show="true"><br />
This example creates an ped when the resource starts:<br />
<syntaxhighlight lang="lua"><br />
function pedLoad ( name )<br />
createPed ( 120, 5540.6654, 1020.55122, 1240.545 )<br />
end<br />
addEventHandler ( "onResourceStart", getRootElement(), pedLoad )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Ped functions}}<br />
[[ru:createPed]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GetVehicleEngineState&diff=24061GetVehicleEngineState2010-07-18T20:55:33Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function returns a vehicle's engine state (on or off).<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getVehicleEngineState ( vehicle theVehicle )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''theVehicle''': The [[vehicle]] you wish to change the engine state of.<br />
<br />
===Returns===<br />
Returns '''true''' if the vehicle's engine is started, '''false''' otherwise.<br />
<br />
==Example==<br />
<section name="Serverside example" class="server" show="true"><br />
This example will switch the vehicle engine state with the command "/switchengine".<br />
<syntaxhighlight lang="lua"><br />
function switchEngine ( playerSource )<br />
local theVehicle = getPedOccupiedVehicle ( playerSource )<br />
<br />
-- Check if the player is in any vehicle and if he is the driver<br />
if theVehicle and getVehicleController ( theVehicle ) == playerSource then<br />
local state = getVehicleEngineState ( theVehicle )<br />
setVehicleEngineState ( theVehicle, not state )<br />
end<br />
end<br />
addCommandHandler ( "switchengine", switchEngine )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Vehicle functions}}<br />
<br />
[[Category:Changes_in_1.0]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=Template:Client_camera_functions&diff=24033Template:Client camera functions2010-07-14T08:06:48Z<p>Sebassje: </p>
<hr />
<div>*[[fadeCamera]]<br />
*[[getCameraTarget]]<br />
*[[setCameraTarget]]<br />
{{New feature|3|1.0|<br />
*[[getCameraInterior]]<br />
*[[getCameraMatrix]]<br />
*[[setCameraInterior]]<br />
*[[setCameraMatrix]]<br />
}}<br />
{{New feature|3.0001|1.0.1|<br />
*[[setCameraClip]]<br />
}}<br />
{{New feature|3.0110|1.1|<br />
*[[getCameraView]]<br />
*[[setCameraView]]<br />
}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=Template:GUI_functions&diff=24032Template:GUI functions2010-07-13T16:06:22Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__<br />
{{New feature|3.0004|1.0.4|<br />
* [[getChatboxLayout]]<br />
}}<br />
* [[guiBringToFront]]<br />
* [[guiGetAlpha]]<br />
* [[guiGetEnabled]]<br />
* [[guiGetFont]]<br />
* [[guiGetInputEnabled]]<br />
* [[guiGetPosition]]<br />
* [[guiGetProperties]]<br />
* [[guiGetProperty]]<br />
* [[guiGetScreenSize]]<br />
* [[guiGetSize]]<br />
* [[guiGetText]]<br />
* [[guiGetVisible]]<br />
* [[guiMoveToBack]]<br />
* [[guiSetAlpha]]<br />
* [[guiSetEnabled]]<br />
* [[guiSetFont]]<br />
* [[guiSetInputEnabled]]<br />
* [[guiSetPosition]]<br />
* [[guiSetProperty]]<br />
* [[guiSetSize]]<br />
* [[guiSetText]]<br />
* [[guiSetVisible]]<br />
* [[isChatBoxInputActive]]<br />
* [[isConsoleActive]]<br />
* [[isDebugViewActive]]<br />
* [[isMainMenuActive]]<br />
* [[isMTAWindowActive]]<br />
* [[isTransferBoxActive]]<br />
<br />
===Buttons===<br />
* [[guiCreateButton]]<br />
<br />
===Checkboxes===<br />
* [[guiCheckBoxGetSelected]]<br />
* [[guiCheckBoxSetSelected]]<br />
* [[guiCreateCheckBox]]<br />
<br />
===Comboboxes===<br />
{{New feature|3.0110|1.1|<br />
* [[guiCreateComboBox]]<br />
* [[guiComboBoxAddItem]]<br />
* [[guiComboBoxGetItemText]]<br />
* [[guiComboBoxSetItemText]]<br />
* [[guiComboBoxRemoveItem]]<br />
* [[guiComboBoxGetSelected]]<br />
* [[guiComboBoxSetSelected]]<br />
}}<br />
<br />
===Edit fields===<br />
* [[guiCreateEdit]]<br />
* [[guiEditSetMasked]]<br />
* [[guiEditSetMaxLength]]<br />
* [[guiEditSetReadOnly]]<br />
{{New feature|3|1.0|<br />
* [[guiEditSetCaretIndex]]<br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
* [[guiEditSetCaratIndex]]<br />
}}<br />
<br />
===Gridlists===<br />
* [[guiCreateGridList]]<br />
* [[guiGridListAddColumn]]<br />
* [[guiGridListAddRow]]<br />
* [[guiGridListAutoSizeColumn]]<br />
* [[guiGridListClear]]<br />
* [[guiGridListGetItemData]]<br />
* [[guiGridListGetItemText]]<br />
* [[guiGridListGetRowCount]]<br />
* [[guiGridListGetSelectedItem]]<br />
* [[guiGridListInsertRowAfter]]<br />
* [[guiGridListRemoveColumn]]<br />
* [[guiGridListRemoveRow]]<br />
* [[guiGridListSetItemData]]<br />
* [[guiGridListSetItemText]]<br />
* [[guiGridListSetScrollBars]]<br />
* [[guiGridListSetSelectedItem]]<br />
* [[guiGridListSetSelectionMode]]<br />
* [[guiGridListSetSortingEnabled]]<br />
{{New feature|3|1.0|<br />
* [[guiGridListGetSelectedCount]]<br />
* [[guiGridListGetSelectedItems]]<br />
* [[guiGridListSetColumnWidth]]<br />
}}<br />
{{New feature|3.0004|1.0.4|<br />
* [[guiGridListGetItemColor]]<br />
* [[guiGridListSetItemColor]]<br />
}}<br />
<br />
===Memos===<br />
* [[guiCreateMemo]]<br />
* [[guiMemoSetReadOnly]]<br />
{{New feature|3|1.0|<br />
* [[guiMemoSetCaretIndex]]<br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
* [[guiMemoSetCaratIndex]]<br />
}}<br />
<br />
===Progress bars===<br />
* [[guiCreateProgressBar]]<br />
* [[guiProgressBarGetProgress]]<br />
* [[guiProgressBarSetProgress]]<br />
<br />
===Radio buttons===<br />
* [[guiCreateRadioButton]]<br />
* [[guiRadioButtonGetSelected]]<br />
* [[guiRadioButtonSetSelected]]<br />
<br />
===Scrollbars===<br />
* [[guiCreateScrollBar]]<br />
* [[guiScrollBarGetScrollPosition]]<br />
* [[guiScrollBarSetScrollPosition]]<br />
<br />
===Scroll panes===<br />
* [[guiCreateScrollPane]]<br />
* [[guiScrollPaneGetHorizontalScrollPosition]]<br />
* [[guiScrollPaneGetVerticalScrollPosition]]<br />
* [[guiScrollPaneSetHorizontalScrollPosition]]<br />
* [[guiScrollPaneSetScrollBars]]<br />
* [[guiScrollPaneSetVerticalScrollPosition]]<br />
<br />
===Static images===<br />
* [[guiCreateStaticImage]]<br />
* [[guiStaticImageLoadImage]]<br />
<br />
===Tab panels===<br />
* [[guiCreateTabPanel]]<br />
{{New feature|3|1.0|<br />
* [[guiGetSelectedTab]]<br />
* [[guiSetSelectedTab]]<br />
}}<br />
<br />
===Tabs===<br />
* [[guiCreateTab]]<br />
* [[guiDeleteTab]]<br />
<br />
===Text labels===<br />
* [[guiCreateLabel]]<br />
* [[guiLabelGetFontHeight]]<br />
* [[guiLabelGetTextExtent]]<br />
* [[guiLabelSetColor]]<br />
* [[guiLabelSetHorizontalAlign]]<br />
* [[guiLabelSetVerticalAlign]]<br />
<br />
===Windows===<br />
* [[guiCreateWindow]]<br />
* [[guiWindowSetMovable]]<br />
* [[guiWindowSetSizable]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=Template:GUI_functions&diff=24031Template:GUI functions2010-07-13T16:05:37Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__<br />
{{New feature|3.0004|1.0.4|<br />
* [[getChatboxLayout]]<br />
}}<br />
* [[guiBringToFront]]<br />
* [[guiGetAlpha]]<br />
* [[guiGetEnabled]]<br />
* [[guiGetFont]]<br />
* [[guiGetInputEnabled]]<br />
* [[guiGetPosition]]<br />
* [[guiGetProperties]]<br />
* [[guiGetProperty]]<br />
* [[guiGetScreenSize]]<br />
* [[guiGetSize]]<br />
* [[guiGetText]]<br />
* [[guiGetVisible]]<br />
* [[guiMoveToBack]]<br />
* [[guiSetAlpha]]<br />
* [[guiSetEnabled]]<br />
* [[guiSetFont]]<br />
* [[guiSetInputEnabled]]<br />
* [[guiSetPosition]]<br />
* [[guiSetProperty]]<br />
* [[guiSetSize]]<br />
* [[guiSetText]]<br />
* [[guiSetVisible]]<br />
* [[isChatBoxInputActive]]<br />
* [[isConsoleActive]]<br />
* [[isDebugViewActive]]<br />
* [[isMainMenuActive]]<br />
* [[isMTAWindowActive]]<br />
* [[isTransferBoxActive]]<br />
<br />
===Buttons===<br />
* [[guiCreateButton]]<br />
<br />
===Checkboxes===<br />
* [[guiCheckBoxGetSelected]]<br />
* [[guiCheckBoxSetSelected]]<br />
* [[guiCreateCheckBox]]<br />
<br />
===Comboboxes===<br />
{{New feature|3.0011|1.1|<br />
* [[guiCreateComboBox]]<br />
* [[guiComboBoxAddItem]]<br />
* [[guiComboBoxGetItemText]]<br />
* [[guiComboBoxSetItemText]]<br />
* [[guiComboBoxRemoveItem]]<br />
* [[guiComboBoxGetSelected]]<br />
* [[guiComboBoxSetSelected]]<br />
}}<br />
<br />
===Edit fields===<br />
* [[guiCreateEdit]]<br />
* [[guiEditSetMasked]]<br />
* [[guiEditSetMaxLength]]<br />
* [[guiEditSetReadOnly]]<br />
{{New feature|3|1.0|<br />
* [[guiEditSetCaretIndex]]<br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
* [[guiEditSetCaratIndex]]<br />
}}<br />
<br />
===Gridlists===<br />
* [[guiCreateGridList]]<br />
* [[guiGridListAddColumn]]<br />
* [[guiGridListAddRow]]<br />
* [[guiGridListAutoSizeColumn]]<br />
* [[guiGridListClear]]<br />
* [[guiGridListGetItemData]]<br />
* [[guiGridListGetItemText]]<br />
* [[guiGridListGetRowCount]]<br />
* [[guiGridListGetSelectedItem]]<br />
* [[guiGridListInsertRowAfter]]<br />
* [[guiGridListRemoveColumn]]<br />
* [[guiGridListRemoveRow]]<br />
* [[guiGridListSetItemData]]<br />
* [[guiGridListSetItemText]]<br />
* [[guiGridListSetScrollBars]]<br />
* [[guiGridListSetSelectedItem]]<br />
* [[guiGridListSetSelectionMode]]<br />
* [[guiGridListSetSortingEnabled]]<br />
{{New feature|3|1.0|<br />
* [[guiGridListGetSelectedCount]]<br />
* [[guiGridListGetSelectedItems]]<br />
* [[guiGridListSetColumnWidth]]<br />
}}<br />
{{New feature|3.0004|1.0.4|<br />
* [[guiGridListGetItemColor]]<br />
* [[guiGridListSetItemColor]]<br />
}}<br />
<br />
===Memos===<br />
* [[guiCreateMemo]]<br />
* [[guiMemoSetReadOnly]]<br />
{{New feature|3|1.0|<br />
* [[guiMemoSetCaretIndex]]<br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
* [[guiMemoSetCaratIndex]]<br />
}}<br />
<br />
===Progress bars===<br />
* [[guiCreateProgressBar]]<br />
* [[guiProgressBarGetProgress]]<br />
* [[guiProgressBarSetProgress]]<br />
<br />
===Radio buttons===<br />
* [[guiCreateRadioButton]]<br />
* [[guiRadioButtonGetSelected]]<br />
* [[guiRadioButtonSetSelected]]<br />
<br />
===Scrollbars===<br />
* [[guiCreateScrollBar]]<br />
* [[guiScrollBarGetScrollPosition]]<br />
* [[guiScrollBarSetScrollPosition]]<br />
<br />
===Scroll panes===<br />
* [[guiCreateScrollPane]]<br />
* [[guiScrollPaneGetHorizontalScrollPosition]]<br />
* [[guiScrollPaneGetVerticalScrollPosition]]<br />
* [[guiScrollPaneSetHorizontalScrollPosition]]<br />
* [[guiScrollPaneSetScrollBars]]<br />
* [[guiScrollPaneSetVerticalScrollPosition]]<br />
<br />
===Static images===<br />
* [[guiCreateStaticImage]]<br />
* [[guiStaticImageLoadImage]]<br />
<br />
===Tab panels===<br />
* [[guiCreateTabPanel]]<br />
{{New feature|3|1.0|<br />
* [[guiGetSelectedTab]]<br />
* [[guiSetSelectedTab]]<br />
}}<br />
<br />
===Tabs===<br />
* [[guiCreateTab]]<br />
* [[guiDeleteTab]]<br />
<br />
===Text labels===<br />
* [[guiCreateLabel]]<br />
* [[guiLabelGetFontHeight]]<br />
* [[guiLabelGetTextExtent]]<br />
* [[guiLabelSetColor]]<br />
* [[guiLabelSetHorizontalAlign]]<br />
* [[guiLabelSetVerticalAlign]]<br />
<br />
===Windows===<br />
* [[guiCreateWindow]]<br />
* [[guiWindowSetMovable]]<br />
* [[guiWindowSetSizable]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=IsPedDoingGangDriveby&diff=24006IsPedDoingGangDriveby2010-07-09T20:30:21Z<p>Sebassje: </p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
This function checks if the ped is in the driveby state.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool isPedDoingGangDriveby ( ped thePed )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''thePed:''' The [[ped]] element whose state is to be checked.<br />
<br />
===Returns===<br />
Returns '''true''' if the driveby state is enabled, '''false''' otherwise.<br />
<br />
==Example== <br />
<section name="Client" class="client" show="true"><br />
This example turns on driveby mode when the local player types ''driveby'' in the console.<br />
<syntaxhighlight lang="lua">function setDoingDriveby ( )<br />
-- we check if local player isn't currently doing a gang driveby<br />
if not isPedDoingGangDriveby ( getLocalPlayer () ) then<br />
-- if he got driveby mode off, turn it on<br />
setPedWeaponSlot ( getLocalPlayer (), 4 )<br />
setPedDoingGangDriveby ( getLocalPlayer (), true )<br />
else<br />
-- otherwise, turn it off<br />
setPedWeaponSlot ( getLocalPlayer (), 0 )<br />
setPedDoingGangDriveby ( getLocalPlayer (), false )<br />
end<br />
end<br />
addCommandHandler ( "driveby", setDoingDriveby )</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Ped functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=PlaySound&diff=23870PlaySound2010-07-08T11:20:36Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
Creates a [[sound]] element and plays it immediately after creation for the local player.<br /><br />
<br /><br />
'''Note:''' The only supported audio formats are MP3, WAV, OGG, RIFF, MOD, XM, IT and S3M.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua">element playSound ( string soundPath, [ bool looped = false ] )</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''soundPath:''' The [[filepath]] to the sound file you want to play. (Sound file has to be predefined in the client side [[meta.xml]] file with <file /> tags.)<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''looped:''' A [[boolean]] representing whether the sound will be looped. To loop the sound, use ''true''.<br />
<br />
===Returns===<br />
Returns a [[sound]] element if the sound was successfully created, ''false'' otherwise.<br />
<br />
==Example== <br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function wasted (killer, weapon, bodypart) <br />
local sound = playSound("sounds/wasted.mp3") --Play wasted.mp3 from the sounds folder<br />
setSoundVolume(sound, 0.5) -- set the sound volume to 50%<br />
end<br />
<br />
addEventHandler("onClientPlayerWasted", getLocalPlayer(), wasted) --add the event handler<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client_audio_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=PlaySound3D&diff=23869PlaySound3D2010-07-08T11:20:17Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
Creates a [[sound]] element in the GTA world and plays it immediately after creation for the local player. [[setElementPosition]] can be used to move the [[sound]] element around after it has been created.<br /><br />
<br /><br />
'''Note:''' The only supported audio formats are MP3, WAV, OGG, RIFF, MOD, XM, IT and S3M.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua">element playSound3D ( string soundPath, float x, float y, float z, [ bool looped = false ] )</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''soundPath:''' The [[filepath]] to the sound file you want to play. (Sound file has to be predefined in the client side [[meta.xml]] file with <file /> tags.)<br />
*'''x:''' A floating point number representing the X coordinate on the map.<br />
*'''y:''' A floating point number representing the Y coordinate on the map.<br />
*'''z:''' A floating point number representing the Z coordinate on the map.<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''looped:''' A [[boolean]] representing whether the sound will be looped. To loop the sound, use ''true''.<br />
<br />
===Returns===<br />
Returns a [[sound]] element if the sound was successfully created, ''false'' otherwise.<br />
<br />
==Example== <br />
This example creates a looping sound within a pizza shop. The pizza shop is in san fierro near pier 69<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function onResourceStart()<br />
local sound = playSound3D("sounds/song.mp3", 373.14, -125.21, 1001, true) <br />
end<br />
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onResourceStart)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client_audio_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GetDistanceBetweenPoints2D&diff=23867GetDistanceBetweenPoints2D2010-07-07T19:08:47Z<p>Sebassje: </p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
This function returns the distance between two 2 dimensional points using the pythagorean theorem.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">float getDistanceBetweenPoints2D ( float x1, float y1, float x2, float y2 )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''x1''': The X position of the first point<br />
* '''y1''': The Y position of the first point<br />
* '''x2''': The X position of the second point<br />
* '''y2''': The Y position of the second point<br />
<br />
===Returns===<br />
Returns a float containing the 2D distance between the two points. Returns ''false'' if invalid parameters are passed.<br />
<br />
==Example==<br />
<section name="Server and client" class="both" show="true"><br />
This example gets the distance between two vehicles, stored in variables ''vehicle1'' and ''vehicle2''.<br />
<syntaxhighlight lang="lua"><br />
vehicle1x, vehicle1y, vehicle1z = getElementPosition ( vehicle1 )<br />
vehicle2x, vehicle2y, vehicle2z = getElementPosition ( vehicle2 )<br />
outputChatBox ( "The map distance between vehicle1 and vehicle2 is ", getDistanceBetweenPoints2D ( vehicle1x, vehicle1y, vehicle2x, vehicle2y ) )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Utility functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GetDistanceBetweenPoints3D&diff=23866GetDistanceBetweenPoints3D2010-07-07T19:08:38Z<p>Sebassje: </p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
This function returns the distance between two 3 dimensional points using the pythagorean theorem.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">float getDistanceBetweenPoints3D ( float x1, float y1, float z1, float x2, float y2, float z2 )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''x1''': The X position of the first point<br />
* '''y1''': The Y position of the first point<br />
* '''z1''': The Z position of the first point<br />
* '''x2''': The X position of the second point<br />
* '''y2''': The Y position of the second point<br />
* '''z2''': The Z position of the second point<br />
<br />
===Returns===<br />
Returns a float containing the distance between the two points as a [[float]]. Returns ''false'' if an argument passed was invalid.<br />
<br />
==Example==<br />
<section name="Server and client" class="both" show="true"><br />
This example gets the distance between two vehicles and outputs it to the chat box.<br />
<syntaxhighlight lang="lua"><br />
vehicle1x, vehicle1y, vehicle1z = getElementPosition ( vehicle1 )<br />
vehicle2x, vehicle2y, vehicle2z = getElementPosition ( vehicle2 )<br />
outputChatBox ( "The distance between vehicle1 and vehicle2 is "..tostring(getDistanceBetweenPoints3D ( vehicle1x, vehicle1y, vehicle1z, vehicle2x,<br />
vehicle2y, vehicle2z )) )</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Utility functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=OnVehicleStartEnter&diff=23865OnVehicleStartEnter2010-07-07T16:28:36Z<p>Sebassje: /* Example */</p>
<hr />
<div>__NOTOC__ <br />
{{Server event}}<br />
This event is triggered when a player starts to enter a vehicle. This event can be used to cancel entry, if necessary.<br />
<br />
==Parameters==<br />
{{Deprecated_feature|3|1.0|<br />
<syntaxhighlight lang="lua"><br />
player enteringPlayer, int seat, player jacked<br />
</syntaxhighlight> <br />
}}<br />
{{New feature|3|1.0|<br />
<syntaxhighlight lang="lua"><br />
player enteringPlayer, int seat, player jacked, int door<br />
</syntaxhighlight>}}<br />
<br />
*'''enteringPlayer''': A player element representing the player who is starting to enter a vehicle<br />
*'''seat''': An integer representing the seat in which the player is entering<br />
*'''jacked''': A player element representing who is going to be jacked<br />
*{{New feature|3|1.0|'''door''': An integer of which door the player used (0-3). 0 is driver side door, 1 is front passenger, 2 is back left, 3 is back right.}}<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[vehicle]] in which a player began to enter.<br />
<br />
===Canceling===<br />
If this event is [[Event system #Canceling|canceled]], the player will not enter the vehicle.<br />
<br />
==Example== <br />
This example blocks a player out of a police vehicle if he is not a policeman.<br />
<syntaxhighlight lang="lua"><br />
policeVehicles = { [598]=true,[596]=true,[597]=true,[599]=true }<br />
policeSkins = { [280]=true,[281]=true,[282]=true,[283]=true,[284]=true,[285]=true,[286]=true }<br />
<br />
function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle<br />
if ( policeVehicles[getElementModel(source)] ) and ( not policeSkins[getElementModel(player)] ) then --if the vehicle is one of 4 police cars, and the skin is not a police skin<br />
cancelEvent()<br />
outputChatBox ( "Only policeman can enter police cars!", player ) --and tell the player why<br />
end<br />
end<br />
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) --add an event handler for onVehicleStartEnter<br />
</syntaxhighlight><br />
<br />
{{See also/Server event|Vehicle events}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=CloneElement&diff=23864CloneElement2010-07-07T14:26:04Z<p>Sebassje: /* Example */</p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
This function clones (creates an exact copy of) an already existing element. The root node, and player elements, cannot be cloned. If a player element is a child of an element that is cloned, it will be skipped, along with the elements that exist as a child to the player element.<br />
<br />
Players are not the only elements that cannot be cloned. This list also includes remoteclients, and console elements.<br />
<br />
The cloned element will be placed on the element tree as a child of the same parent as the cloned element.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
element cloneElement ( element theElement, [ float xPos = 0, float yPos = 0, float zPos = 0, bool cloneChildren = false ] ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The element that you wish to clone.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
* '''xPos''': A floating point number representing the X coordinate on the map.<br />
* '''yPos''': A floating point number representing the Y coordinate on the map.<br />
* '''zPos''': A floating point number representing the Z coordinate on the map.<br />
* '''cloneChildren''': A boolean value representing whether or not the element's children will be cloned.<br />
'''Note: if 'cloneChildren' is true, the position floats will be offsets from the cloned element's position.'''<br />
<br />
===Returns===<br />
Returns the handle of the new cloned element of the parent, ''false'' if invalid arguments were passed.<br />
<br />
==Example== <br />
This example clones the vehicle a player is in. This allows carrying over of the current state of the vehicle, including mods, for example.<br />
<syntaxhighlight lang="lua"><br />
function cloneVehicle ( thePlayer, commandName )<br />
local occupiedVehicle = getPedOccupiedVehicle ( thePlayer ) -- get the player's vehicle<br />
if occupiedVehicle then -- If the player is actually in a vehicle<br />
local x, y, z = getElementPosition ( occupiedVehicle ) -- get the vehicle's position<br />
local clone = cloneElement ( occupiedVehicle, x+5, y, z ) -- create a clone of the vehicle near it<br />
else<br />
outputChatBox ( "You can't clone a vehicle if you're not in a vehicle", thePlayer, 255, 0, 0 )<br />
end<br />
end<br />
addCommandHandler ( "clone", cloneVehicle )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Element functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=AddPedClothes&diff=23863AddPedClothes2010-07-07T14:22:43Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function is used to set the current clothes of a certain type on a [[ped]]. It can only be used on peds with the CJ skin (id 0).<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool addPedClothes ( ped thePed, string clothesTexture, string clothesModel, int clothesType )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''thePed''': The [[ped]] whose clothes you want to change.<br />
*'''clothesTexture''': A string determining the clothes texture that will be added. See the [[CJ Clothes|clothes catalog]].<br />
*'''clothesModel''': A string determining the clothes model that will be added. See the [[CJ Clothes|clothes catalog]].<br />
*'''clothesType''': A integer representing the clothes slot/type the clothes should be added to. See the [[CJ Clothes|clothes catalog]].<br />
<br />
==Returns==<br />
This function returns ''true'' if the clothes were successfully added to the ped, ''false'' otherwise.<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off.<br />
<syntaxhighlight lang="lua"><br />
function onEnterVehicle ( theVehicle, seat, jacked )<br />
if getElementModel ( theVehicle ) == 522 then -- if it's an nrg<br />
addPedClothes ( source, "moto", "moto", 16 ) -- add the helmet<br />
end<br />
end<br />
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onEnterVehicle )<br />
<br />
function onExitVehicle ( theVehicle, seat, jacked )<br />
if getElementModel ( theVehicle ) == 522 then -- if it's an nrg<br />
removePedClothes ( source, 16 ) -- remove the helmet<br />
end<br />
end<br />
addEventHandler ( "onPlayerVehicleExit", getRootElement(), onExitVehicle )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Ped functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=CanPlayerUseFunction&diff=23861CanPlayerUseFunction2010-07-06T17:28:48Z<p>Sebassje: </p>
<hr />
<div>{{Needs_Checking|Should the function still be string? --[[User:Talidan2|Talidan2]] 15:44, 15 July 2007 (CDT)<br>If this is supposed to take a console command, it'd better be renamed to canPlayerUseCommand. --[[User:Jbeta|jbeta]] 19:58, 11 September 2007 (CDT)<br>[[User:ChrML|ChrML]] This function doesn't work. It's not coded at all with the ACL system. Remove?}}<br />
__NOTOC__ <br />
{{Server function}}<br />
{{Deprecated}}<br />
This function can be used to check if the player can use a function, based on their current access level. Access levels for functions are stored in the server's config file. Use this if you want to prevent a player using a function unless they are logged in with enough rights.<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool canPlayerUseFunction ( player thePlayer, string functionName )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player who you consider is running the function.<br />
*'''functionName''' The name of the function which you want to check.<br />
<br />
===Returns===<br />
Returns ''true'' if the player specified can use the function specified, ''false'' otherwise.<br />
<br />
==Example== <br />
This example adds a console function called ''kill_player'' that can only be used by players with enough access rights. These access rights can be specified in the server's config file.<br />
<syntaxhighlight lang="lua"><br />
function adminKillPlayer ( source, commandName, killPlayerName )<br />
if ( canPlayerUseFunction ( source, "kill_player" ) ) then -- if the player can use the "kill_player" function<br />
local playerToKill = getPlayerFromNick ( killPlayerName ) -- look up the player to kill<br />
if ( playerToKill ~= false ) then -- check if we found him<br />
killPlayer ( playerToKill ) -- if so, kill him<br />
outputConsole ( killPlayerName .. " has been killed!", source ) -- and notify the admin<br />
else<br />
outputConsole ( "Couldn't find a player called '" .. killPlayerName .. "'", source ) -- otherwise tell him the player was not found<br />
end<br />
else<br />
outputConsole ( "You do not have access to this function!", source ) -- if he isn't allowed to use the function, tell him so<br />
end<br />
end<br />
addCommandHandler ( "kill_player", adminKillPlayer )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=SetPlayerNametagShowing&diff=23857SetPlayerNametagShowing2010-07-04T20:25:59Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
{{New feature|3|1.0|This function allows you to set whether a player's nametag visibility both clientside and serverside}}<br />
<br />
Use this to define whether the player's name tag is visible or invisible.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerNametagShowing ( player thePlayer, bool showing )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''thePlayer:''' Define the player whos tag visiblity status you want to change<br />
*'''showing:''' Use true or false to show/hide the tag<br />
<br />
===Returns===<br />
Returns ''true'' if successful, ''false'' otherwise<br />
<br />
==Example== <br />
This script will turn off player tags for everyone<br />
<syntaxhighlight lang="lua"><br />
root = getRootElement ( )<br />
-- Store all the players in the server into a table<br />
players = getElementsByType ( "player" )<br />
<br />
function ResourceStart ( name, root )<br />
for k,v in ipairs ( players ) do -- for all the players in the table<br />
setPlayerNametagShowing ( v, false ) -- turn off their nametag<br />
end<br />
end<br />
addEventHandler ( "onResourceStart", root, ResourceStart )<br />
<br />
function PlayerJoin ()<br />
-- Whoever joins the server should also have their nametags deactivated<br />
setPlayerNametagShowing ( source, false )<br />
end<br />
addEventHandler ( "onPlayerJoin", root, PlayerJoin )<br />
<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GetPedTotalAmmo&diff=23819GetPedTotalAmmo2010-07-01T11:18:31Z<p>Sebassje: /* Example */</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function returns an integer that contains the total ammo in a specified [[ped]]'s weapon. See [[weapon|Weapon Info]]<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
int getPedTotalAmmo ( ped thePed, [ int weaponSlot = current ] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''thePed''': The [[ped]] whose ammo you want to check.<br />
<br />
===Optional Arguments===<br />
*'''weaponSlot''': an integer representing the weapon slot (set to the ped's current slot if not given)<br />
<br />
===Returns===<br />
Returns an [[int]] containing the total amount of ammo for the specified ped's weapon, or 0 if the ped specified is invalid.<br />
<br />
==Example==<br />
This example outputs the total amount of ammo a player called ''Someguy'' has for his weapon.<br />
<syntaxhighlight lang="lua"><br />
-- Find the player called 'Someguy'<br />
myPlayer = getPlayerFromName ( "Someguy" )<br />
-- If a player called 'Someguy' was found then<br />
if ( myPlayer ) then<br />
-- Retrieve the total amount of ammo for that player, and store it in a variable called 'ammo'<br />
ammo = getPedTotalAmmo ( myPlayer )<br />
-- Tell all the players how much ammo 'Someguy' has<br />
outputChatBox ( "Someguy's current total ammo: " .. ammo .. "." )<br />
end<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_ped_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=SetMinuteDuration&diff=23818SetMinuteDuration2010-06-29T12:19:03Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
Sets the real-world duration of an ingame minute. The GTA default is 1000.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setMinuteDuration ( int milliseconds )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''milliseconds''': the new duration of an ingame minute<br />
<br />
===Returns===<br />
Returns ''true'' if successful, ''false'' otherwise.<br />
<br />
==Example==<br />
This example will make the ingame time correspond to the real-world time of the server.<br />
<section class="server" name="Server" show="true"><br />
<syntaxhighlight lang="lua"><br />
function resourceStart()<br />
local realtime = getRealTime()<br />
<br />
setTime(realtime.hour, realtime.minute)<br />
setMinuteDuration(60000)<br />
end<br />
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), resourceStart)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{World_functions}}<br />
<br />
[[ru:setMinuteDuration]]</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GetElementsByType&diff=23809GetElementsByType2010-06-26T13:31:15Z<p>Sebassje: </p>
<hr />
<div>{{Server_client_function}}<br />
__NOTOC__ <br />
This function is used to retrieve a list of all elements of the specified type. This can be useful, as it disregards ''where'' in the element tree it is. It can be used with either the built in types (listed below) or with any custom type used in a .map file. For example, if there is an element of type "flag" (e.g. <flag />) in the .map file, the using "flag" as the type argument would find it.<br />
<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
table getElementsByType ( string theType, [ element startat=getRootElement() ] ) <br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
table getElementsByType ( string theType, [ element startat=getRootElement(), bool streamedIn=false ] ) <br />
</syntaxhighlight><br />
</section><br />
<br />
===Required Arguments=== <br />
*'''theType:''' The type of element you want a list of. This is the same as the tag name in the .map file, so this can be used with a custom element type if desired. Built in types are:<br />
**'''"player":''' A player connected to the server<br />
**'''"ped":''' A ped<br />
**'''"water":''' A water polygon<br />
**'''"sound":''' A playing sound<br />
**'''"vehicle":''' A vehicle<br />
**'''"object":''' An object<br />
**'''"pickup":''' A pickup<br />
**'''"marker":''' A marker<br />
**'''"colshape":''' A collision shape<br />
**'''"blip":''' A blip<br />
**'''"radararea":''' A radar area<br />
**'''"team":''' A team<br />
**'''"spawnpoint":''' A spawnpoint<br />
**'''"remoteclient":''' A remote client connected to the server<br />
**'''"console":''' The server Console<br />
<br />
==Optional Arguments==<br />
{{OptionalArg}}<br />
*'''startat:''' The [[element]] the search should start at. Children of this element are searched, siblings or parents will not be found. By default, this is the root element which should suit most uses.<br />
<br />
<section name="Client" class="client" show="true"><br />
*'''streamedIn:''' If true, function will only return elements that are streamed in.<br />
</section><br />
<br />
===Returns===<br />
Returns a ''table'' containing all the elements of the specified type. Returns an empty ''table'' if there are no elements of the specified type. Returns ''false'' if the string specified is invalid (or not a string).<br />
<br />
==Example== <br />
'''Example 1:''' This example retrieves a table of the players in the server, and checks whether or not each one is in a vehicle:<br />
<syntaxhighlight lang="lua"><br />
local players = getElementsByType ( "player" ) -- get a table of all the players in the server<br />
for theKey,thePlayer in ipairs(players) do -- use a generic for loop to step through each player<br />
if ( isPlayerInVehicle ( thePlayer ) ) then -- if the player is in a vehicle, announce it<br />
outputChatBox ( getPlayerName ( thePlayer ) .. " is in a vehicle" )<br />
else -- if the player isn't in a vehicle, announce that he/she is on foot<br />
outputChatBox ( getPlayerName ( thePlayer ) .. " is on foot" )<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
'''Example 2:''' This shows how you could create a new element to describe a gas station:<br />
<syntaxhighlight lang="lua"><br />
function createGasStations(below)<br />
local gasstations = getElementsByType ( "gasstation", below ) -- get a table of all the gas station elements in the element tree<br />
for theKey,theGasStation in ipairs(gasstations) do <br />
local x = getElementData(theGasStation, "posX") -- get the position of the element<br />
local y = getElementData(theGasStation, "posY")<br />
local z = getElementData(theGasStation, "posZ")<br />
setElementParent(createColSphere(x, y, z, 10), theGasStation) -- create a colshape for the gas station at the gas station's position<br />
addEventHandler("onColShapeHit", theGasStation, giveGas) -- when the player hits<br />
end<br />
end<br />
<br />
function mapLoad()<br />
createGasStations(source) -- create gas stations for the map that's just loaded<br />
end<br />
addEventHandler("onResourceStart", getRootElement(), mapLoad)<br />
<br />
function giveGas(hittingElement)<br />
local theGasStation = source<br />
if getElementType(hittingElement) == "vehicle" then<br />
local gas_left = getElementData(theGasStation, "amount")<br />
local gas_speed = getElementData(theGasStation, "speed")<br />
if gas_left > 0 then<br />
<br />
local gas_to_remove = gas_speed <br />
if gas_left < gas_speed then<br />
gas_to_remove = gas_left<br />
<br />
local current_vehicle_gas = getElementData(hittingElement, "gas")<br />
current_vehicle_gas = current_vehicle_gas + gas_to_remove<br />
gas_left = gas_left - gas_to_remove<br />
<br />
setElementData(hittingElement, "gas", current_vehicle_gas)<br />
setElementData(theGasStation, "amount", gas_left)<br />
else<br />
outputChatBox("Pump is out of gas!")<br />
end<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Element_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=Template:Element_functions&diff=23769Template:Element functions2010-06-25T14:53:46Z<p>Sebassje: </p>
<hr />
<div>*[[clearElementVisibleTo]]<br />
*[[cloneElement]]<br />
*[[createElement]]<br />
*[[destroyElement]]<br />
*[[getAllElementData]]<br />
*[[getAttachedElements]]<br />
*[[getElementAlpha]]<br />
*[[getElementAttachedTo]]<br />
*[[getElementByID]]<br />
*[[getElementByIndex]]<br />
*[[getElementChild]]<br />
*[[getElementChildren]]<br />
*[[getElementChildrenCount]]<br />
*[[getElementColShape]]<br />
*[[getElementData]]<br />
*[[getElementDimension]]<br />
*[[getElementHealth]]<br />
*[[getElementID]]<br />
*[[getElementInterior]]<br />
*[[getElementParent]]<br />
*[[getElementPosition]]<br />
{{New feature|3.0004|1.0.4|<br />
*[[getElementRotation]]<br />
}}<br />
*[[getElementsByType]]<br />
*[[getElementsWithinColShape]]<br />
*[[getElementType]]<br />
*[[getElementVelocity]]<br />
*[[getElementZoneName]]<br />
*[[getRootElement]]<br />
*[[isElement]]<br />
*[[isElementAttached]]<br />
{{New feature|3.0004|1.0.4|<br />
*[[isElementDoubleSided]]<br />
}}<br />
*[[isElementVisibleTo]]<br />
*[[isElementWithinColShape]]<br />
*[[removeElementData]]<br />
*[[setElementAlpha]]<br />
*[[setElementData]]<br />
{{New feature|3.0004|1.0.4|<br />
*[[setElementDoubleSided]]<br />
}}<br />
*[[setElementDimension]]<br />
*[[setElementHealth]]<br />
*[[setElementID]]<br />
*[[setElementInterior]]<br />
*[[setElementParent]]<br />
*[[setElementPosition]]<br />
{{New feature|3.0004|1.0.4|<br />
*[[setElementSyncer]]<br />
*[[setElementRotation]]<br />
}}<br />
*[[setElementVelocity]]<br />
*[[setElementVisibleTo]]<br />
{{New feature|3|1.0|<br />
*[[attachElements]]<br />
*[[detachElements]]<br />
*[[getElementModel]]<br />
*[[getElementSyncer]]<br />
*[[isElementInWater]]<br />
*[[setElementAttachedOffsets]]<br />
*[[setElementModel]]<br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
*[[attachElementToElement]]<br />
*[[detachElementFromElement]]<br />
}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=SetElementRotation&diff=23768SetElementRotation2010-06-25T14:53:08Z<p>Sebassje: </p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__ <br />
Sets the rotation of elements according to the world (does not work with players that are on the ground).<br />
<br />
'''Only clientside before 1.0.4'''<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setElementRotation ( element theElement, float rotX, float rotY, float rotZ ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The element whose rotation will be set<br />
*'''rotX:''' The element's rotation around the x axis in degrees<br />
*'''rotY:''' The element's rotation around the y axis in degrees<br />
*'''rotZ:''' The element's rotation around the z axis in degrees<br />
<br />
===Returns===<br />
Returns ''true'' if the element rotation was successfully set and ''false'' otherwise.<br />
<br />
==Example== <br />
When a player used the command "turn" and they are the driver of a vehicle the vehicle will rotate 10 degrees clockwise<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
local localPlayer = getLocalPlayer()<br />
function carRotate( )<br />
if isPedInVehicle(localPlayer) then -- if the local client is in a vehicle<br />
localVehicle = getPedOccupiedVehicle(localPlayer)<br />
if getVehicleController(localVehicle) == localPlayer then -- if the local client is the controller (driver) of the vehicle<br />
local rotX, rotY, rotZ = getElementRotation(localVehicle) -- get the local client's vehicle rotation<br />
setElementRotation(localVehicle,rotX,rotY,rotZ+10) -- turn the vehicle 10 degrees clockwise<br />
end<br />
end<br />
end<br />
addCommandHandler ( "turn", carRotate )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client_element_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=IsElement&diff=23767IsElement2010-06-25T11:41:33Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function checks if a value is an [[element]] or not.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool isElement ( var theValue )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''theValue''': The value that we want to check.<br />
<br />
===Returns===<br />
Returns ''true'' if the passed value is an element, ''false'' otherwise.<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This serverside function kills a player when it's passed his name or his element.<br />
<syntaxhighlight lang="lua"><br />
function killPlayer2 ( argument )<br />
-- if the argument is an element, and also a player,<br />
if isElement( argument ) and getElementType( argument ) == "player" then<br />
-- kill him<br />
killPlayer ( argument )<br />
<br />
-- if it isn't an element, but a string, it could be a name<br />
elseif type ( argument ) == "string" then<br />
-- retrieve the player with that name<br />
local playerElement = getPlayerFromNick( argument )<br />
-- if a player with such a name exists,<br />
if playerElement then<br />
-- kill him<br />
killPlayer ( playerElement )<br />
end<br />
end<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Element functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=SetVehicleDoorsUndamageable&diff=23766SetVehicleDoorsUndamageable2010-06-25T11:41:04Z<p>Sebassje: </p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function makes a vehicle's doors undamageable, so they won't fall off when they're hit. Note that the vehicle '''has''' to be locked using [[setVehicleLocked]] for this setting to have any effect.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool setVehicleDoorsUndamageable ( vehicle theVehicle, bool state )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments===<br />
*'''theVehicle:''' The [[vehicle]] of which you wish to set the car door damageability.<br />
*'''state:''' A boolean denoting whether the vehicle's doors are undamageable (''true'') or damageable (''false'').<br />
<br />
===Returns===<br />
Returns ''true'' if the damageability state was successfully changed, ''false'' if invalid arguments were passed.<br />
<br />
==Example==<br />
Here you can disable all vehicles doors damage with /nodamage, and enable it with /adddamage.<br />
<syntaxhighlight lang="lua"><br />
function doorsLikeGod()<br />
for i, car in ipairs( getElementsByType ("vehicle") ) do<br />
setVehicleDoorsUndamageable ( car, true )<br />
end<br />
outputChatBox("All vehicles doors is not damageable")<br />
end<br />
addCommandHandler("nodamage", doorsLikeGod)<br />
<br />
function doorsNotLikeGod()<br />
for i, car in ipairs( getElementsByType ("vehicle") ) do<br />
setVehicleDoorsUndamageable ( car, false )<br />
end<br />
outputChatBox("Now everyone can kick vehicles doors and throw them away.")<br />
end<br />
addCommandHandler("adddamage", doorsNotLikeGod)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Vehicle functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GetPedWeapon&diff=23765GetPedWeapon2010-06-25T10:50:56Z<p>Sebassje: /* Example */</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function tells you which weapon type is in a certain weapon slot of a ped. See [[weapon|Weapon Info]]<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
int getPedWeapon ( ped thePed, [ int weaponSlot = current ] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''thePed''': the [[ped]] you want to get the weapon type from.<br />
<br />
===Optional Arguments===<br />
*'''weaponSlot''': an integer representing the weapon slot (set to the ped's current slot if not given).<br />
<br />
===Returns===<br />
Returns an [[int]] indicating the type of the weapon the ped has in the specified slot. If the slot is empty, it returns 0.<br />
<br />
It should be noted that if a ped runs out of ammo for a weapon, it will still return the ID of that weapon in the slot (even if it appears as if the ped does not have a weapon at all), though [[getPedTotalAmmo]] will return '''0'''. Therefore, [[getPedTotalAmmo]] should be used in conjunction with [[getPedWeapon]] in order to check if a ped has a weapon.<br />
<br />
==Example==<br />
This serverside example will display a player's current weapon type. In this case, it is hard coded to use the player called ''someguy''.<br />
<syntaxhighlight lang="lua"><br />
-- Find a player called someguy and find his current weapon id.<br />
local weaponType = getPedWeapon ( getPlayerFromName ( "someguy" ) )<br />
-- If a weapon type was returned then<br />
if ( weaponType ) then<br />
outputChatBox ( "someguy's current Weapon-type: " .. weaponType .. "." ) -- Display the weapon type in the chat box<br />
end<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_ped_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=Template:Element_functions&diff=23755Template:Element functions2010-06-24T18:17:29Z<p>Sebassje: </p>
<hr />
<div>*[[clearElementVisibleTo]]<br />
*[[cloneElement]]<br />
*[[createElement]]<br />
*[[destroyElement]]<br />
*[[getAllElementData]]<br />
*[[getAttachedElements]]<br />
*[[getElementAlpha]]<br />
*[[getElementAttachedTo]]<br />
*[[getElementByID]]<br />
*[[getElementByIndex]]<br />
*[[getElementChild]]<br />
*[[getElementChildren]]<br />
*[[getElementChildrenCount]]<br />
*[[getElementColShape]]<br />
*[[getElementData]]<br />
*[[getElementDimension]]<br />
*[[getElementHealth]]<br />
*[[getElementID]]<br />
*[[getElementInterior]]<br />
*[[getElementParent]]<br />
*[[getElementPosition]]<br />
{{New feature|3.0004|1.0.4|<br />
*[[getElementRotation]]<br />
}}<br />
*[[getElementsByType]]<br />
*[[getElementsWithinColShape]]<br />
*[[getElementType]]<br />
*[[getElementVelocity]]<br />
*[[getElementZoneName]]<br />
*[[getRootElement]]<br />
*[[isElement]]<br />
*[[isElementAttached]]<br />
{{New feature|3.0004|1.0.4|<br />
*[[isElementDoubleSided]]<br />
}}<br />
*[[isElementVisibleTo]]<br />
*[[isElementWithinColShape]]<br />
*[[removeElementData]]<br />
*[[setElementAlpha]]<br />
*[[setElementData]]<br />
{{New feature|3.0004|1.0.4|<br />
*[[setElementDoubleSided]]<br />
}}<br />
*[[setElementDimension]]<br />
*[[setElementHealth]]<br />
*[[setElementID]]<br />
*[[setElementInterior]]<br />
*[[setElementParent]]<br />
*[[setElementPosition]]<br />
{{New feature|3.0004|1.0.4|<br />
*[[setElementSyncer]]<br />
}}<br />
*[[setElementVelocity]]<br />
*[[setElementVisibleTo]]<br />
{{New feature|3|1.0|<br />
*[[attachElements]]<br />
*[[detachElements]]<br />
*[[getElementModel]]<br />
*[[getElementSyncer]]<br />
*[[isElementInWater]]<br />
*[[setElementAttachedOffsets]]<br />
*[[setElementModel]]<br />
}}<br />
{{Deprecated_feature|3|1.0|<br />
*[[attachElementToElement]]<br />
*[[detachElementFromElement]]<br />
}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=GetElementRotation&diff=23754GetElementRotation2010-06-24T18:16:30Z<p>Sebassje: </p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__ <br />
Retrieve the rotation of elements.<br />
<br />
'''Only clientside before 1.0.4'''<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
float float float getElementRotation ( element theElement ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The element whose rotation will be retrieved<br />
<br />
===Returns===<br />
Returns three ''float''s if element exists and is a valid element, ''false'' in if it's invalid.<br />
<br />
==Example== <br />
If a player points at a player element with a gun, its rotation will appear in the chat box.<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function onPlayerTargeted ( targetElem )<br />
if ( isElement(targetElem) and getElementType (targetElem) == "player" ) then<br />
local x,y,z = getElementRotation ( targetElem )<br />
outputChatBox ( "Target player rotation: " .. x .. " " .. y .. " " .. z )<br />
end<br />
end<br />
addEventHandler ( "onClientPlayerTarget", getRootElement(), onPlayerTargeted )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client_element_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=EngineUnloadModel&diff=23753EngineUnloadModel2010-06-24T17:27:13Z<p>Sebassje: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__ <br />
{{Deprecated}}<br />
This function "unloads" a custom model identified by a model id, and reloads the original GTA model.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool engineUnloadModel ( int model_id ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''model_id:''' The model id used to identify the model that is being reloaded.<br />
<br />
===Returns===<br />
Returns ''true'' if the custom model was unloaded succesfully, ''false'' otherwise.<br />
<br />
==Example== <br />
This example loads a combination of custom DFF, TXD and COL files to replace an in-game model of a set of floors and unloads it again.<br />
<syntaxhighlight lang="lua"><br />
outputChatBox ( "> loading floor objects" )<br />
txd_floors = engineLoadTXD ( "models/office_floors.txd" )<br />
engineImportTXD ( txd_floors, 3781 )<br />
col_floors = engineLoadCOL ( "models/office_floors.col" )<br />
dff_floors = engineLoadDFF ( "models/office_floors.dff", 0 )<br />
engineImportCOL ( col_floors, 3781 )<br />
engineReplaceObjectModel ( dff_floors, 3781 )<br />
<br />
-- do your logic<br />
<br />
engineUnloadModel ( 3781 )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Engine_functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=AddVehicleUpgrade&diff=23752AddVehicleUpgrade2010-06-24T11:07:31Z<p>Sebassje: /* Example */</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function adds an upgrade to an existing vehicle, eg: nos, hyrdraulics.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool addVehicleUpgrade ( vehicle theVehicle, int upgrade )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''theVehicle''': The [[element]] representing the [[vehicle]] you wish to add the upgrade to.<br />
*'''upgrade''': The id of the upgrade you wish to add. (1000 to 1193), ''see [[Vehicle Upgrades]]''<br />
<br />
==Returns==<br />
Returns ''true'' if the upgrade was successfully added to the vehicle, otherwise ''false''.<br />
<br />
==Example==<br />
<section name="Example 1" class="server" show="true"><br />
This serverside function allows the user to get an upgrade by typing a command:<br />
<syntaxhighlight lang="lua"><br />
-- define the handler function for our command<br />
function consoleAddUpgrade ( thePlayer, commandName, id )<br />
-- make sure the player is in a vehicle<br />
if ( isPedInVehicle ( thePlayer ) ) then<br />
-- convert the given ID from a string to a number<br />
local id = tonumber ( id )<br />
-- get the player's vehicle<br />
local theVehicle = getPedOccupiedVehicle ( thePlayer )<br />
-- add the requested upgrade to the vehicle<br />
local success = addVehicleUpgrade ( theVehicle, id )<br />
-- inform the player of whether the upgrade was added successfully<br />
if ( success ) then<br />
outputConsole ( getVehicleUpgradeSlotName ( id ) .. " upgrade added.", thePlayer )<br />
else<br />
outputConsole ( "Failed to add upgrade.", thePlayer )<br />
end<br />
else<br />
outputConsole ( "You must be in a vehicle!", thePlayer )<br />
end<br />
end<br />
-- add the function as a handler for the "addupgrade" command<br />
addCommandHandler ( "addupgrade", consoleAddUpgrade )<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Example 2" class="client" show="true"><br />
This client-side script gives vehicles a nitro upgrade whenever they pass through a certain collision shape:<br />
<syntaxhighlight lang="lua"><br />
-- create a collision shape<br />
local nitroColShape = createColSphere ( 1337, 100, 12, 2 )<br />
<br />
-- attach the collision shape to an 'onClientColShapeHit' event<br />
function onNitroColShapeHit ( hitElement, matchingDimension )<br />
if ( getElementType ( hitElement ) == "vehicle" ) then<br />
-- add a nitro upgrade if the element that hit the colshape is a vehicle<br />
addVehicleUpgrade ( hitElement, 1010 )<br />
end<br />
end<br />
addEventHandler ( "onClientColShapeHit", nitroColShape, onNitroColShapeHit )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Vehicle functions}}</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=User:Sebassje&diff=23751User:Sebassje2010-06-24T10:51:58Z<p>Sebassje: /* GreenHood Roleplay v1.1 (TODO) */</p>
<hr />
<div>__NOTOC__<br />
<br />
==Module(s)==<br />
* Socket module: [[Modules/Sockets | click here]]<br />
<br />
<br />
==TODO==<br />
* Finish FlightZ Simulator Deluxe v2.0 (Work in progress)<br />
* GreenHood Roleplay v1.1 (Work in progress)<br />
<br />
<br />
==GreenHood Roleplay v1.1 (TODO) (Developer: x86)==<br />
* <strike>(Admin) Make the world tab dynamic (weather, anticheat etc).</strike><br />
* (Admin) Ban/Options system.<br />
* Car system.<br />
* House system.<br />
* Fuel system.<br />
* Weapon system.<br />
* Item system.<br />
* Some jobs.<br />
* <strike>Dynamic anticheat system.</strike><br />
* Fix email activation problem with Hotmail.<br />
* Last betatest.<br />
* Fix minors (?)<br />
* Release.<br />
<br />
==GreenHood FlightZ Simulator Deluxe v2.0 Details==<br />
* <strike>Complete code rewrite.</strike><br />
* New plane models.<br />
* First place view.<br />
* Flying peds.<br />
* Tutorials.<br />
* ATC (Tower communication).<br />
* Fly with other people in a plane.<br />
* And much more!</div>Sebassjehttps://wiki.multitheftauto.com/index.php?title=OnClientRender&diff=23750OnClientRender2010-06-24T10:41:44Z<p>Sebassje: /* Incomplete event */</p>
<hr />
<div>__NOTOC__<br />
{{Client event}} <br />
This event is triggered every time GTA renders a new frame. It is required for the DirectX drawing functions, and also useful for other clientside operations that have to be applied repeatedly with very short time differences between them.<br />
<br />
==Parameters==<br />
''None''<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the client's [[root element]].<br />
<br />
==Example==<br />
[[Category:Needs Example]]<br />
<br />
==See Also==<br />
===Other client events===<br />
{{Client_other_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}</div>Sebassje