https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=JavadOmidi&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-28T15:11:23ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=AddEventHandler&diff=64920AddEventHandler2020-01-22T08:13:23Z<p>JavadOmidi: </p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}} <br />
{{Important Note|Do '''NOT''' use the same name for your handler function as the event name, as this can lead to confusion if multiple handler functions are used}}<br />
This function will add an [[event]] handler. An event handler is a function that will be called when the event it's attached to is triggered. See [[event system]] for more information on how the event system works.<br />
<br />
Event handlers are functions that are called when a particular event happens. Each event specifies a specific set of variables that are passed to the event handler and can be read by your function. The following global variables are available for use in handler functions:<br />
*'''source''': the element that triggered the event<br />
*'''this''': the element that the event handler is attached to<br />
*'''sourceResource''': the resource that triggered the event<br />
*'''sourceResourceRoot''': the root element of the resource that triggered the event<br />
*'''client''': the client that triggered the event using [[triggerServerEvent]]. Not set if the event was not triggered from a client.<br />
{{New_feature|3|1.0|<br />
*'''eventName''': the name of the event which triggered the handler function.<br />
}}<br />
<br />
It is important to remember that events pass up and down the [[element tree]]. An event triggered on the root element is triggered on every element in the tree. An event triggered on any other element is triggered on its ancestors (its parent element and its parent's parent etc) and its children, grandchildren and great-grandchildren. You can use the ''getPropagated'' argument to specify if you wish your handler to receive events that have propagated up or down the tree.<br />
<br />
The order in which event handlers are triggered is undefined, you should not rely on one event handler being executed before another.<br />
{{Note|See [[Script security]] for tips on preventing cheaters when using events and element data}}<br />
{{Note|See [[Event_Source_Element|Event Source Element]] for a descriptive visualization of the event system handling an event trigger.}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool addEventHandler ( string eventName, element attachedTo, function handlerFunction [, bool getPropagated = true, string priority = "normal" ] ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''eventName:''' The name of the [[event]] you want to attach the handler function to.<br />
*'''attachedTo:''' The [[element]] you wish to attach the handler to. The handler will only be called when the event it is attached to is triggered for this element, or one of its children. Often, this can be the root element (meaning the handler will be called when the event is triggered for ''any'' element).<br />
*'''handlerFunction:''' The handler function you wish to call when the event is triggered. This function will be passed all of the event's parameters as arguments, but it isn't required that it takes all of them.<br />
<br />
===Optional Arguments===<br />
*'''getPropagated:''' A boolean representing whether the handler will be triggered if the event was propagated down or up the [[element tree]] (starting from the source), and not triggered directly on attachedTo (that is, handlers attached with this argument set to ''false'' will only be triggered if ''source == this'')<br />
you need to put getPropagated false in the gui events.<br />
{{New_feature|3.0131|1.3.1|<br />
*'''priority :''' A string representing the trigger order priority relative to other event handlers of the same name. Possible values are:<br />
**'''"high"'''<br />
**'''"normal"'''<br />
**'''"low"'''<br />
''It is also possible to add finer priority control by appending a positive or negative number to the priority string. For example (in priority order for reference): "high+4" "high" "high-1" "normal-6" "normal-7" "low+1" "low" "low-1"''<br />
{{Important Note|Anything bound to a specific element will be run before other handlers that are bound to something higher in the element tree (like root) This means that "high+10" bound to root '''won't''' trigger before "normal" bound directly to an element.}}<br />
}}<br />
<br />
===Returns===<br />
Returns ''true'' if the event handler was attached successfully. Returns ''false'' if the specified event could not be found or any parameters were invalid.<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This serverside example sends a message to everyone in the server when a player spawns.<br />
<syntaxhighlight lang="lua"><br />
-- define our handler function<br />
function onPlayerSpawnHandler ( )<br />
-- get the player's name, source is the player because he was spawned<br />
local playerName = getPlayerName( source )<br />
-- output in the chat box that they've spawned<br />
outputChatBox ( playerName .. " has spawned!" )<br />
end<br />
<br />
addEventHandler( "onPlayerSpawn", root, onPlayerSpawnHandler ) -- root is a predefined global variable for getRootElement()<br />
</syntaxhighlight><br />
</section><br />
<br />
==Changelog==<br />
{{ChangelogHeader}}<br />
{{ChangelogItem|1.3.0-9.03795|Added priority argument}}<br />
<br />
==See Also==<br />
{{Event_functions}}<br />
[[ru:addEventHandler]]</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=GetZoneName&diff=64852GetZoneName2020-01-01T15:57:13Z<p>JavadOmidi: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function allows you to retrieve the zone name of a certain location.<br />
<br />
''Note that between versions 1.1 and 1.3.0-3749 the default value for '''citiesonly''' was incorrect when called the client side. The work around for clients before 1.3.0-3749 is to always declare a value for '''citiesonly'''. Server side getZoneName was unaffected.'' <br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
string getZoneName ( float x, float y, float z, [bool citiesonly=false] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
*'''x:''' The X axis position<br />
*'''y:''' The Y axis position<br />
*'''z:''' The Z axis position<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
* '''citiesonly''': An optional argument to choose if you want to return the city name (eg Las Venturas)<br />
<br />
===Returns===<br />
Returns the string of the zone name<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
'''Example 1:''' This example returns the player's City & Zone.<br />
<syntaxhighlight lang="lua"><br />
function outputPlayerZone(thePlayer)<br />
-- get the player position<br />
x, y, z = getElementPosition(thePlayer)<br />
-- get the player zone<br />
zone = getZoneName(x, y, z)<br />
-- get the player city (citiesonly as true)<br />
city = getZoneName(x, y, z, true)<br />
-- output to local player's chatbox<br />
outputChatBox("City: ".. city .." / Zone: ".. zone, thePlayer)<br />
end<br />
addCommandHandler("getloc", outputPlayerZone)<br />
</syntaxhighlight><br />
<br />
'''Example 2:''' This example will tell you what zone a specified player is in when the "getloc" console command is used.<br />
<syntaxhighlight lang="lua"><br />
function scriptGetLoc ( source, command, playername ) --when getloc is called<br />
local thePlayer = getPlayerFromName ( playername ) --get the player from nickname<br />
if ( thePlayer ~= false ) then --if there is a player from the nickname<br />
local x, y, z = getElementPosition ( thePlayer )<br />
local location = getZoneName ( x, y, z )<br />
local city = getZoneName ( x, y, z, true )<br />
outputChatBox ( playername .. " is at " .. location .. " (" .. city .. ")", source ) --announce his zone<br />
else outputChatBox ( "Player does not exist" )<br />
end<br />
end<br />
addCommandHandler( "getloc", scriptGetLoc ) -- add a command "getloc" which initiates "scriptGetloc" function<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{World functions}}<br />
<br />
[[ru:getZoneName]]</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=DgsSetSystemFont&diff=64832DgsSetSystemFont2019-12-27T01:21:34Z<p>JavadOmidi: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function creates a dx font element as default font stored in dgs.<br />
<br />
Successful font creation is not guaranteed, and may fail due to hardware or memory limitations.<br />
<br />
'''This function will copy the font file into dgs folder and then load it'''<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
element dgsSetSystemFont ( string filepath [, int size=9, bool bold=false, string quality="proof" ] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''filepath:''' the name of the file containing the font. Or built-in fonts are available (see here [[Standard_DGS_Font_Names]]):<br />
**default<br />
**default-bold<br />
**clear<br />
**arial<br />
**sans<br />
**pricedown<br />
**bankgothic<br />
**diploma<br />
**beckett<br />
<br />
===Optional Arguments===<br />
*'''size:''' size of the font<br />
*'''bold:''' flag to indicate if the font should be bold<br />
*'''quality:''' the font quality<br />
**"default": not the actual default<br />
**"draft"<br />
**"proof": the default<br />
**"nonantialiased"<br />
**"antialiased"<br />
**"cleartype"<br />
**"cleartype_natural"<br />
<br />
===Returns===<br />
Returns a true if successful, ''false'' otherwise.<br />
<br />
==Example== <br />
<syntaxhighlight lang="lua"><br />
DGS = exports.dgs<br />
<br />
DGS:dgsSetSystemFont("example.ttf")<br />
</syntaxhighlight><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
DGS = exports.dgs<br />
<br />
DGS:dgsSetSystemFont("default-bold")<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{DGSFUNCTIONS}}</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=DgsSetFont&diff=64831DgsSetFont2019-12-27T01:19:41Z<p>JavadOmidi: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function sets the font of a dgs element to be used when drawing text. '''a dgs font can be affected by [[dgsSetSystemFont]]'''<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool dgsSetFont( element dgsElement, mixed font )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments===<br />
*'''dgsElement:''' The DGS element you wish to change the font of<br />
*'''font:''' Either a custom dx font element or the name of a built-in dx font (see here [[Standard_DGS_Font_Names]])<br />
<br />
===Returns===<br />
Returns ''true'' if the font has been successfully set on the dgs element, ''false'' otherwise.<br />
<br />
==Example== <br />
This example sets and gets the font of a pre-made gui element and outputs it to chat box.<br />
<syntaxhighlight lang="lua"><br />
DGS = exports.dgs<br />
-- We create a dummy gui label to get text of<br />
local dummyGUIElement = DGS:dgsCreateLabel ( 0.45, 0.48, 0.10, 0.04, "Hello world", true )<br />
DGS:dgsSetFont ( dummyGUIElement, "clear" )<br />
-- Output the font of the label to chat box<br />
outputChatBox ( "Font used in the DGS label: " .. DGS:dgsGetFont ( dummyGuiElement ) )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{DGSFUNCTIONS}}</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=DgsSetFont&diff=64830DgsSetFont2019-12-27T01:19:09Z<p>JavadOmidi: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function sets the font of a dgs element to be used when drawing text. '''a dgs font an be affected by [[dgsSetSystemFont]]'''<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool dgsSetFont( element dgsElement, mixed font )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments===<br />
*'''dgsElement:''' The DGS element you wish to change the font of<br />
*'''font:''' Either a custom dx font element or the name of a built-in dx font (see here [[Standard_DGS_Font_Names]])<br />
<br />
===Returns===<br />
Returns ''true'' if the font has been successfully set on the dgs element, ''false'' otherwise.<br />
<br />
==Example== <br />
This example sets and gets the font of a pre-made gui element and outputs it to chat box.<br />
<syntaxhighlight lang="lua"><br />
DGS = exports.dgs<br />
-- We create a dummy gui label to get text of<br />
local dummyGUIElement = DGS:dgsCreateLabel ( 0.45, 0.48, 0.10, 0.04, "Hello world", true )<br />
DGS:dgsSetFont ( dummyGUIElement, "clear" )<br />
-- Output the font of the label to chat box<br />
outputChatBox ( "Font used in the DGS label: " .. DGS:dgsGetFont ( dummyGuiElement ) )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{DGSFUNCTIONS}}</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=DgsSetFont&diff=64829DgsSetFont2019-12-27T01:17:42Z<p>JavadOmidi: /* Required Arguments */</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function sets the font of a dgs element to be used when drawing text.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool dgsSetFont( element dgsElement, mixed font )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments===<br />
*'''dgsElement:''' The DGS element you wish to change the font of<br />
*'''font:''' Either a custom dx font element or the name of a built-in dx font (see here [[Standard_DGS_Font_Names]]) (Can be affected by [[dgsSetSystemFont]]).<br />
<br />
===Returns===<br />
Returns ''true'' if the font has been successfully set on the dgs element, ''false'' otherwise.<br />
<br />
==Example== <br />
This example sets and gets the font of a pre-made gui element and outputs it to chat box.<br />
<syntaxhighlight lang="lua"><br />
DGS = exports.dgs<br />
-- We create a dummy gui label to get text of<br />
local dummyGUIElement = DGS:dgsCreateLabel ( 0.45, 0.48, 0.10, 0.04, "Hello world", true )<br />
DGS:dgsSetFont ( dummyGUIElement, "clear" )<br />
-- Output the font of the label to chat box<br />
outputChatBox ( "Font used in the DGS label: " .. DGS:dgsGetFont ( dummyGuiElement ) )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{DGSFUNCTIONS}}</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=Standard_DGS_Font_Names&diff=64828Standard DGS Font Names2019-12-27T01:15:51Z<p>JavadOmidi: </p>
<hr />
<div>These are the standard fonts that are used in DGS and can be accessed functions [[dgsGetFont]] and [[dgsSetFont]].<br />
"default"<br />
"default-bold"<br />
"clear"<br />
"arial"<br />
"sans"<br />
"pricedown"<br />
"bankgothic"<br />
"diploma"<br />
"beckett"<br />
<br />
<br />
<br />
<br />
<gallery heights="48" widths="236" perrow="3" caption="Available font properties and previews (ruined arabic word means that font doesn't support RTL languages)"><br />
File:Default.png|<div style="font-weight: bold">default</div><br />
File:Default-bold.png|<div style="font-weight: bold">default-bold</div><br />
File:Clear.png|<div style="font-weight: bold">clear</div><br />
File:Arial.png|<div style="font-weight: bold">arial</div><br />
File:Sans.png|<div style="font-weight: bold">sans</div><br />
File:Pricedown.png|<div style="font-weight: bold">pricedown</div><br />
File:Bankgothic.png|<div style="font-weight: bold">bankgothic</div><br />
File:Diploma.png|<div style="font-weight: bold">diploma</div><br />
File:Beckett.png|<div style="font-weight: bold">beckett</div><br />
</gallery></div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=File:Beckett.png&diff=64827File:Beckett.png2019-12-27T01:14:56Z<p>JavadOmidi: </p>
<hr />
<div>Beckett</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=File:Diploma.png&diff=64826File:Diploma.png2019-12-27T01:13:57Z<p>JavadOmidi: </p>
<hr />
<div>Diploma</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=File:Bankgothic.png&diff=64825File:Bankgothic.png2019-12-27T01:13:05Z<p>JavadOmidi: </p>
<hr />
<div>Bankgothic</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=File:Pricedown.png&diff=64824File:Pricedown.png2019-12-27T01:12:06Z<p>JavadOmidi: </p>
<hr />
<div>Pricedown</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=File:Sans.png&diff=64823File:Sans.png2019-12-27T01:10:31Z<p>JavadOmidi: </p>
<hr />
<div>Sans</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=File:Clear.png&diff=64822File:Clear.png2019-12-27T01:08:46Z<p>JavadOmidi: </p>
<hr />
<div>Clear</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=File:Default-bold.png&diff=64821File:Default-bold.png2019-12-27T01:07:36Z<p>JavadOmidi: </p>
<hr />
<div>Default-bold</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=File:Default.png&diff=64820File:Default.png2019-12-27T01:05:42Z<p>JavadOmidi: </p>
<hr />
<div>Default</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=File:Arial.png&diff=64819File:Arial.png2019-12-27T00:57:45Z<p>JavadOmidi: </p>
<hr />
<div>Arial</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=Standard_DGS_Font_Names&diff=64818Standard DGS Font Names2019-12-27T00:53:14Z<p>JavadOmidi: Created page with "These are the standard fonts that are used in DGS and can be accessed functions [dgsGetFont] and [dgsSetFont]. "default" "default-bold" "clear" "arial" "sans" "pricedown" "ban..."</p>
<hr />
<div>These are the standard fonts that are used in DGS and can be accessed functions [dgsGetFont] and [dgsSetFont].<br />
"default"<br />
"default-bold"<br />
"clear"<br />
"arial"<br />
"sans"<br />
"pricedown"<br />
"bankgothic"<br />
"diploma"<br />
"beckett"</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=DgsSetFont&diff=64817DgsSetFont2019-12-26T23:20:17Z<p>JavadOmidi: /* Required Arguments */</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function sets the font of a dgs element to be used when drawing text.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool dgsSetFont( element dgsElement, mixed font )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments===<br />
*'''dgsElement:''' The DGS element you wish to change the font of<br />
*'''font:''' Either a custom dx font element or the name of a built-in dx font (Can be affected by [[dgsSetSystemFont]]).<br />
<br />
===Returns===<br />
Returns ''true'' if the font has been successfully set on the dgs element, ''false'' otherwise.<br />
<br />
==Example== <br />
This example sets and gets the font of a pre-made gui element and outputs it to chat box.<br />
<syntaxhighlight lang="lua"><br />
DGS = exports.dgs<br />
-- We create a dummy gui label to get text of<br />
local dummyGUIElement = DGS:dgsCreateLabel ( 0.45, 0.48, 0.10, 0.04, "Hello world", true )<br />
DGS:dgsSetFont ( dummyGUIElement, "clear" )<br />
-- Output the font of the label to chat box<br />
outputChatBox ( "Font used in the DGS label: " .. DGS:dgsGetFont ( dummyGuiElement ) )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{DGSFUNCTIONS}}</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=AreVehicleLightsOn&diff=64734AreVehicleLightsOn2019-11-14T20:59:39Z<p>JavadOmidi: /* Example */</p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
{{New feature/item|3.0160|1.5.7|19626|This function is used to find out whether the lights of the vehicle are on.}}<br />
{{Note|<br />
*This is different to [[getVehicleOverrideLights]] because this function will return '''true''' if the lights were turned on by natural causes.<br />
* Unless [[setVehicleOverrideLights]] is used, vehicles always automatically disable their lights between 06:00 and 07:00 and enable them between 20:00 and 21:00.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool areVehicleLightsOn ( vehicle theVehicle )<br />
</syntaxhighlight><br />
{{OOP||[[vehicle]]:areLightsOn|lightsOn}}<br />
===Required Arguments===<br />
*'''theVehicle''': the [[vehicle]] you wish to retrieve the lights state of.<br />
<br />
===Returns===<br />
Returns ''true'' if the lights are on, ''false'' otherwise.<br />
<br />
==Example==<br />
This example checks if your vehicle lights are on/off and tells you the reason<br />
<syntaxhighlight lang="lua">addCommandHandler('checkMyLights' , function ()<br />
if not isPedInVehicle(localPlayer) then<br />
outputChatBox('Please enter your vehicle first' , 150 , 50 , 0 )<br />
return end<br />
local message = ''<br />
local myVehicle = getPedOccupiedVehicle(localPlayer)<br />
local checkIfOverrided = getVehicleOverrideLights(myVehicle)<br />
if checkIfOverrided == 0 then<br />
if areVehicleLightsOn(myVehicle) then<br />
local h , m = getTime()<br />
if h > 6 and h < 20 then<br />
message = 'on. Reason: You are in a dark place' -- vehicle lights turn on in some dark places during the day like this position x:-1513 y:-287 z:6<br />
else<br />
message = 'on. Reason: It is night'<br />
end<br />
else<br />
message = 'off. Reason: It is day'<br />
end<br />
elseif checkIfOverrided == 1 then<br />
message = 'off. Reason: They are forced off'<br />
else<br />
message = 'on. Reason: They are forced on'<br />
end<br />
<br />
outputChatBox('Your vehicle lights are turned '..message , 0 , 150 , 50 )<br />
end)</syntaxhighlight><br />
By javadOmidi<br />
<br />
==See Also==<br />
{{Client vehicle functions}}</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=EngineReplaceModel_notes&diff=64582EngineReplaceModel notes2019-11-01T22:51:53Z<p>JavadOmidi: /* Replacing models in the original GTA map */</p>
<hr />
<div>=Replacing models in the original GTA map=<br />
There are two ways to replace models in the original GTA map:<br />
<br />
==Method 1: Move camera away during replace process==<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
local modelId = 12853<br />
<br />
setCameraMatrix( 10000, 0, 0 ) -- Move camera far away<br />
<br />
col = engineLoadCOL( "garage.col" )<br />
txd = engineLoadTXD( "garage.txd" )<br />
dff = engineLoadDFF( "garage.dff", 0 )<br />
<br />
engineReplaceCOL( col, modelId )<br />
engineImportTXD( txd, modelId )<br />
engineReplaceModel( dff, modelId )<br />
<br />
setTimer( function()<br />
setCameraTarget( localPlayer ) -- Move camera back after a delay<br />
end, 50, 1 )<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
==Method 2: Create custom object and hide original==<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
local modelId = 12853<br />
local x,y,z = 661, -561, 17<br />
<br />
obj = createObject( modelId, x,y,z )<br />
removeWorldModel( modelId, 100, x,y,z ) -- Hide original<br />
<br />
col = engineLoadCOL( "garage.col" )<br />
txd = engineLoadTXD( "garage.txd" )<br />
dff = engineLoadDFF( "garage.dff", 0 )<br />
<br />
engineReplaceCOL( col, modelId )<br />
engineImportTXD( txd, modelId )<br />
engineReplaceModel( dff, modelId )<br />
</syntaxhighlight><br />
</section><br />
<br />
====Additonal code if model has LOD:====<br />
''(To determine the LOD model ID, use the editor resource, or refer to this [https://github.com/multitheftauto/mtasa-resources/blob/master/%5Beditor%5D/editor_main/server/mapEditorScriptingExtension_s.lua#L50 this table])''<br/><br />
If the model has a LOD version, that will need to be hidden:<br />
<syntaxhighlight lang="lua"><br />
local modelIdLOD = 13245<br />
removeWorldModel ( modelIdLOD, 100, x,y,z ) -- Hide LOD<br />
</syntaxhighlight><br />
<br />
Optionally create a MTA LOD replacement so there is no hole in the map from a distance:<br />
<syntaxhighlight lang="lua"><br />
-- This step is optional<br />
objLOD = createObject( modelIdLOD, x,y,z, 0, 0, 0, true )<br />
setLowLODElement(obj, objLOD)<br />
</syntaxhighlight><br />
<br />
And for extra points, add a custom dff for the MTA LOD replacement:<br />
<syntaxhighlight lang="lua"><br />
-- This step is optional<br />
txdLOD = engineLoadTXD( "garageLOD.txd" )<br />
dffLOD = engineLoadDFF( "garageLOD.dff", 0 )<br />
engineImportTXD( txdLOD, modelIdLOD )<br />
engineReplaceModel( dffLOD, modelIdLOD )<br />
</syntaxhighlight><br />
<br />
=Additonal Note=<br />
'''Sometimes you need to replace the model far away from where the model/texture change is being made'''<br />
so if you are in the game and you are trying to replace a model then get away from the model till it is gone from your draw distance for making sure that this problem won't happen</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=ResetWorldSounds&diff=64570ResetWorldSounds2019-10-28T09:31:46Z<p>JavadOmidi: /* Requirements */</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
{{Needs Example}}<br />
{{New items|3.0140|1.3.1|<br />
This function is used to reset the world sounds to the default setting.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool resetWorldSounds()<br />
</syntaxhighlight><br />
<br />
===Returns===<br />
Returns true if the world sounds were reset, false otherwise.<br />
<br />
==Requirements==<br />
{{Requirements|n/a|1.3.0-9.04134|}}<br />
<br />
<br />
==Example==<br />
By this command player can choose to reset world sounds to the default setting if it has been changed before using '''setWorldSoundEnabled'''<br />
<syntaxhighlight lang="lua"><br />
function iWantTheDefaultSounds()<br />
resetWorldSounds()<br />
end<br />
addCommandHandler('resetSounds' , iWantTheDefaultSounds )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client world functions}}</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=SetPlayerVoiceIgnoreFrom&diff=64569SetPlayerVoiceIgnoreFrom2019-10-28T08:50:35Z<p>JavadOmidi: /* Example */</p>
<hr />
<div>{{Server function}}__NOTOC__ <br />
{{Needs Example}}<br />
<br />
This function allows you to mute voices for a player.<br />
{{Important Note|This function should only be used as a low-level function for advanced users. For typical Voice scripting, please see the [[Resource:Voice|Voice Resource]]}}<br />
<br />
==Syntax== <br />
<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerVoiceIgnoreFrom ( element thePlayer, mixed ignoreFrom )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:setVoiceIgnoreFrom|voiceIgnoreFrom|}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The [[player]] you wish to change<br />
*'''ignoreFrom:''' Element or table of elements which the player should not hear voices from. Use ''nil'' if no one should be ignored.<br />
<br />
===Returns===<br />
Returns ''true'' if the value was set successfully, ''false'' otherwise.<br />
<br />
==Example== <br />
By this example mute a player voice to yourself so you won't hear him<br />
( '''note:''' use setPlayerVoiceMuted function if you are using the voice resource more information at https://wiki.multitheftauto.com/wiki/Resource:Voice )<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
function voiceMuteFunction( Muter , cmd , MutedName , mutual)<br />
local Muted = getPlayerFromName(MutedName)<br />
if not Muted then<br />
outputChatBox('enter the correct player name' , Muter)<br />
return end<br />
if mutual then --enter any string as the second arg for making this mute mutual or enter nothing to make it one-way<br />
setPlayerVoiceIgnoreFrom(Muter,Muted)<br />
setPlayerVoiceIgnoreFrom(Muted,Muter)<br />
else<br />
setPlayerVoiceIgnoreFrom(Muter,Muted)<br />
end <br />
end<br />
addCommandHandler('voiceMute' ,voiceMuteFunction )<br />
-- e.g. /voiceMute jacky y (mutual)<br />
-- e.g. /voiceMute jacky (one-way)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player_functions}}</div>JavadOmidihttps://wiki.multitheftauto.com/index.php?title=AreVehicleLightsOn&diff=64568AreVehicleLightsOn2019-10-28T07:41:23Z<p>JavadOmidi: /* Example */</p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
{{New feature/item|3.0160|1.5.7|19626|This function is used to find out whether the lights of the vehicle are on.}}<br />
{{Note|<br />
*This is different to [[getVehicleOverrideLights]] because this function will return '''true''' if the lights were turned on by natural causes.<br />
* Unless [[setVehicleOverrideLights]] is used, vehicles always automatically disable their lights between 06:00 and 07:00 and enable them between 20:00 and 21:00.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool areVehicleLightsOn ( vehicle theVehicle )<br />
</syntaxhighlight><br />
{{OOP||[[vehicle]]:areLightsOn|lightsOn}}<br />
===Required Arguments===<br />
*'''theVehicle''': the [[vehicle]] you wish to retrieve the lights state of.<br />
<br />
===Returns===<br />
Returns ''true'' if the lights are on, ''false'' otherwise.<br />
<br />
==Example==<br />
This example checks if your vehicle lights are on/off and tells you the reason<br />
<syntaxhighlight lang="lua">addCommandHandler('checkMyLights' , function ()<br />
if not isPedInVehicle(localPlayer) then<br />
outputChatBox('Please enter your vehicle first' , 150 , 50 , 0 )<br />
end<br />
local message = ''<br />
local myVehicle = getPedOccupiedVehicle(localPlayer)<br />
local checkIfOverrided = getVehicleOverrideLights(myVehicle)<br />
if checkIfOverrided == 0 then<br />
if areVehicleLightsOn(myVehicle) then<br />
local h , m = getTime()<br />
if h > 6 and h < 20 then<br />
message = 'on. Reason: You are in a dark place' -- vehicle lights turn on in some dark places during the day like this position x:-1513 y:-287 z:6<br />
else<br />
message = 'on. Reason: It is night'<br />
end<br />
else<br />
message = 'off. Reason: It is day'<br />
end<br />
elseif checkIfOverrided == 1 then<br />
message = 'off. Reason: They are forced off'<br />
else<br />
message = 'on. Reason: They are forced on'<br />
end<br />
<br />
outputChatBox('Your vehicle lights are turned '..message , 0 , 150 , 50 )<br />
end)</syntaxhighlight><br />
By javadOmidi<br />
<br />
==See Also==<br />
{{Client vehicle functions}}</div>JavadOmidi