https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=Einheit-101&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-29T11:09:59ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=AttachElementToBone&diff=67781AttachElementToBone2020-11-23T23:31:28Z<p>Einheit-101: Added example, fixed some stuff</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function allows you to attach an object, ped, player or vehicle to a ped or player bone for '''ONE FRAME'''. In order to attach an element continuously to a bone, this function should be used in conjunction with [[onClientPedsProcessed]].<br />
The function checks if a player is actually on screen and if he is not, the object gets moved out of the stream distance in order to preserve some performance.<br />
Unlike bone_attach, this function provides perfect accuracy for the attached elements and performs better.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool attachElementToBone(element theElement, ped thePed, int boneID, float offsetX, float offsetY, float offsetZ, float rotationOffsetX, float rotationOffsetZ, float rotationOffsetZ)</syntaxhighlight><br />
<br />
===Required arguments===<br />
* '''theElement''': The element which should be attached to the ped/player bone. Should work with any element that is supported by matrix functions.<br />
* '''thePed''': The ped or player which the element should be attached to.<br />
* '''boneID''': The target bone where the element should be attached to.<br />
* '''offsetX''': The X position offset from the bone.<br />
* '''offsetY''': The Y position offset from the bone.<br />
* '''offsetZ''': The Z position offset from the bone.<br />
* '''rotationOffsetX''': The rotation X-axis offset from the bone, in '''radians'''.<br />
* '''rotationOffsetY''': The rotation Y-axis offset from the bone, in '''radians'''.<br />
* '''rotationOffsetZ''': The rotation Z-axis offset from the bone, in '''radians'''.<br />
<br />
[[Image:Bones.jpg|thumb|Bone numbers]]<br />
<br />
<div style="border: 3px red solid; margin-bottom:3px; padding-left:5px;"><br />
*'''1:''' BONE_PELVIS1<br />
*'''2:''' BONE_PELVIS<br />
*'''3:''' BONE_SPINE1<br />
*'''4:''' BONE_UPPERTORSO<br />
*'''5:''' BONE_NECK<br />
*'''6:''' BONE_HEAD2<br />
*'''7:''' BONE_HEAD1<br />
*'''8:''' BONE_HEAD<br />
*'''21:''' BONE_RIGHTUPPERTORSO<br />
*'''22:''' BONE_RIGHTSHOULDER<br />
*'''23:''' BONE_RIGHTELBOW<br />
*'''24:''' BONE_RIGHTWRIST<br />
*'''25:''' BONE_RIGHTHAND<br />
*'''26:''' BONE_RIGHTTHUMB<br />
*'''31:''' BONE_LEFTUPPERTORSO<br />
*'''32:''' BONE_LEFTSHOULDER<br />
*'''33:''' BONE_LEFTELBOW<br />
*'''34:''' BONE_LEFTWRIST<br />
*'''35:''' BONE_LEFTHAND<br />
*'''36:''' BONE_LEFTTHUMB<br />
*'''41:''' BONE_LEFTHIP<br />
*'''42:''' BONE_LEFTKNEE<br />
*'''43:''' BONE_LEFTANKLE<br />
*'''44:''' BONE_LEFTFOOT<br />
*'''51:''' BONE_RIGHTHIP<br />
*'''52:''' BONE_RIGHTKNEE<br />
*'''53:''' BONE_RIGHTANKLE<br />
*'''54:''' BONE_RIGHTFOOT<br />
</div><br />
<br />
===Return===<br />
Returns true if the object has successfully been attached to the ped/player, returns false if the specified ped/player is not on screen and the object has been moved out of the streaming distance.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function attachElementToBone(element, ped, bone, offX, offY, offZ, offrx, offry, offrz)<br />
if isElementOnScreen(ped) then<br />
local boneMat = getElementBoneMatrix(ped, bone)<br />
local sroll, croll, spitch, cpitch, syaw, cyaw = math.sin(offrz), math.cos(offrz), math.sin(offry), math.cos(offry), math.sin(offrx), math.cos(offrx)<br />
local rotMat = {<br />
{sroll * spitch * syaw + croll * cyaw,<br />
sroll * cpitch,<br />
sroll * spitch * cyaw - croll * syaw},<br />
{croll * spitch * syaw - sroll * cyaw,<br />
croll * cpitch,<br />
croll * spitch * cyaw + sroll * syaw},<br />
{cpitch * syaw,<br />
-spitch,<br />
cpitch * cyaw}<br />
}<br />
local finalMatrix = {<br />
{boneMat[2][1] * rotMat[1][2] + boneMat[1][1] * rotMat[1][1] + rotMat[1][3] * boneMat[3][1],<br />
boneMat[3][2] * rotMat[1][3] + boneMat[1][2] * rotMat[1][1] + boneMat[2][2] * rotMat[1][2],-- right<br />
boneMat[2][3] * rotMat[1][2] + boneMat[3][3] * rotMat[1][3] + rotMat[1][1] * boneMat[1][3],<br />
0},<br />
{rotMat[2][3] * boneMat[3][1] + boneMat[2][1] * rotMat[2][2] + rotMat[2][1] * boneMat[1][1],<br />
boneMat[3][2] * rotMat[2][3] + boneMat[2][2] * rotMat[2][2] + boneMat[1][2] * rotMat[2][1],-- front <br />
rotMat[2][1] * boneMat[1][3] + boneMat[3][3] * rotMat[2][3] + boneMat[2][3] * rotMat[2][2],<br />
0},<br />
{boneMat[2][1] * rotMat[3][2] + rotMat[3][3] * boneMat[3][1] + rotMat[3][1] * boneMat[1][1],<br />
boneMat[3][2] * rotMat[3][3] + boneMat[2][2] * rotMat[3][2] + rotMat[3][1] * boneMat[1][2],-- up<br />
rotMat[3][1] * boneMat[1][3] + boneMat[3][3] * rotMat[3][3] + boneMat[2][3] * rotMat[3][2],<br />
0},<br />
{offX * boneMat[1][1] + offY * boneMat[2][1] + offZ * boneMat[3][1] + boneMat[4][1],<br />
offX * boneMat[1][2] + offY * boneMat[2][2] + offZ * boneMat[3][2] + boneMat[4][2],-- pos<br />
offX * boneMat[1][3] + offY * boneMat[2][3] + offZ * boneMat[3][3] + boneMat[4][3],<br />
1}<br />
}<br />
setElementMatrix(element, finalMatrix)<br />
return true<br />
else<br />
setElementPosition(element, 0, 0, -1000)<br />
return false<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example attaches a sniper rifle and a backpack to the local player.<br />
<syntaxhighlight lang="lua"><br />
local theGun = createObject(358, 0, 0, 0)<br />
local thePara = createObject(371, 0, 0, 0)<br />
<br />
function onPedsProcessed()<br />
attachElementToBone(theGun, localPlayer, 24, 0, 0, 0, 0, 0, 0)-- Attach the sniper model to bone #24 of the local player, no offset is needed because the default GTA weapon models fit perfectly fine into bone #24<br />
attachElementToBone(thePara, localPlayer, 3, 0.1, -0.14, 0, math.rad(90), 0, 0)-- Attach parachute to bone #3 of the local player with a small position and rotation offset, so it looks nice<br />
end<br />
addEventHandler("onClientPedsProcessed", root, onPedsProcessed)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=AttachElementToBone&diff=67780AttachElementToBone2020-11-23T23:23:31Z<p>Einheit-101: First release</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function allows you to attach an object, ped, player or vehicle to a ped or player bone for '''ONE FRAME'''. In order to attach an element continuously to a bone, this function should be used in conjunction with [[onClientPedsProcessed]].<br />
The function checks if a player is actually on screen and if he is not, the object gets moved out of the stream distance in order to preserve some performance.<br />
Unlike bone_attach, this function provides perfect accuracy for the attached elements and performs better.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool attachElementToBone(element theElement, ped thePed, int boneID, float offsetX, float offsetY, float offsetZ, float rotationOffsetX, float rotationOffsetZ, float rotationOffsetZ)</syntaxhighlight><br />
<br />
===Required arguments===<br />
* '''theElement''': The element which should be attached to the ped/player bone. Should work with any element that is supported by matrix functions.<br />
* '''thePed''': The ped or player which the element should be attached to.<br />
* '''boneID''': The target bone where the element should be attached to.<br />
* '''offsetX''': The X position offset from the bone.<br />
* '''offsetY''': The Y position offset from the bone.<br />
* '''offsetZ''': The Z position offset from the bone.<br />
* '''rotationOffsetX''': The rotation X-axis offset from the bone.<br />
* '''rotationOffsetY''': The rotation Y-axis offset from the bone.<br />
* '''rotationOffsetZ''': The rotation Z-axis offset from the bone.<br />
<br />
[[Image:Bones.jpg|thumb|Bone numbers]]<br />
<br />
<div style="border: 3px red solid; margin-bottom:3px; padding-left:5px;"><br />
*'''1:''' BONE_PELVIS1<br />
*'''2:''' BONE_PELVIS<br />
*'''3:''' BONE_SPINE1<br />
*'''4:''' BONE_UPPERTORSO<br />
*'''5:''' BONE_NECK<br />
*'''6:''' BONE_HEAD2<br />
*'''7:''' BONE_HEAD1<br />
*'''8:''' BONE_HEAD<br />
*'''21:''' BONE_RIGHTUPPERTORSO<br />
*'''22:''' BONE_RIGHTSHOULDER<br />
*'''23:''' BONE_RIGHTELBOW<br />
*'''24:''' BONE_RIGHTWRIST<br />
*'''25:''' BONE_RIGHTHAND<br />
*'''26:''' BONE_RIGHTTHUMB<br />
*'''31:''' BONE_LEFTUPPERTORSO<br />
*'''32:''' BONE_LEFTSHOULDER<br />
*'''33:''' BONE_LEFTELBOW<br />
*'''34:''' BONE_LEFTWRIST<br />
*'''35:''' BONE_LEFTHAND<br />
*'''36:''' BONE_LEFTTHUMB<br />
*'''41:''' BONE_LEFTHIP<br />
*'''42:''' BONE_LEFTKNEE<br />
*'''43:''' BONE_LEFTANKLE<br />
*'''44:''' BONE_LEFTFOOT<br />
*'''51:''' BONE_RIGHTHIP<br />
*'''52:''' BONE_RIGHTKNEE<br />
*'''53:''' BONE_RIGHTANKLE<br />
*'''54:''' BONE_RIGHTFOOT<br />
</div><br />
<br />
===Return===<br />
Returns true if the object has successfully been attached to the ped/player, returns false if the specified ped/player is not on screen and the object has been moved out of the streaming distance.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function attachElementToBone(element, ped, bone, offX, offY, offZ, offrx, offry, offrz)<br />
if isElementOnScreen(ped) then<br />
local boneMat = getElementBoneMatrix(ped, bone)<br />
local sroll, croll, spitch, cpitch, syaw, cyaw = math.sin(offrz), math.cos(offrz), math.sin(offry), math.cos(offry), math.sin(offrx), math.cos(offrx)<br />
local rotMat = {<br />
{sroll * spitch * syaw + croll * cyaw,<br />
sroll * cpitch,<br />
sroll * spitch * cyaw - croll * syaw},<br />
{croll * spitch * syaw - sroll * cyaw,<br />
croll * cpitch,<br />
croll * spitch * cyaw + sroll * syaw},<br />
{cpitch * syaw,<br />
-spitch,<br />
cpitch * cyaw}<br />
}<br />
local finalMatrix = {<br />
{boneMat[2][1] * rotMat[1][2] + boneMat[1][1] * rotMat[1][1] + rotMat[1][3] * boneMat[3][1],<br />
boneMat[3][2] * rotMat[1][3] + boneMat[1][2] * rotMat[1][1] + boneMat[2][2] * rotMat[1][2],-- right<br />
boneMat[2][3] * rotMat[1][2] + boneMat[3][3] * rotMat[1][3] + rotMat[1][1] * boneMat[1][3],<br />
0},<br />
{rotMat[2][3] * boneMat[3][1] + boneMat[2][1] * rotMat[2][2] + rotMat[2][1] * boneMat[1][1],<br />
boneMat[3][2] * rotMat[2][3] + boneMat[2][2] * rotMat[2][2] + boneMat[1][2] * rotMat[2][1],-- front <br />
rotMat[2][1] * boneMat[1][3] + boneMat[3][3] * rotMat[2][3] + boneMat[2][3] * rotMat[2][2],<br />
0},<br />
{boneMat[2][1] * rotMat[3][2] + rotMat[3][3] * boneMat[3][1] + rotMat[3][1] * boneMat[1][1],<br />
boneMat[3][2] * rotMat[3][3] + boneMat[2][2] * rotMat[3][2] + rotMat[3][1] * boneMat[1][2],-- up<br />
rotMat[3][1] * boneMat[1][3] + boneMat[3][3] * rotMat[3][3] + boneMat[2][3] * rotMat[3][2],<br />
0},<br />
{offX * boneMat[1][1] + offY * boneMat[2][1] + offZ * boneMat[3][1] + boneMat[4][1],<br />
offX * boneMat[1][2] + offY * boneMat[2][2] + offZ * boneMat[3][2] + boneMat[4][2],-- pos<br />
offX * boneMat[1][3] + offY * boneMat[2][3] + offZ * boneMat[3][3] + boneMat[4][3],<br />
1}<br />
}<br />
setElementMatrix(element, finalMatrix)<br />
return true<br />
else<br />
setElementPosition(element, 0, 0, -1000)<br />
return false<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example attaches a sniper rifle (model 358) to the players hand.<br />
<syntaxhighlight lang="lua"><br />
--todo<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=ProcessLineOfSight&diff=66965ProcessLineOfSight2020-06-27T14:44:26Z<p>Einheit-101: Updated wiki information regarding inverted seeThroughStuff and shootThroughStuff arguments and some other problems.</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function casts a ray between two points in the world, and tells you information about the point that was hit, if any. The two positions '''must''' be within the local player's draw distance as the collision data is not loaded outside this area, and the call will just fail as if the ray didn't hit.<br />
<br />
This function is relatively expensive to call, so over use of this in scripts may have a detrimental effect on performance.<br />
<br />
This function is useful for checking for collisions and for editor-style scripts. If you wish to find what element is positioned at a particular point on the screen, use this function combined with [[getWorldFromScreenPosition]]. If you wish to just know if something is hit, and don't care about what or where was hit, use [[isLineOfSightClear]].<br />
<br />
{{Note|Due to a bug, shootThroughStuff argument does currently check for seeThroughStuff!}}<br />
{{Note|Due to a bug, seeThroughStuff argument has no effect. It mistakenly checks for "shootThrough" surfaces and will always behave as if the argument is set to FALSE (It will never hit).}}<br />
<br />
==Syntax== <br />
Return values labelled for ease of reference.<br />
<syntaxhighlight lang="lua"><br />
bool -- hit<br />
float float float -- hitX, hitY, hitZ<br />
element -- hitElement<br />
float float float -- normalX, normalY, normalZ<br />
int -- material<br />
float -- lighting<br />
int -- piece<br />
int -- worldModelID<br />
float float float -- worldModelPositionX,Y,Z<br />
float float float -- worldModelRotationX,Y,Z<br />
int -- worldLODModelID<br />
processLineOfSight ( float startX, float startY, float startZ, <br />
float endX, float endY, float endZ, <br />
[ bool checkBuildings = true, <br />
bool checkVehicles = true, <br />
bool checkPlayers = true, <br />
bool checkObjects = true, <br />
bool checkDummies = true, <br />
bool seeThroughStuff = false, <br />
bool ignoreSomeObjectsForCamera = false, <br />
bool shootThroughStuff = false, <br />
element ignoredElement = nil,<br />
bool includeWorldModelInformation = false,<br />
bool bIncludeCarTyres ] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''startX:''' The start ''x'' position<br />
*'''startY:''' The start ''y'' position<br />
*'''startZ:''' The start ''z'' position<br />
*'''endX:''' The end ''x'' position<br />
*'''endY:''' The end ''y'' position<br />
*'''endZ:''' The end ''z'' position<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.<br />
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].<br />
*'''checkPlayers:''' Allow the line of sight to be blocked by [[Player|players]].<br />
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].<br />
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''.<br />
*'''seeThroughStuff:''' Allow the line of sight '''pass through''' collision materials that have this flag enabled (By default material IDs 52, 55 and 66 which are some fences that you can shoot throug but still walk on them).<br />
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to '''pass through''' objects that have (K) property enabled in "object.dat" data file. (i.e. Most dynamic objects like boxes or barrels)<br />
*'''shootThroughStuff:''' Allow the line of sight to '''pass through''' collision materials that have this flag enabled (By default material IDs 28, 29, 31, 32, 33, 74, 75, 76, 77, 78, 79, 96, 97, 98, 99, 100 which are exclusively sand / beach or underwater objects).<br />
*'''ignoredElement:''' Allow the line of sight to '''pass through''' a certain specified element. This is usually set to the object you are tracing from so it does not interfere with the results.<br />
*'''includeWorldModelInformation :''' Include the results of hitting a world model.<br />
*'''bIncludeCarTyres :''' Includes car tyre hits.<br />
<br />
===Returns===<br />
*'''hit:''' ''true'' if there is a collision, ''false'' otherwise<br />
The other values are only filled if there is a collision, they contain ''nil'' otherwise<br />
*'''hitX, hitY, hitZ:''' collision position<br />
*'''hitElement:''' the MTA element hit if any, ''nil'' otherwise<br />
*'''normalX, normalY, normalZ:''' the normal of the surface hit<br />
*'''material:''' an integer representing the [[Material IDs|GTASA material ID]] of the surface hit when applicable (world, objects)<br />
*'''lighting:''' a float between 0 (fully dark) and 1 (bright) representing the amount of light that the hit building surface will transfer to peds or vehicles that are in contact with it. The value can be affected by the game time of day, usually with a lower (darker) value being returned during the night.<br />
*'''piece:''' an integer representing the part of the element hit if hitElement is a vehicle or a ped/player, ''0'' otherwise. <br />
**For a ped/player, piece represents the body part hit:<br />
{{BodyParts}}<br />
**For vehicles, piece represents the vehicle part hit:<br />
{{VehicleParts}}<br />
*'''worldModelID:''' If includeWorldModelInformation was set to ''true'' and a world model was hit, this will contain the model ID.<br />
*'''worldModelPositionX,Y,Z:''' If worldModelID is set, this will contain the world model position.<br />
*'''worldModelRotationX,Y,Z:''' If worldModelID is set, this will contain the world model rotation.<br />
*'''worldLODModelID:''' If worldModelID is set, this will contain the LOD model ID if applicable.<br />
<br />
==Examples== <br />
This example shows how you can tell what position and element the camera is looking at, up to 50 units away.<br />
<syntaxhighlight lang="lua"><br />
local w, h = guiGetScreenSize ()<br />
local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 )<br />
local px, py, pz = getCameraMatrix()<br />
hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz )<br />
if hit then<br />
outputChatBox ( "Looking at " .. x .. ", " .. y .. ", " .. z )<br />
if elementHit then<br />
outputChatBox ( "Hit element " .. getElementType(elementHit) )<br />
end<br />
end<br />
</syntaxhighlight><br />
This example shows how you can get the surface type a vehicle is on. This is useful if you want to do a script to dirt cars over time. Please note that this function doesn't count if the vehicle is streamed in or not, so expect this function to fail or return incorrect values on unloaded vehicles.<br />
<syntaxhighlight lang="lua"><br />
function getSurfaceVehicleIsOn(vehicle)<br />
if isElement(vehicle) and (isVehicleOnGround(vehicle) or isElementInWater(vehicle)) then -- Is an element and is touching any surface?<br />
local cx, cy, cz = getElementPosition(vehicle) -- Get the position of the vehicle<br />
local gz = getGroundPosition(cx, cy, cz) - 0.001 -- Get the Z position of the ground the vehicle is on (-0.001 because of processLineOfSight)<br />
local hit, _, _, _, _, _, _, _, surface = processLineOfSight(cx, cy, cz, cx, cy, gz) -- This will get the material of the thing the car is standing on<br />
if hit then<br />
return surface -- If everything is correct, stop executing this function and return the surface type<br />
end<br />
end<br />
return false -- If something isn't correct, return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Changelog==<br />
{{ChangelogHeader}}<br />
{{ChangelogItem|1.3.0-9.04273|''bIncludeCarTyres'' argument added}}<br />
{{ChangelogItem|1.3.0-9.04273|''worldModelID'' return value fixed}}<br />
{{ChangelogItem|1.3.0-9.04405|''lighting'' return value fixed}}<br />
<br />
==See Also==<br />
{{Client world functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=IsLineOfSightClear&diff=66964IsLineOfSightClear2020-06-27T14:00:10Z<p>Einheit-101: seeThroughStuff argument is actually inverted, setting it to TRUE allows the line of sight to pass through "seeThrough" surface materials. I added this information and highlighted it respectively.</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function checks if there are obstacles between two points of the game world, optionally ignoring certain kinds of elements. Use [[processLineOfSight]] if you want more information about what the ray hits.<br />
<br />
{{Note|This function does currently NOT support collisions with the "shootthrough" flag enabled. That means: isLineOfSightClear will never collide with such collisions and this can lead to unreliabilities. The "shootthrough" flag is used by many beach/sand/underwater objects.}}<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool isLineOfSightClear ( float startX, float startY, float startZ, float endX, float endY, float endZ, [ bool checkBuildings = true, bool checkVehicles = true, bool checkPeds = true,<br />
bool checkObjects = true, bool checkDummies = true, bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, element ignoredElement = nil ] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
*'''startX:''' The first point's world X coordinate.<br />
*'''startY:''' The first point's world Y coordinate.<br />
*'''startZ:''' The first point's world Z coordinate.<br />
*'''endX:''' The second point's world X coordinate.<br />
*'''endY:''' The second point's world Y coordinate.<br />
*'''endZ:''' The second point's world Z coordinate.<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.<br />
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].<br />
*'''checkPeds:''' Allow the line of sight to be blocked by peds, i.e. [[Player|players]].<br />
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].<br />
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''.<br />
*'''seeThroughStuff:''' Allow the line of sight to '''pass through''' collision materials that have this flag enabled (By default material IDs 52, 55 and 66 which are some fences). This flag originally allows some objects to be walked on but you can shoot throug them.<br />
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to '''pass through''' objects that have (K) property enabled in "object.dat" data file. (i.e. Most dynamic objects like boxes or barrels)<br />
*'''ignoredElement:''' Allow the line of sight to pass through a certain specified element.<br />
<br />
===Returns===<br />
Returns ''true'' if the line between the specified points is clear, ''false'' if there's an obstacle or if invalid parameters are passed.<br />
<br />
==Example== <br />
<section name="Client" class="client" show="false"><br />
isLineOfSightClear is the economical way to cast a ray in the world. <br />
This example demonstrates how you can easily implement basic NPC behaviour such as jumping obstacles. A 3D line is drawn connecting the two points in the ray.<br />
<syntaxhighlight lang="lua"><br />
local t_Data = {}<br />
<br />
local function updateNPC ()<br />
if (not isElement(t_Data.ped) or (getElementHealth(t_Data.ped) == 0)) then<br />
return toggleNPCFollower ()<br />
end<br />
<br />
local t_PlayerPos = {getElementPosition(localPlayer)}<br />
local t_PedPos = {getElementPosition(t_Data.ped)}<br />
<br />
local intDistance = getDistanceBetweenPoints3D (t_PedPos[1], t_PedPos[2], t_PedPos[3], unpack(t_PlayerPos))<br />
if (intDistance < 4) then<br />
setPedControlState (t_Data.ped, 'forwards', false)<br />
return true<br />
end<br />
<br />
-- Calculate the rotation between ped and player position<br />
local intPedRot = -math.deg (math.atan2(t_PlayerPos[1] - t_PedPos[1], t_PlayerPos[2] - t_PedPos[2]))<br />
if intPedRot < 0 then intPedRot = intPedRot + 360 end;<br />
<br />
setElementRotation (t_Data.ped, 0, 0, intPedRot, 'default', true)<br />
-- At this point we know that the ped needs to move it<br />
setPedControlState (t_Data.ped, 'forwards', true)<br />
<br />
local bPathClear = true<br />
local t_Matrix = getElementMatrix (t_Data.ped)<br />
<br />
-- Calculate a position 1m ahead of ped<br />
local int_RayX = t_Matrix[2][1] + t_Matrix[4][1]<br />
local int_RayY = t_Matrix[2][2] + t_Matrix[4][2]<br />
local int_RayZ = t_Matrix[2][3] + t_Matrix[4][3]<br />
<br />
-- We cast 10 rays 1m ahead of the ped<br />
for i = 1, 10 do<br />
local intSourceX, intSourceY, intSourceZ = t_PedPos[1], t_PedPos[2], t_PedPos[3]<br />
<br />
-- The target position height is identical to the center of the ped (1m above ground) <br />
-- We lower this value by 0.5m to detect short obstacles<br />
local intTargetX, intTargetY, intTargetZ = int_RayX, int_RayY, int_RayZ - 0.5 + i*0.2<br />
<br />
bPathClear = isLineOfSightClear (intSourceX, intSourceY, intSourceZ, intTargetX, intTargetY, intTargetZ, true, true, false, true)<br />
dxDrawLine3D (intSourceX, intSourceY, intSourceZ, intTargetX, intTargetY, intTargetZ, bPathClear and tocolor(255,255,255,255) or tocolor(255,0,0,255))<br />
<br />
if (not bPathClear) then<br />
break<br />
end<br />
end<br />
<br />
if (not bPathClear) then<br />
setPedControlState (t_Data.ped, 'jump', true)<br />
else<br />
setPedControlState (t_Data.ped, 'jump', false)<br />
end<br />
<br />
if (intDistance > 15) then<br />
setPedControlState (t_Data.ped, 'sprint', true)<br />
else<br />
setPedControlState (t_Data.ped, 'sprint', false)<br />
end<br />
end<br />
<br />
function toggleNPCFollower ()<br />
if (t_Data.ped) then<br />
if (t_Data.updateNPCTimer) then<br />
if (isTimer(t_Data.updateNPCTimer)) then<br />
killTimer (t_Data.updateNPCTimer)<br />
end<br />
end<br />
if (isElement(t_Data.ped)) then<br />
destroyElement (t_Data.ped)<br />
end<br />
t_Data.ped = nil<br />
return true<br />
end<br />
<br />
local intX, intY, intZ = getElementPosition (localPlayer)<br />
local _, _, intRZ = getElementRotation (localPlayer)<br />
local t_Matrix = getElementMatrix (localPlayer)<br />
<br />
-- Calculate a position 4m behind local player<br />
local intPedX = -4 * t_Matrix[2][1] + t_Matrix[4][1]<br />
local intPedY = -4 * t_Matrix[2][2] + t_Matrix[4][2]<br />
local intPedZ = -4 * t_Matrix[2][3] + t_Matrix[4][3]<br />
<br />
t_Data.ped = createPed (0, intPedX, intPedY, intPedZ, intRZ)<br />
t_Data.updateNPCTimer = setTimer (updateNPC, 50, 0)<br />
end<br />
addCommandHandler ('npc', toggleNPCFollower)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client world functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=IsLineOfSightClear&diff=66880IsLineOfSightClear2020-06-09T23:24:28Z<p>Einheit-101: Added note about current issue</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function checks if there are obstacles between two points of the game world, optionally ignoring certain kinds of elements. Use [[processLineOfSight]] if you want more information about what the ray hits.<br />
<br />
{{Note|This function does currently NOT support collisions with the "shootthrough" flag enabled. That means: isLineOfSightClear will never collide with such collisions and this can lead to unreliabilities. The "shootthrough" flag is <br />
used by many beach/sand/underwater objects.}}<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool isLineOfSightClear ( float startX, float startY, float startZ, float endX, float endY, float endZ, [ bool checkBuildings = true, bool checkVehicles = true, bool checkPeds = true,<br />
bool checkObjects = true, bool checkDummies = true, bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, element ignoredElement = nil ] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
*'''startX:''' The first point's world X coordinate.<br />
*'''startY:''' The first point's world Y coordinate.<br />
*'''startZ:''' The first point's world Z coordinate.<br />
*'''endX:''' The second point's world X coordinate.<br />
*'''endY:''' The second point's world Y coordinate.<br />
*'''endZ:''' The second point's world Z coordinate.<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.<br />
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].<br />
*'''checkPeds:''' Allow the line of sight to be blocked by peds, i.e. [[Player|players]].<br />
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].<br />
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''.<br />
*'''seeThroughStuff:''' Allow the line of sight to be blocked by collision materials that have this flag enabled (By default material IDs 52, 55 and 66 which are some fences). This flag originally allows some objects to be walked on but you can shoot throug them.<br />
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to pass through objects that have (K) property enabled in "object.dat" data file. (i.e. Most dynamic objects like boxes or barrels)<br />
*'''ignoredElement:''' Allow the line of sight to pass through a certain specified element.<br />
<br />
===Returns===<br />
Returns ''true'' if the line between the specified points is clear, ''false'' if there's an obstacle or if invalid parameters are passed.<br />
<br />
==Example== <br />
<section name="Client" class="client" show="false"><br />
isLineOfSightClear is the economical way to cast a ray in the world. <br />
This example demonstrates how you can easily implement basic NPC behaviour such as jumping obstacles. A 3D line is drawn connecting the two points in the ray.<br />
<syntaxhighlight lang="lua"><br />
local t_Data = {}<br />
<br />
local function updateNPC ()<br />
if (not isElement(t_Data.ped) or (getElementHealth(t_Data.ped) == 0)) then<br />
return toggleNPCFollower ()<br />
end<br />
<br />
local t_PlayerPos = {getElementPosition(localPlayer)}<br />
local t_PedPos = {getElementPosition(t_Data.ped)}<br />
<br />
local intDistance = getDistanceBetweenPoints3D (t_PedPos[1], t_PedPos[2], t_PedPos[3], unpack(t_PlayerPos))<br />
if (intDistance < 4) then<br />
setPedControlState (t_Data.ped, 'forwards', false)<br />
return true<br />
end<br />
<br />
-- Calculate the rotation between ped and player position<br />
local intPedRot = -math.deg (math.atan2(t_PlayerPos[1] - t_PedPos[1], t_PlayerPos[2] - t_PedPos[2]))<br />
if intPedRot < 0 then intPedRot = intPedRot + 360 end;<br />
<br />
setElementRotation (t_Data.ped, 0, 0, intPedRot, 'default', true)<br />
-- At this point we know that the ped needs to move it<br />
setPedControlState (t_Data.ped, 'forwards', true)<br />
<br />
local bPathClear = true<br />
local t_Matrix = getElementMatrix (t_Data.ped)<br />
<br />
-- Calculate a position 1m ahead of ped<br />
local int_RayX = t_Matrix[2][1] + t_Matrix[4][1]<br />
local int_RayY = t_Matrix[2][2] + t_Matrix[4][2]<br />
local int_RayZ = t_Matrix[2][3] + t_Matrix[4][3]<br />
<br />
-- We cast 10 rays 1m ahead of the ped<br />
for i = 1, 10 do<br />
local intSourceX, intSourceY, intSourceZ = t_PedPos[1], t_PedPos[2], t_PedPos[3]<br />
<br />
-- The target position height is identical to the center of the ped (1m above ground) <br />
-- We lower this value by 0.5m to detect short obstacles<br />
local intTargetX, intTargetY, intTargetZ = int_RayX, int_RayY, int_RayZ - 0.5 + i*0.2<br />
<br />
bPathClear = isLineOfSightClear (intSourceX, intSourceY, intSourceZ, intTargetX, intTargetY, intTargetZ, true, true, false, true)<br />
dxDrawLine3D (intSourceX, intSourceY, intSourceZ, intTargetX, intTargetY, intTargetZ, bPathClear and tocolor(255,255,255,255) or tocolor(255,0,0,255))<br />
<br />
if (not bPathClear) then<br />
break<br />
end<br />
end<br />
<br />
if (not bPathClear) then<br />
setPedControlState (t_Data.ped, 'jump', true)<br />
else<br />
setPedControlState (t_Data.ped, 'jump', false)<br />
end<br />
<br />
if (intDistance > 15) then<br />
setPedControlState (t_Data.ped, 'sprint', true)<br />
else<br />
setPedControlState (t_Data.ped, 'sprint', false)<br />
end<br />
end<br />
<br />
function toggleNPCFollower ()<br />
if (t_Data.ped) then<br />
if (t_Data.updateNPCTimer) then<br />
if (isTimer(t_Data.updateNPCTimer)) then<br />
killTimer (t_Data.updateNPCTimer)<br />
end<br />
end<br />
if (isElement(t_Data.ped)) then<br />
destroyElement (t_Data.ped)<br />
end<br />
t_Data.ped = nil<br />
return true<br />
end<br />
<br />
local intX, intY, intZ = getElementPosition (localPlayer)<br />
local _, _, intRZ = getElementRotation (localPlayer)<br />
local t_Matrix = getElementMatrix (localPlayer)<br />
<br />
-- Calculate a position 4m behind local player<br />
local intPedX = -4 * t_Matrix[2][1] + t_Matrix[4][1]<br />
local intPedY = -4 * t_Matrix[2][2] + t_Matrix[4][2]<br />
local intPedZ = -4 * t_Matrix[2][3] + t_Matrix[4][3]<br />
<br />
t_Data.ped = createPed (0, intPedX, intPedY, intPedZ, intRZ)<br />
t_Data.updateNPCTimer = setTimer (updateNPC, 50, 0)<br />
end<br />
addCommandHandler ('npc', toggleNPCFollower)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client world functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=ProcessLineOfSight&diff=66879ProcessLineOfSight2020-06-09T23:19:21Z<p>Einheit-101: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function casts a ray between two points in the world, and tells you information about the point that was hit, if any. The two positions '''must''' be within the local player's draw distance as the collision data is not loaded outside this area, and the call will just fail as if the ray didn't hit.<br />
<br />
This function is relatively expensive to call, so over use of this in scripts may have a detrimental effect on performance.<br />
<br />
This function is useful for checking for collisions and for editor-style scripts. If you wish to find what element is positioned at a particular point on the screen, use this function combined with [[getWorldFromScreenPosition]]. If you wish to just know if something is hit, and don't care about what or where was hit, use [[isLineOfSightClear]].<br />
<br />
{{Note|Due to a bug, shootThroughStuff argument has no effect and this function will always behave as if shootThroughStuff is set to TRUE (It will always hit).}}<br />
{{Note|Due to a bug, seeThroughStuff argument has no effect and this function will always behave as if seeThroughStuff is set to FALSE (It will never hit).}}<br />
<br />
==Syntax== <br />
Return values labelled for ease of reference.<br />
<syntaxhighlight lang="lua"><br />
bool -- hit<br />
float float float -- hitX, hitY, hitZ<br />
element -- hitElement<br />
float float float -- normalX, normalY, normalZ<br />
int -- material<br />
float -- lighting<br />
int -- piece<br />
int -- worldModelID<br />
float float float -- worldModelPositionX,Y,Z<br />
float float float -- worldModelRotationX,Y,Z<br />
int -- worldLODModelID<br />
processLineOfSight ( float startX, float startY, float startZ, <br />
float endX, float endY, float endZ, <br />
[ bool checkBuildings = true, <br />
bool checkVehicles = true, <br />
bool checkPlayers = true, <br />
bool checkObjects = true, <br />
bool checkDummies = true, <br />
bool seeThroughStuff = false, <br />
bool ignoreSomeObjectsForCamera = false, <br />
bool shootThroughStuff = false, <br />
element ignoredElement = nil,<br />
bool includeWorldModelInformation = false,<br />
bool bIncludeCarTyres ] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''startX:''' The start ''x'' position<br />
*'''startY:''' The start ''y'' position<br />
*'''startZ:''' The start ''z'' position<br />
*'''endX:''' The end ''x'' position<br />
*'''endY:''' The end ''y'' position<br />
*'''endZ:''' The end ''z'' position<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.<br />
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].<br />
*'''checkPlayers:''' Allow the line of sight to be blocked by [[Player|players]].<br />
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].<br />
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''.<br />
*'''seeThroughStuff:''' Allow the line of sight to be blocked by collision materials that have this flag enabled (By default material IDs 52, 55 and 66 which are some fences that you can shoot throug but still walk on them).<br />
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to pass through objects that have (K) property enabled in "object.dat" data file. (i.e. Most dynamic objects like boxes or barrels)<br />
*'''shootThroughStuff:''' Allow the line of sight to be blocked by collision materials that have this flag enabled (By default material IDs 28, 29, 31, 32, 33, 74, 75, 76, 77, 78, 79, 96, 97, 98, 99, 100 which are exclusively sand / beach or underwater objects).<br />
*'''ignoredElement:''' Allow the line of sight to pass through a certain specified element. This is usually set to the object you are tracing from so it does not interfere with the results.<br />
*'''includeWorldModelInformation :''' Include the results of hitting a world model.<br />
*'''bIncludeCarTyres :''' Includes car tyre hits.<br />
<br />
===Returns===<br />
*'''hit:''' ''true'' if there is a collision, ''false'' otherwise<br />
The other values are only filled if there is a collision, they contain ''nil'' otherwise<br />
*'''hitX, hitY, hitZ:''' collision position<br />
*'''hitElement:''' the MTA element hit if any, ''nil'' otherwise<br />
*'''normalX, normalY, normalZ:''' the normal of the surface hit<br />
*'''material:''' an integer representing the [[Material IDs|GTASA material ID]] of the surface hit when applicable (world, objects)<br />
*'''lighting:''' a float between 0 (fully dark) and 1 (bright) representing the amount of light that the hit building surface will transfer to peds or vehicles that are in contact with it. The value can be affected by the game time of day, usually with a lower (darker) value being returned during the night.<br />
*'''piece:''' an integer representing the part of the element hit if hitElement is a vehicle or a ped/player, ''0'' otherwise. <br />
**For a ped/player, piece represents the body part hit:<br />
{{BodyParts}}<br />
**For vehicles, piece represents the vehicle part hit:<br />
{{VehicleParts}}<br />
*'''worldModelID:''' If includeWorldModelInformation was set to ''true'' and a world model was hit, this will contain the model ID.<br />
*'''worldModelPositionX,Y,Z:''' If worldModelID is set, this will contain the world model position.<br />
*'''worldModelRotationX,Y,Z:''' If worldModelID is set, this will contain the world model rotation.<br />
*'''worldLODModelID:''' If worldModelID is set, this will contain the LOD model ID if applicable.<br />
<br />
==Examples== <br />
This example shows how you can tell what position and element the camera is looking at, up to 50 units away.<br />
<syntaxhighlight lang="lua"><br />
local w, h = guiGetScreenSize ()<br />
local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 )<br />
local px, py, pz = getCameraMatrix()<br />
hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz )<br />
if hit then<br />
outputChatBox ( "Looking at " .. x .. ", " .. y .. ", " .. z )<br />
if elementHit then<br />
outputChatBox ( "Hit element " .. getElementType(elementHit) )<br />
end<br />
end<br />
</syntaxhighlight><br />
This example shows how you can get the surface type a vehicle is on. This is useful if you want to do a script to dirt cars over time. Please note that this function doesn't count if the vehicle is streamed in or not, so expect this function to fail or return incorrect values on unloaded vehicles.<br />
<syntaxhighlight lang="lua"><br />
function getSurfaceVehicleIsOn(vehicle)<br />
if isElement(vehicle) and (isVehicleOnGround(vehicle) or isElementInWater(vehicle)) then -- Is an element and is touching any surface?<br />
local cx, cy, cz = getElementPosition(vehicle) -- Get the position of the vehicle<br />
local gz = getGroundPosition(cx, cy, cz) - 0.001 -- Get the Z position of the ground the vehicle is on (-0.001 because of processLineOfSight)<br />
local hit, _, _, _, _, _, _, _, surface = processLineOfSight(cx, cy, cz, cx, cy, gz) -- This will get the material of the thing the car is standing on<br />
if hit then<br />
return surface -- If everything is correct, stop executing this function and return the surface type<br />
end<br />
end<br />
return false -- If something isn't correct, return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Changelog==<br />
{{ChangelogHeader}}<br />
{{ChangelogItem|1.3.0-9.04273|''bIncludeCarTyres'' argument added}}<br />
{{ChangelogItem|1.3.0-9.04273|''worldModelID'' return value fixed}}<br />
{{ChangelogItem|1.3.0-9.04405|''lighting'' return value fixed}}<br />
<br />
==See Also==<br />
{{Client world functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=ProcessLineOfSight&diff=66878ProcessLineOfSight2020-06-09T22:59:01Z<p>Einheit-101: Added information that shootThroughStuff argument has no effect and processLineOfSight will always collide with these collision materials, no matter what you specify.</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function casts a ray between two points in the world, and tells you information about the point that was hit, if any. The two positions '''must''' be within the local player's draw distance as the collision data is not loaded outside this area, and the call will just fail as if the ray didn't hit.<br />
<br />
This function is relatively expensive to call, so over use of this in scripts may have a detrimental effect on performance.<br />
<br />
This function is useful for checking for collisions and for editor-style scripts. If you wish to find what element is positioned at a particular point on the screen, use this function combined with [[getWorldFromScreenPosition]]. If you wish to just know if something is hit, and don't care about what or where was hit, use [[isLineOfSightClear]].<br />
<br />
==Syntax== <br />
Return values labelled for ease of reference.<br />
<syntaxhighlight lang="lua"><br />
bool -- hit<br />
float float float -- hitX, hitY, hitZ<br />
element -- hitElement<br />
float float float -- normalX, normalY, normalZ<br />
int -- material<br />
float -- lighting<br />
int -- piece<br />
int -- worldModelID<br />
float float float -- worldModelPositionX,Y,Z<br />
float float float -- worldModelRotationX,Y,Z<br />
int -- worldLODModelID<br />
processLineOfSight ( float startX, float startY, float startZ, <br />
float endX, float endY, float endZ, <br />
[ bool checkBuildings = true, <br />
bool checkVehicles = true, <br />
bool checkPlayers = true, <br />
bool checkObjects = true, <br />
bool checkDummies = true, <br />
bool seeThroughStuff = false, <br />
bool ignoreSomeObjectsForCamera = false, <br />
bool shootThroughStuff = false, <br />
element ignoredElement = nil,<br />
bool includeWorldModelInformation = false,<br />
bool bIncludeCarTyres ] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''startX:''' The start ''x'' position<br />
*'''startY:''' The start ''y'' position<br />
*'''startZ:''' The start ''z'' position<br />
*'''endX:''' The end ''x'' position<br />
*'''endY:''' The end ''y'' position<br />
*'''endZ:''' The end ''z'' position<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.<br />
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].<br />
*'''checkPlayers:''' Allow the line of sight to be blocked by [[Player|players]].<br />
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].<br />
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''.<br />
*'''seeThroughStuff:''' Allow the line of sight to be blocked by collision materials that have this flag enabled (By default material IDs 52, 55 and 66 which are some fences that you can shoot throug but still walk on them).<br />
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to pass through objects that have (K) property enabled in "object.dat" data file. (i.e. Most dynamic objects like boxes or barrels)<br />
*'''shootThroughStuff:''' Allow the line of sight to be blocked by collision materials that have this flag enabled (By default material IDs 28, 29, 31, 32, 33, 74, 75, 76, 77, 78, 79, 96, 97, 98, 99, 100 which are exclusively sand / beach or underwater objects). This argument has currently no effect due to a bug, that means this argument is always TRUE.<br />
*'''ignoredElement:''' Allow the line of sight to pass through a certain specified element. This is usually set to the object you are tracing from so it does not interfere with the results.<br />
*'''includeWorldModelInformation :''' Include the results of hitting a world model.<br />
*'''bIncludeCarTyres :''' Includes car tyre hits.<br />
<br />
===Returns===<br />
*'''hit:''' ''true'' if there is a collision, ''false'' otherwise<br />
The other values are only filled if there is a collision, they contain ''nil'' otherwise<br />
*'''hitX, hitY, hitZ:''' collision position<br />
*'''hitElement:''' the MTA element hit if any, ''nil'' otherwise<br />
*'''normalX, normalY, normalZ:''' the normal of the surface hit<br />
*'''material:''' an integer representing the [[Material IDs|GTASA material ID]] of the surface hit when applicable (world, objects)<br />
*'''lighting:''' a float between 0 (fully dark) and 1 (bright) representing the amount of light that the hit building surface will transfer to peds or vehicles that are in contact with it. The value can be affected by the game time of day, usually with a lower (darker) value being returned during the night.<br />
*'''piece:''' an integer representing the part of the element hit if hitElement is a vehicle or a ped/player, ''0'' otherwise. <br />
**For a ped/player, piece represents the body part hit:<br />
{{BodyParts}}<br />
**For vehicles, piece represents the vehicle part hit:<br />
{{VehicleParts}}<br />
*'''worldModelID:''' If includeWorldModelInformation was set to ''true'' and a world model was hit, this will contain the model ID.<br />
*'''worldModelPositionX,Y,Z:''' If worldModelID is set, this will contain the world model position.<br />
*'''worldModelRotationX,Y,Z:''' If worldModelID is set, this will contain the world model rotation.<br />
*'''worldLODModelID:''' If worldModelID is set, this will contain the LOD model ID if applicable.<br />
<br />
==Examples== <br />
This example shows how you can tell what position and element the camera is looking at, up to 50 units away.<br />
<syntaxhighlight lang="lua"><br />
local w, h = guiGetScreenSize ()<br />
local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 )<br />
local px, py, pz = getCameraMatrix()<br />
hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz )<br />
if hit then<br />
outputChatBox ( "Looking at " .. x .. ", " .. y .. ", " .. z )<br />
if elementHit then<br />
outputChatBox ( "Hit element " .. getElementType(elementHit) )<br />
end<br />
end<br />
</syntaxhighlight><br />
This example shows how you can get the surface type a vehicle is on. This is useful if you want to do a script to dirt cars over time. Please note that this function doesn't count if the vehicle is streamed in or not, so expect this function to fail or return incorrect values on unloaded vehicles.<br />
<syntaxhighlight lang="lua"><br />
function getSurfaceVehicleIsOn(vehicle)<br />
if isElement(vehicle) and (isVehicleOnGround(vehicle) or isElementInWater(vehicle)) then -- Is an element and is touching any surface?<br />
local cx, cy, cz = getElementPosition(vehicle) -- Get the position of the vehicle<br />
local gz = getGroundPosition(cx, cy, cz) - 0.001 -- Get the Z position of the ground the vehicle is on (-0.001 because of processLineOfSight)<br />
local hit, _, _, _, _, _, _, _, surface = processLineOfSight(cx, cy, cz, cx, cy, gz) -- This will get the material of the thing the car is standing on<br />
if hit then<br />
return surface -- If everything is correct, stop executing this function and return the surface type<br />
end<br />
end<br />
return false -- If something isn't correct, return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Changelog==<br />
{{ChangelogHeader}}<br />
{{ChangelogItem|1.3.0-9.04273|''bIncludeCarTyres'' argument added}}<br />
{{ChangelogItem|1.3.0-9.04273|''worldModelID'' return value fixed}}<br />
{{ChangelogItem|1.3.0-9.04405|''lighting'' return value fixed}}<br />
<br />
==See Also==<br />
{{Client world functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=IsLineOfSightClear&diff=66877IsLineOfSightClear2020-06-09T22:10:53Z<p>Einheit-101: </p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function checks if there are obstacles between two points of the game world, optionally ignoring certain kinds of elements. Use [[processLineOfSight]] if you want more information about what the ray hits.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool isLineOfSightClear ( float startX, float startY, float startZ, float endX, float endY, float endZ, [ bool checkBuildings = true, bool checkVehicles = true, bool checkPeds = true,<br />
bool checkObjects = true, bool checkDummies = true, bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, element ignoredElement = nil ] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
*'''startX:''' The first point's world X coordinate.<br />
*'''startY:''' The first point's world Y coordinate.<br />
*'''startZ:''' The first point's world Z coordinate.<br />
*'''endX:''' The second point's world X coordinate.<br />
*'''endY:''' The second point's world Y coordinate.<br />
*'''endZ:''' The second point's world Z coordinate.<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.<br />
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].<br />
*'''checkPeds:''' Allow the line of sight to be blocked by peds, i.e. [[Player|players]].<br />
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].<br />
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''.<br />
*'''seeThroughStuff:''' Allow the line of sight to be blocked by collision materials that have this flag enabled (By default material IDs 52, 55 and 66 which are some fences). This flag originally allows some objects to be walked on but you can shoot throug them.<br />
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to pass through objects that have (K) property enabled in "object.dat" data file. (i.e. Most dynamic objects like boxes or barrels)<br />
*'''ignoredElement:''' Allow the line of sight to pass through a certain specified element.<br />
<br />
===Returns===<br />
Returns ''true'' if the line between the specified points is clear, ''false'' if there's an obstacle or if invalid parameters are passed.<br />
<br />
==Example== <br />
<section name="Client" class="client" show="false"><br />
isLineOfSightClear is the economical way to cast a ray in the world. <br />
This example demonstrates how you can easily implement basic NPC behaviour such as jumping obstacles. A 3D line is drawn connecting the two points in the ray.<br />
<syntaxhighlight lang="lua"><br />
local t_Data = {}<br />
<br />
local function updateNPC ()<br />
if (not isElement(t_Data.ped) or (getElementHealth(t_Data.ped) == 0)) then<br />
return toggleNPCFollower ()<br />
end<br />
<br />
local t_PlayerPos = {getElementPosition(localPlayer)}<br />
local t_PedPos = {getElementPosition(t_Data.ped)}<br />
<br />
local intDistance = getDistanceBetweenPoints3D (t_PedPos[1], t_PedPos[2], t_PedPos[3], unpack(t_PlayerPos))<br />
if (intDistance < 4) then<br />
setPedControlState (t_Data.ped, 'forwards', false)<br />
return true<br />
end<br />
<br />
-- Calculate the rotation between ped and player position<br />
local intPedRot = -math.deg (math.atan2(t_PlayerPos[1] - t_PedPos[1], t_PlayerPos[2] - t_PedPos[2]))<br />
if intPedRot < 0 then intPedRot = intPedRot + 360 end;<br />
<br />
setElementRotation (t_Data.ped, 0, 0, intPedRot, 'default', true)<br />
-- At this point we know that the ped needs to move it<br />
setPedControlState (t_Data.ped, 'forwards', true)<br />
<br />
local bPathClear = true<br />
local t_Matrix = getElementMatrix (t_Data.ped)<br />
<br />
-- Calculate a position 1m ahead of ped<br />
local int_RayX = t_Matrix[2][1] + t_Matrix[4][1]<br />
local int_RayY = t_Matrix[2][2] + t_Matrix[4][2]<br />
local int_RayZ = t_Matrix[2][3] + t_Matrix[4][3]<br />
<br />
-- We cast 10 rays 1m ahead of the ped<br />
for i = 1, 10 do<br />
local intSourceX, intSourceY, intSourceZ = t_PedPos[1], t_PedPos[2], t_PedPos[3]<br />
<br />
-- The target position height is identical to the center of the ped (1m above ground) <br />
-- We lower this value by 0.5m to detect short obstacles<br />
local intTargetX, intTargetY, intTargetZ = int_RayX, int_RayY, int_RayZ - 0.5 + i*0.2<br />
<br />
bPathClear = isLineOfSightClear (intSourceX, intSourceY, intSourceZ, intTargetX, intTargetY, intTargetZ, true, true, false, true)<br />
dxDrawLine3D (intSourceX, intSourceY, intSourceZ, intTargetX, intTargetY, intTargetZ, bPathClear and tocolor(255,255,255,255) or tocolor(255,0,0,255))<br />
<br />
if (not bPathClear) then<br />
break<br />
end<br />
end<br />
<br />
if (not bPathClear) then<br />
setPedControlState (t_Data.ped, 'jump', true)<br />
else<br />
setPedControlState (t_Data.ped, 'jump', false)<br />
end<br />
<br />
if (intDistance > 15) then<br />
setPedControlState (t_Data.ped, 'sprint', true)<br />
else<br />
setPedControlState (t_Data.ped, 'sprint', false)<br />
end<br />
end<br />
<br />
function toggleNPCFollower ()<br />
if (t_Data.ped) then<br />
if (t_Data.updateNPCTimer) then<br />
if (isTimer(t_Data.updateNPCTimer)) then<br />
killTimer (t_Data.updateNPCTimer)<br />
end<br />
end<br />
if (isElement(t_Data.ped)) then<br />
destroyElement (t_Data.ped)<br />
end<br />
t_Data.ped = nil<br />
return true<br />
end<br />
<br />
local intX, intY, intZ = getElementPosition (localPlayer)<br />
local _, _, intRZ = getElementRotation (localPlayer)<br />
local t_Matrix = getElementMatrix (localPlayer)<br />
<br />
-- Calculate a position 4m behind local player<br />
local intPedX = -4 * t_Matrix[2][1] + t_Matrix[4][1]<br />
local intPedY = -4 * t_Matrix[2][2] + t_Matrix[4][2]<br />
local intPedZ = -4 * t_Matrix[2][3] + t_Matrix[4][3]<br />
<br />
t_Data.ped = createPed (0, intPedX, intPedY, intPedZ, intRZ)<br />
t_Data.updateNPCTimer = setTimer (updateNPC, 50, 0)<br />
end<br />
addCommandHandler ('npc', toggleNPCFollower)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client world functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=ProcessLineOfSight&diff=66876ProcessLineOfSight2020-06-09T22:10:05Z<p>Einheit-101: shootThroughStuff has nothing to do with "shooting through", that flag is used by some riverbed / beach objects that cant be shot through. It is actually seeThroughStuff that controls what you can shoot and what not, it is used by some fences.</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function casts a ray between two points in the world, and tells you information about the point that was hit, if any. The two positions '''must''' be within the local player's draw distance as the collision data is not loaded outside this area, and the call will just fail as if the ray didn't hit.<br />
<br />
This function is relatively expensive to call, so over use of this in scripts may have a detrimental effect on performance.<br />
<br />
This function is useful for checking for collisions and for editor-style scripts. If you wish to find what element is positioned at a particular point on the screen, use this function combined with [[getWorldFromScreenPosition]]. If you wish to just know if something is hit, and don't care about what or where was hit, use [[isLineOfSightClear]].<br />
<br />
==Syntax== <br />
Return values labelled for ease of reference.<br />
<syntaxhighlight lang="lua"><br />
bool -- hit<br />
float float float -- hitX, hitY, hitZ<br />
element -- hitElement<br />
float float float -- normalX, normalY, normalZ<br />
int -- material<br />
float -- lighting<br />
int -- piece<br />
int -- worldModelID<br />
float float float -- worldModelPositionX,Y,Z<br />
float float float -- worldModelRotationX,Y,Z<br />
int -- worldLODModelID<br />
processLineOfSight ( float startX, float startY, float startZ, <br />
float endX, float endY, float endZ, <br />
[ bool checkBuildings = true, <br />
bool checkVehicles = true, <br />
bool checkPlayers = true, <br />
bool checkObjects = true, <br />
bool checkDummies = true, <br />
bool seeThroughStuff = false, <br />
bool ignoreSomeObjectsForCamera = false, <br />
bool shootThroughStuff = false, <br />
element ignoredElement = nil,<br />
bool includeWorldModelInformation = false,<br />
bool bIncludeCarTyres ] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''startX:''' The start ''x'' position<br />
*'''startY:''' The start ''y'' position<br />
*'''startZ:''' The start ''z'' position<br />
*'''endX:''' The end ''x'' position<br />
*'''endY:''' The end ''y'' position<br />
*'''endZ:''' The end ''z'' position<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.<br />
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].<br />
*'''checkPlayers:''' Allow the line of sight to be blocked by [[Player|players]].<br />
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].<br />
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''.<br />
*'''seeThroughStuff:''' Allow the line of sight to be blocked by collision materials that have this flag enabled (By default material IDs 52, 55 and 66 which are some fences that you can shoot throug but still walk on them).<br />
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to pass through objects that have (K) property enabled in "object.dat" data file. (i.e. Most dynamic objects like boxes or barrels)<br />
*'''shootThroughStuff:''' Allow the line of sight to be blocked by collision materials that have this flag enabled (By default material IDs 28, 29, 31, 32, 33, 74, 75, 76, 77, 78, 79, 96, 97, 98, 99, 100 which are exclusively sand / beach or underwater objects).<br />
*'''ignoredElement:''' Allow the line of sight to pass through a certain specified element. This is usually set to the object you are tracing from so it does not interfere with the results.<br />
*'''includeWorldModelInformation :''' Include the results of hitting a world model.<br />
*'''bIncludeCarTyres :''' Includes car tyre hits.<br />
<br />
===Returns===<br />
*'''hit:''' ''true'' if there is a collision, ''false'' otherwise<br />
The other values are only filled if there is a collision, they contain ''nil'' otherwise<br />
*'''hitX, hitY, hitZ:''' collision position<br />
*'''hitElement:''' the MTA element hit if any, ''nil'' otherwise<br />
*'''normalX, normalY, normalZ:''' the normal of the surface hit<br />
*'''material:''' an integer representing the [[Material IDs|GTASA material ID]] of the surface hit when applicable (world, objects)<br />
*'''lighting:''' a float between 0 (fully dark) and 1 (bright) representing the amount of light that the hit building surface will transfer to peds or vehicles that are in contact with it. The value can be affected by the game time of day, usually with a lower (darker) value being returned during the night.<br />
*'''piece:''' an integer representing the part of the element hit if hitElement is a vehicle or a ped/player, ''0'' otherwise. <br />
**For a ped/player, piece represents the body part hit:<br />
{{BodyParts}}<br />
**For vehicles, piece represents the vehicle part hit:<br />
{{VehicleParts}}<br />
*'''worldModelID:''' If includeWorldModelInformation was set to ''true'' and a world model was hit, this will contain the model ID.<br />
*'''worldModelPositionX,Y,Z:''' If worldModelID is set, this will contain the world model position.<br />
*'''worldModelRotationX,Y,Z:''' If worldModelID is set, this will contain the world model rotation.<br />
*'''worldLODModelID:''' If worldModelID is set, this will contain the LOD model ID if applicable.<br />
<br />
==Examples== <br />
This example shows how you can tell what position and element the camera is looking at, up to 50 units away.<br />
<syntaxhighlight lang="lua"><br />
local w, h = guiGetScreenSize ()<br />
local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 )<br />
local px, py, pz = getCameraMatrix()<br />
hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz )<br />
if hit then<br />
outputChatBox ( "Looking at " .. x .. ", " .. y .. ", " .. z )<br />
if elementHit then<br />
outputChatBox ( "Hit element " .. getElementType(elementHit) )<br />
end<br />
end<br />
</syntaxhighlight><br />
This example shows how you can get the surface type a vehicle is on. This is useful if you want to do a script to dirt cars over time. Please note that this function doesn't count if the vehicle is streamed in or not, so expect this function to fail or return incorrect values on unloaded vehicles.<br />
<syntaxhighlight lang="lua"><br />
function getSurfaceVehicleIsOn(vehicle)<br />
if isElement(vehicle) and (isVehicleOnGround(vehicle) or isElementInWater(vehicle)) then -- Is an element and is touching any surface?<br />
local cx, cy, cz = getElementPosition(vehicle) -- Get the position of the vehicle<br />
local gz = getGroundPosition(cx, cy, cz) - 0.001 -- Get the Z position of the ground the vehicle is on (-0.001 because of processLineOfSight)<br />
local hit, _, _, _, _, _, _, _, surface = processLineOfSight(cx, cy, cz, cx, cy, gz) -- This will get the material of the thing the car is standing on<br />
if hit then<br />
return surface -- If everything is correct, stop executing this function and return the surface type<br />
end<br />
end<br />
return false -- If something isn't correct, return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Changelog==<br />
{{ChangelogHeader}}<br />
{{ChangelogItem|1.3.0-9.04273|''bIncludeCarTyres'' argument added}}<br />
{{ChangelogItem|1.3.0-9.04273|''worldModelID'' return value fixed}}<br />
{{ChangelogItem|1.3.0-9.04405|''lighting'' return value fixed}}<br />
<br />
==See Also==<br />
{{Client world functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=IsLineOfSightClear&diff=66875IsLineOfSightClear2020-06-09T22:06:54Z<p>Einheit-101: seeThroughStuff is actually stuff that you can shoot through (Fences etc), i added this information and what material IDs are connected with it.</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function checks if there are obstacles between two points of the game world, optionally ignoring certain kinds of elements. Use [[processLineOfSight]] if you want more information about what the ray hits.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool isLineOfSightClear ( float startX, float startY, float startZ, float endX, float endY, float endZ, [ bool checkBuildings = true, bool checkVehicles = true, bool checkPeds = true,<br />
bool checkObjects = true, bool checkDummies = true, bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, element ignoredElement = nil ] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
*'''startX:''' The first point's world X coordinate.<br />
*'''startY:''' The first point's world Y coordinate.<br />
*'''startZ:''' The first point's world Z coordinate.<br />
*'''endX:''' The second point's world X coordinate.<br />
*'''endY:''' The second point's world Y coordinate.<br />
*'''endZ:''' The second point's world Z coordinate.<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.<br />
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].<br />
*'''checkPeds:''' Allow the line of sight to be blocked by peds, i.e. [[Player|players]].<br />
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].<br />
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''.<br />
*'''seeThroughStuff:''' Allow the line of sight to be blocked by materials that have this flag enabled (By default material IDs 52, 55 and 66 which are some fences). This flag originally allows some objects to be walked on but you can shoot throug them.<br />
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to pass through objects that have (K) property enabled in "object.dat" data file. (i.e. Most dynamic objects like boxes or barrels)<br />
*'''ignoredElement:''' Allow the line of sight to pass through a certain specified element.<br />
<br />
===Returns===<br />
Returns ''true'' if the line between the specified points is clear, ''false'' if there's an obstacle or if invalid parameters are passed.<br />
<br />
==Example== <br />
<section name="Client" class="client" show="false"><br />
isLineOfSightClear is the economical way to cast a ray in the world. <br />
This example demonstrates how you can easily implement basic NPC behaviour such as jumping obstacles. A 3D line is drawn connecting the two points in the ray.<br />
<syntaxhighlight lang="lua"><br />
local t_Data = {}<br />
<br />
local function updateNPC ()<br />
if (not isElement(t_Data.ped) or (getElementHealth(t_Data.ped) == 0)) then<br />
return toggleNPCFollower ()<br />
end<br />
<br />
local t_PlayerPos = {getElementPosition(localPlayer)}<br />
local t_PedPos = {getElementPosition(t_Data.ped)}<br />
<br />
local intDistance = getDistanceBetweenPoints3D (t_PedPos[1], t_PedPos[2], t_PedPos[3], unpack(t_PlayerPos))<br />
if (intDistance < 4) then<br />
setPedControlState (t_Data.ped, 'forwards', false)<br />
return true<br />
end<br />
<br />
-- Calculate the rotation between ped and player position<br />
local intPedRot = -math.deg (math.atan2(t_PlayerPos[1] - t_PedPos[1], t_PlayerPos[2] - t_PedPos[2]))<br />
if intPedRot < 0 then intPedRot = intPedRot + 360 end;<br />
<br />
setElementRotation (t_Data.ped, 0, 0, intPedRot, 'default', true)<br />
-- At this point we know that the ped needs to move it<br />
setPedControlState (t_Data.ped, 'forwards', true)<br />
<br />
local bPathClear = true<br />
local t_Matrix = getElementMatrix (t_Data.ped)<br />
<br />
-- Calculate a position 1m ahead of ped<br />
local int_RayX = t_Matrix[2][1] + t_Matrix[4][1]<br />
local int_RayY = t_Matrix[2][2] + t_Matrix[4][2]<br />
local int_RayZ = t_Matrix[2][3] + t_Matrix[4][3]<br />
<br />
-- We cast 10 rays 1m ahead of the ped<br />
for i = 1, 10 do<br />
local intSourceX, intSourceY, intSourceZ = t_PedPos[1], t_PedPos[2], t_PedPos[3]<br />
<br />
-- The target position height is identical to the center of the ped (1m above ground) <br />
-- We lower this value by 0.5m to detect short obstacles<br />
local intTargetX, intTargetY, intTargetZ = int_RayX, int_RayY, int_RayZ - 0.5 + i*0.2<br />
<br />
bPathClear = isLineOfSightClear (intSourceX, intSourceY, intSourceZ, intTargetX, intTargetY, intTargetZ, true, true, false, true)<br />
dxDrawLine3D (intSourceX, intSourceY, intSourceZ, intTargetX, intTargetY, intTargetZ, bPathClear and tocolor(255,255,255,255) or tocolor(255,0,0,255))<br />
<br />
if (not bPathClear) then<br />
break<br />
end<br />
end<br />
<br />
if (not bPathClear) then<br />
setPedControlState (t_Data.ped, 'jump', true)<br />
else<br />
setPedControlState (t_Data.ped, 'jump', false)<br />
end<br />
<br />
if (intDistance > 15) then<br />
setPedControlState (t_Data.ped, 'sprint', true)<br />
else<br />
setPedControlState (t_Data.ped, 'sprint', false)<br />
end<br />
end<br />
<br />
function toggleNPCFollower ()<br />
if (t_Data.ped) then<br />
if (t_Data.updateNPCTimer) then<br />
if (isTimer(t_Data.updateNPCTimer)) then<br />
killTimer (t_Data.updateNPCTimer)<br />
end<br />
end<br />
if (isElement(t_Data.ped)) then<br />
destroyElement (t_Data.ped)<br />
end<br />
t_Data.ped = nil<br />
return true<br />
end<br />
<br />
local intX, intY, intZ = getElementPosition (localPlayer)<br />
local _, _, intRZ = getElementRotation (localPlayer)<br />
local t_Matrix = getElementMatrix (localPlayer)<br />
<br />
-- Calculate a position 4m behind local player<br />
local intPedX = -4 * t_Matrix[2][1] + t_Matrix[4][1]<br />
local intPedY = -4 * t_Matrix[2][2] + t_Matrix[4][2]<br />
local intPedZ = -4 * t_Matrix[2][3] + t_Matrix[4][3]<br />
<br />
t_Data.ped = createPed (0, intPedX, intPedY, intPedZ, intRZ)<br />
t_Data.updateNPCTimer = setTimer (updateNPC, 50, 0)<br />
end<br />
addCommandHandler ('npc', toggleNPCFollower)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client world functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=ProcessLineOfSight&diff=66874ProcessLineOfSight2020-06-09T22:03:41Z<p>Einheit-101: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function casts a ray between two points in the world, and tells you information about the point that was hit, if any. The two positions '''must''' be within the local player's draw distance as the collision data is not loaded outside this area, and the call will just fail as if the ray didn't hit.<br />
<br />
This function is relatively expensive to call, so over use of this in scripts may have a detrimental effect on performance.<br />
<br />
This function is useful for checking for collisions and for editor-style scripts. If you wish to find what element is positioned at a particular point on the screen, use this function combined with [[getWorldFromScreenPosition]]. If you wish to just know if something is hit, and don't care about what or where was hit, use [[isLineOfSightClear]].<br />
<br />
==Syntax== <br />
Return values labelled for ease of reference.<br />
<syntaxhighlight lang="lua"><br />
bool -- hit<br />
float float float -- hitX, hitY, hitZ<br />
element -- hitElement<br />
float float float -- normalX, normalY, normalZ<br />
int -- material<br />
float -- lighting<br />
int -- piece<br />
int -- worldModelID<br />
float float float -- worldModelPositionX,Y,Z<br />
float float float -- worldModelRotationX,Y,Z<br />
int -- worldLODModelID<br />
processLineOfSight ( float startX, float startY, float startZ, <br />
float endX, float endY, float endZ, <br />
[ bool checkBuildings = true, <br />
bool checkVehicles = true, <br />
bool checkPlayers = true, <br />
bool checkObjects = true, <br />
bool checkDummies = true, <br />
bool seeThroughStuff = false, <br />
bool ignoreSomeObjectsForCamera = false, <br />
bool shootThroughStuff = false, <br />
element ignoredElement = nil,<br />
bool includeWorldModelInformation = false,<br />
bool bIncludeCarTyres ] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''startX:''' The start ''x'' position<br />
*'''startY:''' The start ''y'' position<br />
*'''startZ:''' The start ''z'' position<br />
*'''endX:''' The end ''x'' position<br />
*'''endY:''' The end ''y'' position<br />
*'''endZ:''' The end ''z'' position<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.<br />
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].<br />
*'''checkPlayers:''' Allow the line of sight to be blocked by [[Player|players]].<br />
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].<br />
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''.<br />
*'''seeThroughStuff:''' Allow the line of sight to be blocked by objects that have this flag enabled (By default material IDs 52, 55 and 66 which are some fences).<br />
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to pass through objects that have (K) property enabled in "object.dat" data file. (i.e. Most dynamic objects like boxes or barrels)<br />
*'''shootThroughStuff:''' Allow the line of sight to be blocked by objects that have this flag enabled (By default material IDs 28, 29, 31, 32, 33, 74, 75, 76, 77, 78, 79, 96, 97, 98, 99, 100 which are exclusively sand / beach or underwater objects).<br />
*'''ignoredElement:''' Allow the line of sight to pass through a certain specified element. This is usually set to the object you are tracing from so it does not interfere with the results.<br />
*'''includeWorldModelInformation :''' Include the results of hitting a world model.<br />
*'''bIncludeCarTyres :''' Includes car tyre hits.<br />
<br />
===Returns===<br />
*'''hit:''' ''true'' if there is a collision, ''false'' otherwise<br />
The other values are only filled if there is a collision, they contain ''nil'' otherwise<br />
*'''hitX, hitY, hitZ:''' collision position<br />
*'''hitElement:''' the MTA element hit if any, ''nil'' otherwise<br />
*'''normalX, normalY, normalZ:''' the normal of the surface hit<br />
*'''material:''' an integer representing the [[Material IDs|GTASA material ID]] of the surface hit when applicable (world, objects)<br />
*'''lighting:''' a float between 0 (fully dark) and 1 (bright) representing the amount of light that the hit building surface will transfer to peds or vehicles that are in contact with it. The value can be affected by the game time of day, usually with a lower (darker) value being returned during the night.<br />
*'''piece:''' an integer representing the part of the element hit if hitElement is a vehicle or a ped/player, ''0'' otherwise. <br />
**For a ped/player, piece represents the body part hit:<br />
{{BodyParts}}<br />
**For vehicles, piece represents the vehicle part hit:<br />
{{VehicleParts}}<br />
*'''worldModelID:''' If includeWorldModelInformation was set to ''true'' and a world model was hit, this will contain the model ID.<br />
*'''worldModelPositionX,Y,Z:''' If worldModelID is set, this will contain the world model position.<br />
*'''worldModelRotationX,Y,Z:''' If worldModelID is set, this will contain the world model rotation.<br />
*'''worldLODModelID:''' If worldModelID is set, this will contain the LOD model ID if applicable.<br />
<br />
==Examples== <br />
This example shows how you can tell what position and element the camera is looking at, up to 50 units away.<br />
<syntaxhighlight lang="lua"><br />
local w, h = guiGetScreenSize ()<br />
local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 )<br />
local px, py, pz = getCameraMatrix()<br />
hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz )<br />
if hit then<br />
outputChatBox ( "Looking at " .. x .. ", " .. y .. ", " .. z )<br />
if elementHit then<br />
outputChatBox ( "Hit element " .. getElementType(elementHit) )<br />
end<br />
end<br />
</syntaxhighlight><br />
This example shows how you can get the surface type a vehicle is on. This is useful if you want to do a script to dirt cars over time. Please note that this function doesn't count if the vehicle is streamed in or not, so expect this function to fail or return incorrect values on unloaded vehicles.<br />
<syntaxhighlight lang="lua"><br />
function getSurfaceVehicleIsOn(vehicle)<br />
if isElement(vehicle) and (isVehicleOnGround(vehicle) or isElementInWater(vehicle)) then -- Is an element and is touching any surface?<br />
local cx, cy, cz = getElementPosition(vehicle) -- Get the position of the vehicle<br />
local gz = getGroundPosition(cx, cy, cz) - 0.001 -- Get the Z position of the ground the vehicle is on (-0.001 because of processLineOfSight)<br />
local hit, _, _, _, _, _, _, _, surface = processLineOfSight(cx, cy, cz, cx, cy, gz) -- This will get the material of the thing the car is standing on<br />
if hit then<br />
return surface -- If everything is correct, stop executing this function and return the surface type<br />
end<br />
end<br />
return false -- If something isn't correct, return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Changelog==<br />
{{ChangelogHeader}}<br />
{{ChangelogItem|1.3.0-9.04273|''bIncludeCarTyres'' argument added}}<br />
{{ChangelogItem|1.3.0-9.04273|''worldModelID'' return value fixed}}<br />
{{ChangelogItem|1.3.0-9.04405|''lighting'' return value fixed}}<br />
<br />
==See Also==<br />
{{Client world functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=GetPedAnimation&diff=65416GetPedAnimation2020-03-17T15:16:51Z<p>Einheit-101: Added changes made by Dezash</p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
<br />
Gets the animation of a player or ped that was set using [[setPedAnimation]].<br />
{{Note|Use [[getPedTask]] to monitor what movements the player is currently doing.''}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
string, string getPedAnimation ( ped thePed )<br />
</syntaxhighlight><br />
{{OOP||[[ped]]:getAnimation||setPedAnimation}}<br />
<br />
===Required Arguments===<br />
*'''thePed:''' the [[player]] or [[ped]] you want to get the [[animations|animation]] of.<br />
<br />
===Returns===<br />
Returns two [[string|strings]]: the first is the name of the block, the second is the name of the animation. Returns ''false'' if there was an error or if the ped is not doing an animation.<br />
<br />
<br />
{{New feature/item|3.0160|1.5.7|20450|<syntaxhighlight lang="lua"> string, string, int, int, bool, bool, bool, int, bool getPedAnimation ( ped thePed )</syntaxhighlight><br />
<br />
'''The function now returns 9 values in the same order as required by setPedAnimation:'''<br />
<syntaxhighlight lang="lua">string anim, string block, int time, bool loop, bool updatePosition, bool interruptable, bool freezeLastFrame, int blendTime, bool restoreTaskOnAnimEnd</syntaxhighlight><br />
}}<br />
<br />
<br />
==Example==<br />
This example adds a command that allows you to copy the animation being used by another player using /copyanim theirName<br />
<syntaxhighlight lang="lua"><br />
function CopyAnimation(theCommand, thePlayer) -- The Command Function<br />
if thePlayer then -- If a player name entered then<br />
thePlayerToCopyFrom = getPlayerFromName(thePlayer) -- get player from his name<br />
Block, Anim = getPedAnimation(thePlayerToCopyFrom) -- get the player animation<br />
if Block then -- if got the animation successfully then<br />
setPedAnimation(localPlayer, Block, Anim) -- set my animation the same<br />
outputChatBox("* Copied Successfully !") -- output chat message<br />
end<br />
else <br />
outputChatBox("* Please Enter a Player Name To Copy From !") -- if you didnt entered a player name , then output a chat box message<br />
end<br />
end<br />
addCommandHandler("copyanim", CopyAnimation) -- adding the Command Handler<br />
</syntaxhighlight><br />
<br />
==Example 2==<br />
<br />
This example shows what block and animation your player is currently performing. Note this will return "N/A" if you did not set an animation with [[setPedAnimation]]. If you want to see what the player ped is doing as you control them that is [[getPedTask]].<br />
<syntaxhighlight lang="lua"><br />
addEventHandler("onClientPreRender",root,<br />
function ()<br />
local block, animation = getPedAnimation(localPlayer)<br />
dxDrawText ( "CURRENT ANIMATION INFO...", 100, 300 )<br />
if not block then block = "N/A" end<br />
if not animation then animation = "N/A" end<br />
dxDrawText ( "Block = "..block.." Animation = "..animation, 100, 315 )<br />
end )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_ped_functions}}<br />
<br />
[[hu:getPedAnimation]]</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=SetPedAnimation&diff=64565SetPedAnimation2019-10-26T00:24:56Z<p>Einheit-101: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
<br />
Sets the current [[Animations|animation]] of a [[player]] or [[ped]]. Not specifying the type of animation will automatically cancel the current one.<br />
{{Warning|It is possible that an animation will be cancelled if you use setElementFrozen on the ped, but this does not happen all the time.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPedAnimation ( ped thePed [, string block = nil, string anim = nil, int time = -1, bool loop = true, bool updatePosition = true,<br />
bool interruptable = true, bool freezeLastFrame = true, int blendTime = 250, bool retainPedState = false ] )<br />
</syntaxhighlight><br />
{{OOP||[[ped]]:setAnimation||getPedAnimation}}<br />
<br />
===Required Arguments===<br />
*'''thePed:''' the [[player]] or [[ped]] you want to apply an [[Animations|animation]] to.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
*'''block:''' the [[Animations|animation]] block's name.<br />
*'''anim:''' the name of the [[Animations|animation]] within the block.<br />
*'''time:''' how long the animation will run for in milliseconds.<br />
*'''loop:''' indicates whether or not the animation will loop.<br />
*'''updatePosition:''' will change the actual coordinates of the ped according to the animation. Use this for e.g. walking animations.<br />
*'''interruptable:''' if set to ''false'' other tasks wont be able to interupt the animation. Setting this to 'false' also gives this function more power to override other animations that are running. For example, squatting after a jump can be terminated.<br />
*'''freezeLastFrame:''' if set to ''true'' after animation the last frame will be frozen, otherwise the animation will end and controls will return.<br />
*'''blendTime:''' how long the animation will mixed with the previous one in milliseconds.<br />
{{New items|3.0157|1.5.7|<br />
*'''retainPedState:''' will restore the task which was playing before calling this function. Useful for restoring the crouch task after animation ends. This may be extended in the future to support other states/tasks.<br />
|16632}}<br />
<br />
===Returns===<br />
Returns ''true'' if succesful, ''false'' otherwise.<br />
<br />
==Examples==<br />
<br />
<section name="Server" class="server" show="true"><br />
This example creates a ped, rotates him, and makes him walk:<br />
<syntaxhighlight lang="lua"><br />
function makePed()<br />
local thePed = createPed(56, 1, 1, 4, 315)<br />
setPedAnimation(thePed, "ped", "WOMAN_walknorm")<br />
end<br />
addCommandHandler("makemyped", makePed)<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This example makes the player sit down and stand up using the command /sit.<br />
<syntaxhighlight lang="lua"><br />
function toggleSit(thePlayer)<br />
if not getElementData(thePlayer, "sitting") then<br />
setPedAnimation(thePlayer, "ped", "seat_down", -1, false, false, false, false)<br />
setElementData(thePlayer, "sitting", true)<br />
else<br />
-- If you use again this command then your character stand up<br />
setPedAnimation(thePlayer)<br />
removeElementData(thePlayer, "sitting")<br />
end<br />
end<br />
addCommandHandler("sit", toggleSit)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Changelog==<br />
{{ChangelogHeader}}<br />
{{ChangelogItem|1.5.7-9.16632|Added retainPedState argument}}<br />
<br />
==Issues==<br />
{{Issues|<br />
{{Issue|1110|retainPedState in setPedAnimation() does not work when latency reduction is set to 1}}<br />
{{Issue|1090|A replaced "weapon_crouch" animation gets reset to default when using setPedAnimation()}}<br />
{{Issue|953|setPedAnimation() "interrupt" and "time" has no effect in certain situations}}<br />
{{Issue|512|setPedAnimation isn't synced properly on server side}}<br />
{{Issue|467|Ped animations don't sync for new players}}<br />
}}<br />
<br />
==See Also==<br />
{{Ped_functions}}<br />
[[ru:setPedAnimation]]<br />
[[HU:setPedAnimation]]</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=SetPedAnimation&diff=64517SetPedAnimation2019-10-14T00:16:37Z<p>Einheit-101: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
<br />
Sets the current [[Animations|animation]] of a [[player]] or [[ped]]. Not specifying the type of animation will automatically cancel the current one.<br />
{{Warning|It is possible that an animation will be cancelled if you use setElementFrozen on the ped, but this does not happen all the time.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPedAnimation ( ped thePed [, string block = nil, string anim = nil, int time = -1, bool loop = true, bool updatePosition = true,<br />
bool interruptable = true, bool freezeLastFrame = true, int blendTime = 250, bool retainPedState = false ] )<br />
</syntaxhighlight><br />
{{OOP||[[ped]]:setAnimation||getPedAnimation}}<br />
<br />
===Required Arguments===<br />
*'''thePed:''' the [[player]] or [[ped]] you want to apply an [[Animations|animation]] to.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
*'''block:''' the [[Animations|animation]] block's name.<br />
*'''anim:''' the name of the [[Animations|animation]] within the block.<br />
*'''time:''' how long the animation will run for in milliseconds.<br />
*'''loop:''' indicates whether or not the animation will loop.<br />
*'''updatePosition:''' will change the actual coordinates of the ped according to the animation. Use this for e.g. walking animations.<br />
*'''interruptable:''' if set to ''false'' other tasks wont be able to interupt the animation. Setting this to 'false' also gives this function more power to override other animations that are running. For example, squatting after a jump can be terminated.<br />
*'''freezeLastFrame:''' if set to ''true'' after animation the last frame will be frozen, otherwise the animation will end and controls will return.<br />
*'''blendTime:''' how long the animation will mixed with the previous one in milliseconds.<br />
{{New items|3.0157|1.5.7|<br />
*'''retainPedState:''' will restore the task which was playing before calling this function. Useful for restoring the crouch task after animation ends. This may be extended in the future to support other states/tasks.<br />
|16632}}<br />
<br />
===Returns===<br />
Returns ''true'' if succesful, ''false'' otherwise.<br />
<br />
==Examples==<br />
<br />
<section name="Server" class="server" show="true"><br />
This example creates a ped, rotates him, and makes him walk:<br />
<syntaxhighlight lang="lua"><br />
function makePed()<br />
local thePed = createPed(56, 1, 1, 4, 315)<br />
setPedAnimation(thePed, "ped", "WOMAN_walknorm")<br />
end<br />
addCommandHandler("makemyped", makePed)<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This example makes the player sit down and stand up using the command /sit.<br />
<syntaxhighlight lang="lua"><br />
function toggleSit(thePlayer)<br />
if not getElementData(thePlayer, "sitting") then<br />
setPedAnimation(thePlayer, "ped", "seat_down", -1, false, false, false, false)<br />
setElementData(thePlayer, "sitting", true)<br />
else<br />
-- If you use again this command then your character stand up<br />
setPedAnimation(thePlayer)<br />
removeElementData(thePlayer, "sitting")<br />
end<br />
end<br />
addCommandHandler("sit", toggleSit)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Issues==<br />
{{Issues|<br />
{{Issue|1110|retainPedState in setPedAnimation() does not work when latency reduction is set to 1}}<br />
{{Issue|1090|retainPedState can reset a replaced crouch idle animation to default}}<br />
{{Issue|953|setPedAnimation() "interrupt" and "time" has no effect in certain situations}}<br />
{{Issue|512|setPedAnimation isn't synced properly on server side}}<br />
{{Issue|467|Ped animations don't sync for new players}}<br />
}}<br />
<br />
==See Also==<br />
{{Ped_functions}}<br />
[[ru:setPedAnimation]]<br />
[[HU:setPedAnimation]]</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=SetPedAnimation&diff=64516SetPedAnimation2019-10-14T00:13:22Z<p>Einheit-101: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
<br />
Sets the current [[Animations|animation]] of a [[player]] or [[ped]]. Not specifying the type of animation will automatically cancel the current one.<br />
{{Warning|The animation will be cancelled if you use setElementFrozen on the ped.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPedAnimation ( ped thePed [, string block = nil, string anim = nil, int time = -1, bool loop = true, bool updatePosition = true,<br />
bool interruptable = true, bool freezeLastFrame = true, int blendTime = 250, bool retainPedState = false ] )<br />
</syntaxhighlight><br />
{{OOP||[[ped]]:setAnimation||getPedAnimation}}<br />
<br />
===Required Arguments===<br />
*'''thePed:''' the [[player]] or [[ped]] you want to apply an [[Animations|animation]] to.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
*'''block:''' the [[Animations|animation]] block's name.<br />
*'''anim:''' the name of the [[Animations|animation]] within the block.<br />
*'''time:''' how long the animation will run for in milliseconds.<br />
*'''loop:''' indicates whether or not the animation will loop.<br />
*'''updatePosition:''' will change the actual coordinates of the ped according to the animation. Use this for e.g. walking animations.<br />
*'''interruptable:''' if set to ''false'' other tasks wont be able to interupt the animation. Setting this to 'false' also gives this function more power to override other animations that are running. For example, squatting after a jump can be terminated.<br />
*'''freezeLastFrame:''' if set to ''true'' after animation the last frame will be frozen, otherwise the animation will end and controls will return.<br />
*'''blendTime:''' how long the animation will mixed with the previous one in milliseconds.<br />
{{New items|3.0157|1.5.7|<br />
*'''retainPedState:''' will restore the task which was playing before calling this function. Useful for restoring the crouch task after animation ends. This may be extended in the future to support other states/tasks.<br />
|16632}}<br />
<br />
===Returns===<br />
Returns ''true'' if succesful, ''false'' otherwise.<br />
<br />
==Examples==<br />
<br />
<section name="Server" class="server" show="true"><br />
This example creates a ped, rotates him, and makes him walk:<br />
<syntaxhighlight lang="lua"><br />
function makePed()<br />
local thePed = createPed(56, 1, 1, 4, 315)<br />
setPedAnimation(thePed, "ped", "WOMAN_walknorm")<br />
end<br />
addCommandHandler("makemyped", makePed)<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This example makes the player sit down and stand up using the command /sit.<br />
<syntaxhighlight lang="lua"><br />
function toggleSit(thePlayer)<br />
if not getElementData(thePlayer, "sitting") then<br />
setPedAnimation(thePlayer, "ped", "seat_down", -1, false, false, false, false)<br />
setElementData(thePlayer, "sitting", true)<br />
else<br />
-- If you use again this command then your character stand up<br />
setPedAnimation(thePlayer)<br />
removeElementData(thePlayer, "sitting")<br />
end<br />
end<br />
addCommandHandler("sit", toggleSit)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Issues==<br />
{{Issues|<br />
{{Issue|1110|retainPedState in setPedAnimation() does not work when latency reduction is set to 1}}<br />
{{Issue|1090|retainPedState can reset a replaced crouch idle animation to default}}<br />
{{Issue|953|setPedAnimation() "interrupt" and "time" has no effect in certain situations}}<br />
{{Issue|512|setPedAnimation isn't synced properly on server side}}<br />
{{Issue|467|Ped animations don't sync for new players}}<br />
}}<br />
<br />
==See Also==<br />
{{Ped_functions}}<br />
[[ru:setPedAnimation]]<br />
[[HU:setPedAnimation]]</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=AttachElements&diff=62041AttachElements2019-01-26T00:55:41Z<p>Einheit-101: attachElements is compatible with Peds, this information was missing.</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function attaches one element to another, so that the first one follows the second whenever it moves. <br />
<br />
If an attempt is made to attach two elements that are already attached the opposite way (eg theElement becomes theAttachToElement and vice versa), the 1st attachment order is automatically detached in favor of the 2nd attachment order. For example, if carA was attached to carB, now carB is attached to carA. Also, an element cannot be attached to two separate elements at one time. For example, two cars can be attached to one single car, but one single car cannot be attached to two separate cars. If you attempt to do this, the existing attachment will automatically be dropped in favor of the new attachment. For example, if carA is asked to attached to carB then carC, it is only attached to carC.<br />
<br />
This is not compatible with all elements. The following elements are compatible:<br />
* [[Marker]]s<br />
* [[Blip]]s<br />
* [[Object]]s<br />
* [[Player]]s<br />
* [[Ped]]s<br />
* [[Vehicle]]s<br />
* [[Sound]]s<br />
* [[Colshape]]s<br />
* [[Camera]]s<br />
* [[createWeapon|Weapons]]<br />
<br />
'''Note:''' The offset coodinates reflect the object space, not the world space. This means that you cannot calculate the exact offsets between two objects by pre-positioning them in the map editor as a reference. Please see [[attachElementsOffsets]] for more details.<br />
<br />
'''Note #2:''' Due to a limitation in GTA, unexpected attach rotations may occur if all rotation offsets are non-zero. (i.e. Try to ensure at least one of 'xRotOffset', 'yRotOffset' or 'zRotOffset' is zero)<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool attachElements ( element theElement, element theAttachToElement, [ float xPosOffset = 0, float yPosOffset = 0, float zPosOffset = 0, float xRotOffset = 0, float yRotOffset = 0, float zRotOffset = 0 ] )<br />
</syntaxhighlight> <br />
{{OOP||[[element]]:attach||detachElements}}<br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The element to be attached.<br />
*'''theAttachToElement:''' The element to attach the first to.<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''xPosOffset:''' The x offset, if you want the elements to be a certain distance from one another (default 0).<br />
*'''yPosOffset:''' The y offset (default 0).<br />
*'''zPosOffset:''' The z offset (default 0).<br />
*'''xRotOffset:''' The x rotation offset (default 0).<br />
*'''yRotOffset:''' The y rotation offset (default 0).<br />
*'''zRotOffset:''' The z rotation offset (default 0).<br />
<br />
===Returns===<br />
Returns ''true'' if the attaching process was successful, ''false'' otherwise.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
'''Example 1:''' This example attaches a marker to the player who steals the Mr. Whoopee:<br />
<syntaxhighlight lang="lua"><br />
-- create the vehicle<br />
local vehicleMrWhoopee = createVehicle ( 423, 237.472, -54.225, 1.518, 0, 354.488, 0 )<br />
<br />
function onMrWhoopeeEnter ( thePlayer, seat, jackedPlayer )<br />
outputChatBox ( getPlayerName ( thePlayer ) .. " stole the Whoopee!", root, 255, 0, 0 )<br />
-- create the marker to attach<br />
local arrowMarker = createMarker ( 0, 0, 0, "arrow", .75, 255, 0, 0, 170 )<br />
-- attach the marker to the player with a vertical offset of 2 units<br />
attachElements ( arrowMarker, thePlayer, 0, 0, 2 )<br />
end<br />
<br />
-- attach it to an event<br />
addEventHandler ( "onVehicleEnter", vehicleMrWhoopee, onMrWhoopeeEnter )<br />
</syntaxhighlight><br />
'''Example 2:''' This function adds a tank on top of a player (for extra defense):<br />
<syntaxhighlight lang="lua"><br />
function tankHat ( source, commandName )<br />
local x, y, z = getElementPosition ( source ) --Get the players position<br />
local tank = createVehicle ( 432, x, y, z + 5 ) --Create a tank<br />
attachElements ( tank, source, 0, 0, 5 ) --Attach the tank to the player.<br />
end<br />
addCommandHandler ( "hat", tankHat )<br />
</syntaxhighlight><br />
</section><br />
<section name="Client" class="client" show="true"><br />
'''Example 3:''' This function adds a tank on top of a player (for extra defense), clientside. This means it will be invisible to other players.<br />
<syntaxhighlight lang="lua"><br />
function tankHat (commandName)<br />
local position = Vector3(getElementPosition (localPlayer)) -- Get the players position<br />
local tank = createVehicle ( 432, position.x, position.y, position.z + 5 ) -- Create a tank<br />
attachElements (tank,localPlayer, 0, 0, 5 ) -- Attach the tank to the player.<br />
end<br />
addCommandHandler( "hat", tankHat )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Element functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=GetWaterLevel&diff=60928GetWaterLevel2018-11-26T02:14:40Z<p>Einheit-101: Added a bug to this site. TODO: Issue # needs to refer to github in future!</p>
<hr />
<div>__NOTOC__<br />
{{Client function}} <br />
This function allows you to retrieve the water level from a certain location. The water level is 0 in most places though it can vary (e.g. it's higher near the dam).<br />
{{Note|Some small water areas within parts of the city do not count as water to be used with this function. For example, the shallow water area in Northwest San Fierro.}}<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
float getWaterLevel ( float posX, float posY, float posZ [ , bool bCheckWaves = false ] )<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
float getWaterLevel ( water theWater )<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 />
''or:''<br />
*'''theWater:''' the water element<br />
<br />
===Optional Arguments=== <br />
*'''bCheckWaves''' Include the water levels of waves in the ocean, lakes and ...<br />
<br />
===Returns===<br />
Returns an ''integer'' of the water level if the [[localPlayer]]/position is near the water (-3 to 20 on the Z coordinate) else ''false'' if there's no water near the [[localPlayer]]/position.<br />
<br />
==Example==<br />
This example will tell you what's the water level where the specified player is located.<br />
<syntaxhighlight lang="lua"><br />
function scriptGetLevel ( command, playername ) --when getlevel 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 ) -- get his position<br />
local level = getWaterLevel ( x, y, z )<br />
if level then -- if it's not false<br />
level = z - level -- calculate how far away is he from the water<br />
outputChatBox( "You are " .. level .. " units away from the water!", source )<br />
else outputChatBox ( "There's no sign of water" )<br />
end<br />
else outputChatBox ( "Player does not exist" )<br />
end<br />
end<br />
addCommandHandler( "getlevel", scriptGetLevel ) -- add a command "getloc" which<br />
</syntaxhighlight><br />
<br />
== Issues ==<br />
{{Issues|<br />
{{Issue|458|bCheckWaves argument does not work: https://github.com/multitheftauto/mtasa-blue/issues/458}}<br />
}}<br />
<br />
==See Also==<br />
{{Client water functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=Template:Element_functions&diff=58588Template:Element functions2018-08-27T23:12:29Z<p>Einheit-101: added set/getElementAngularVelocity</p>
<hr />
<div>*[[attachElements]]<br />
*[[clearElementVisibleTo]]<br />
*[[cloneElement]]<br />
*[[createElement]]<br />
*[[destroyElement]]<br />
*[[detachElements]]<br />
*[[getAllElementData]]<br />
*[[getAttachedElements]]<br />
*[[getElementAlpha]]<br />
*[[getElementAttachedOffsets]]<br />
*[[getElementAttachedTo]]<br />
*[[getElementCollisionsEnabled]]<br />
*[[getElementByID]]<br />
*[[getElementByIndex]]<br />
*[[getElementChild]]<br />
*[[getElementChildren]]<br />
*[[getElementChildrenCount]]<br />
*[[getElementColShape]]<br />
*[[getElementData]]<br />
*[[getElementDimension]]<br />
*[[getElementHealth]]<br />
*[[getElementID]]<br />
*[[getElementInterior]]<br />
*[[getElementMatrix]]<br />
*[[getElementModel]]<br />
*[[getElementParent]]<br />
*[[getElementPosition]]<br />
*[[getElementRotation]]<br />
*[[getElementSyncer]]<br />
*[[getElementType]]<br />
*[[getElementVelocity]]<br />
*[[getElementZoneName]]<br />
*[[getElementsByType]]<br />
*[[getElementsWithinColShape]]<br />
*[[getLowLODElement]]<br />
*[[getRootElement]]<br />
*[[isElement]]<br />
*[[isElementAttached]]<br />
*[[isElementCallPropagationEnabled]]<br />
*[[isElementDoubleSided]]<br />
*[[isElementFrozen]]<br />
*[[isElementInWater]]<br />
*[[isElementLowLOD]]<br />
*[[isElementVisibleTo]]<br />
*[[isElementWithinColShape]]<br />
*[[removeElementData]]<br />
*[[setElementAlpha]]<br />
*[[setElementAttachedOffsets]]<br />
*[[setElementCallPropagationEnabled]]<br />
*[[setElementCollisionsEnabled]]<br />
*[[setElementData]]<br />
*[[setElementDimension]]<br />
*[[setElementDoubleSided]]<br />
*[[setElementFrozen]]<br />
*[[setElementHealth]]<br />
*[[setElementID]]<br />
*[[setElementInterior]]<br />
*[[setElementModel]]<br />
*[[setElementParent]]<br />
*[[setElementPosition]]<br />
*[[setElementRotation]]<br />
*[[setElementSyncer]]<br />
*[[setElementVelocity]]<br />
{{New items|3.0156|1.5.5|<br />
* [[setElementAngularVelocity]]<br />
* [[getElementAngularVelocity]]<br />
|14060}}<br />
*[[setElementVisibleTo]]<br />
*[[setLowLODElement]]<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Einheit-101https://wiki.multitheftauto.com/index.php?title=Template:Client_element_functions&diff=58587Template:Client element functions2018-08-27T23:11:40Z<p>Einheit-101: added set/getElementAngularVelocity</p>
<hr />
<div>*[[attachElements]]<br />
*[[createElement]]<br />
*[[destroyElement]]<br />
*[[detachElements]]<br />
*[[getAttachedElements]]<br />
*[[getElementAlpha]]<br />
*[[getElementAttachedOffsets]]<br />
*[[getElementAttachedTo]]<br />
*[[getElementBoundingBox]]<br />
*[[getElementByID]]<br />
*[[getElementChild]]<br />
*[[getElementChildren]]<br />
*[[getElementChildrenCount]]<br />
*[[getElementColShape]]<br />
*[[getElementCollisionsEnabled]]<br />
*[[getElementData]]<br />
*[[getElementDimension]]<br />
*[[getElementDistanceFromCentreOfMassToBaseOfModel]]<br />
*[[getElementHealth]]<br />
*[[getElementID]]<br />
*[[getElementInterior]]<br />
*[[getElementMatrix]]<br />
*[[getElementModel]]<br />
*[[getElementParent]]<br />
*[[getElementPosition]]<br />
*[[getElementRadius]]<br />
*[[getElementRotation]]<br />
*[[getElementType]]<br />
*[[getElementVelocity]]<br />
*[[getElementsByType]]<br />
*[[getElementsWithinColShape]]<br />
{{New items|3.0156|1.5.5|<br />
*[[getElementsWithinRange]]<br />
|13823}}<br />
*[[getLowLODElement]]<br />
*[[getRootElement]]<br />
*[[isElement]]<br />
*[[isElementAttached]]<br />
*[[isElementCallPropagationEnabled]]<br />
*[[isElementCollidableWith]]<br />
*[[isElementDoubleSided]]<br />
*[[isElementFrozen]]<br />
*[[isElementInWater]]<br />
*[[isElementLocal]]<br />
*[[isElementLowLOD]]<br />
*[[isElementOnScreen]]<br />
*[[isElementStreamable]]<br />
*[[isElementStreamedIn]]<br />
*[[isElementSyncer]]<br />
*[[isElementWaitingForGroundToLoad]]<br />
*[[isElementWithinColShape]]<br />
*[[setElementAlpha]]<br />
*[[setElementAttachedOffsets]]<br />
*[[setElementCallPropagationEnabled]]<br />
*[[setElementCollidableWith]]<br />
*[[setElementCollisionsEnabled]]<br />
*[[setElementData]]<br />
*[[setElementDimension]]<br />
*[[setElementDoubleSided]]<br />
*[[setElementFrozen]]<br />
*[[setElementHealth]]<br />
*[[setElementID]]<br />
*[[setElementInterior]]<br />
*[[setElementMatrix]]<br />
*[[setElementModel]]<br />
*[[setElementParent]]<br />
*[[setElementPosition]]<br />
*[[setElementRotation]]<br />
*[[setElementStreamable]]<br />
*[[setElementVelocity]]<br />
{{New items|3.0156|1.5.5|<br />
* [[setElementAngularVelocity]]<br />
* [[getElementAngularVelocity]]<br />
|14060}}<br />
*[[setLowLODElement]]<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Einheit-101https://wiki.multitheftauto.com/index.php?title=Template:Server_functions&diff=58586Template:Server functions2018-08-27T23:09:46Z<p>Einheit-101: added set/getElementAngularVelocity (Is this the right place?? Confusing.)</p>
<hr />
<div>*[[addCommandHandler]]<br />
*[[executeCommandHandler]]<br />
*[[getCommandHandlers]]<br />
*[[getFPSLimit]]<br />
*[[getMaxPlayers]]<br />
*[[getServerHttpPort]]<br />
*[[getServerName]]<br />
*[[getServerPassword]]<br />
*[[getServerPort]]<br />
*[[getVersion]]<br />
*[[isGlitchEnabled]]<br />
*[[outputChatBox]]<br />
*[[outputConsole]]<br />
*[[outputDebugString]]<br />
*[[outputServerLog]]<br />
*[[removeCommandHandler]]<br />
*[[setFPSLimit]]<br />
*[[setGlitchEnabled]]<br />
*[[setMaxPlayers]]<br />
*[[setServerPassword]]<br />
*[[showChat]]<br />
{{New items|3.0156|1.5.6|<br />
* [[clearChatBox]]<br />
|12286}}<br />
{{New items|3.0156|1.5.5|<br />
* [[setElementAngularVelocity]]<br />
* [[getElementAngularVelocity]]<br />
|14060}}<br />
*[[shutdown]]<br />
<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Einheit-101https://wiki.multitheftauto.com/index.php?title=GetElementAngularVelocity&diff=58585GetElementAngularVelocity2018-08-27T22:58:14Z<p>Einheit-101: First creation (please check if that info is correct, i am no c++ expert)</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
{{New feature/item|3.0156|1.5.5|14060|Gets the current angular velocity of a specified, supported element.}}<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool getElementAngularVelocity ( element theElement ) <br />
</syntaxhighlight> <br />
{{OOP||[[element]]:getAngularVelocity|angularVelocity|setElementAngularVelocity}}<br />
===Required Arguments=== <br />
*'''theElement:''' The [[element]] to retrieve the angular velocity from. Can be either a [[player]], [[ped]], [[object]], [[vehicle]] or a [[Element/Weapon|custom weapon]]. '''Server side supports only vehicles currently.'''<br />
<br />
===Returns===<br />
Returns ''true'' if it was succesful, ''false'' otherwise.<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler("getangularvelocity", function(player)<br />
--retrieve angular velocity of the player<br />
local avx, avy, avz = getElementAngularVelocity(player)<br />
outputChatBox("Your current angular velocity is: X: "..avx.." Y: "..avy.." Z: "..avz, player, 0, 255, 0, false)<br />
end)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Element functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=SetElementAngularVelocity&diff=58584SetElementAngularVelocity2018-08-27T22:56:30Z<p>Einheit-101: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
{{New feature/item|3.0156|1.5.5|14060|Sets the angular velocity of a specified, supported element (Applies a spin to it).}}<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool setElementAngularVelocity ( element theElement, float rx, float ry, float rz ) <br />
</syntaxhighlight> <br />
{{OOP||[[element]]:setAngularVelocity|angularVelocity|getElementAngularVelocity}}<br />
===Required Arguments=== <br />
*'''theElement:''' The [[element]] to apply the spin to. Can be either a [[player]], [[ped]], [[object]], [[vehicle]] or a [[Element/Weapon|custom weapon]]. '''Server side supports only vehicles currently.'''<br />
*'''rx:''' velocity around the X axis<br />
*'''ry:''' velocity around the Y axis<br />
*'''rz:''' velocity around the Z axis<br />
<br />
===Returns===<br />
Returns ''true'' if it was succesful, ''false'' otherwise.<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
function onColShapeHit ( thePlayer, matchingDimension )<br />
-- When a player hits the collision shape, give him a spin<br />
setElementAngularVelocity ( thePlayer, 0, 0, 20 )<br />
end<br />
addEventHandler ( "onColShapeHit", root, onColShapeHit )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Element functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=SetElementAngularVelocity&diff=58583SetElementAngularVelocity2018-08-27T22:48:50Z<p>Einheit-101: First creation (please check if that info is correct, i am no c++ expert)</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
Sets the angular velocity of a supported element (Applies a spin to it).<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool setElementAngularVelocity ( element theElement, float rx, float ry, float rz ) <br />
</syntaxhighlight> <br />
{{OOP||[[element]]:setAngularVelocity|angularVelocity|getElementAngularVelocity}}<br />
===Required Arguments=== <br />
*'''theElement:''' The [[element]] to apply the spin to. Can be either a [[player]], [[ped]], [[object]], [[vehicle]] or a [[Element/Weapon|custom weapon]]. '''Server side supports only vehicles currently.'''<br />
*'''rx:''' velocity around the X axis<br />
*'''ry:''' velocity around the Y axis<br />
*'''rz:''' velocity around the Z axis<br />
<br />
===Returns===<br />
Returns ''true'' if it was succesful, ''false'' otherwise.<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
function onColShapeHit ( thePlayer, matchingDimension )<br />
-- When a player hits the collision shape, give him a spin<br />
setElementAngularVelocity ( thePlayer, 0, 0, 20 )<br />
end<br />
addEventHandler ( "onColShapeHit", root, onColShapeHit )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Element functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=GetVehicleTurnVelocity&diff=58582GetVehicleTurnVelocity2018-08-27T22:33:21Z<p>Einheit-101: Added future deprecation hint</p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
This function is used to retrieve a vehicle's turning velocity for each axis.<br />
<br />
{{Deprecated feature|3.0156|1.5.6|This function will be deprecated in '''1.5.6''', use [[getElementAngularVelocity]] in the future.}}<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
float float float getVehicleTurnVelocity ( vehicle theVehicle )<br />
</syntaxhighlight> <br />
{{OOP||[[vehicle]]:getTurnVelocity|turnVelocity|setVehicleTurnVelocity}}<br />
===Required Arguments=== <br />
*'''theVehicle:''' The [[vehicle]] you wish to get the turning velocities of.<br />
<br />
===Returns===<br />
Returns 3 ''floats'' that represent the vehicle's turning velocity on the x, y and z axis or ''false'' if wrong arguments were passed.<br />
<br />
===Example===<br />
<section name="Server" class="server" show="true"><br />
This example shows the current turn velocity of the vehicle that you're in.<br />
<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler("geturnvelocity", function(player)<br />
if not isPedInVehicle(player) then return end<br />
local veh = getPedOccupiedVehicle(player)<br />
local vx, vy, vz = getVehicleTurnVelocity(veh)<br />
outputChatBox("Vehicle's turn velocity is: X: "..vx.." Y: "..vy.." Z: "..vz, player, 0, 255, 0, false)<br />
end)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
<br />
{{Vehicle functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=SetVehicleTurnVelocity&diff=58581SetVehicleTurnVelocity2018-08-27T22:32:54Z<p>Einheit-101: Added future deprecation hint</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
Sets the angular velocity of a vehicle. Basically applies a spin to it.<br />
<br />
{{Deprecated feature|3.0156|1.5.6|This function will be deprecated in '''1.5.6''', use [[setElementAngularVelocity]] in the future.}}<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool setVehicleTurnVelocity ( vehicle theVehicle, float rx, float ry, float rz ) <br />
</syntaxhighlight> <br />
{{OOP||[[vehicle]]:setTurnVelocity|turnVelocity|getVehicleTurnVelocity}}<br />
===Required Arguments=== <br />
*'''theVehicle:''' The [[vehicle]] to apply the spin to.<br />
*'''rx:''' velocity around the X axis<br />
*'''ry:''' velocity around the Y axis<br />
*'''rz:''' velocity around the Z axis<br />
<br />
===Returns===<br />
Returns ''true'' if it was succesful, ''false'' otherwise.<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
function onColShapeHit ( thePlayer, matchingDimension )<br />
-- When a player hits the collision shape, check if he's in a vehicle<br />
local playerVehicle = getPedOccupiedVehicle ( thePlayer )<br />
if playerVehicle ~= false then<br />
-- If so, give it a spin<br />
setVehicleTurnVelocity ( playerVehicle, 0, 0, 20 )<br />
end<br />
end<br />
addEventHandler ( "onColShapeHit", getRootElement ( ), onColShapeHit )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Vehicle functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=FromJSON&diff=51454FromJSON2017-07-01T01:08:13Z<p>Einheit-101: The bug that existed in MTA 1.3.6 is no longer relevant so i removed that warning message.</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
{{New feature/item|3.0140|1.2||<br />
This function is available client-side in 1.2 and onwards.<br />
}}<br />
<br />
This function parses a [[JSON]] formatted string into variables. You can use [[toJSON]] to encode variables into a JSON string that can be read by this function.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
var fromJSON ( string json )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''json:''' A JSON formatted string<br />
<br />
===Returns===<br />
Returns variables read from the JSON string.<br />
<br />
'''Note:''' Indices of a JSON object such as "1": "cat" are being returned as [[string]], not as [[int]]eger.<br />
<br />
==Example== <br />
This makes data equal: ''{ ["1"] = "cat", ["2"] = "mouse", ["3"] = 5, ["4"] = null, ["cat"] = 5, ["mouse"] =1 }''<br />
<syntaxhighlight lang="lua"><br />
local data = fromJSON ( '[ { "1": "cat", "2": "mouse", "3": 5, "4": null, "cat":5, "mouse":1 } ]' )<br />
</syntaxhighlight><br />
<br />
==Example 2==<br />
<syntaxhighlight lang="lua"><br />
local name, weapon, ammo = fromJSON("[\"Desert Eagle\", 24, 147]")<br />
</syntaxhighlight><br />
<br />
==Requirements==<br />
{{Requirements|1.0|1.1.1-9.03316|}}<br />
<br />
==See Also==<br />
{{Server_functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=GetPedControlState&diff=51312GetPedControlState2017-06-19T10:46:34Z<p>Einheit-101: Added the fact that it works with the local player after r11427</p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
Checks whether a ped has a certain control pressed.<br />
<br />
{{New feature/item|3.0160|1.5|11427|<br />
*Works with the local player aswell.<br />
}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPedControlState ( ped thePed, string control )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''thePed:''' the ped you want to check.<br />
*'''control:''' the control to get the status of. See [[control names]] for a list of valid names.<br />
<br />
===Returns===<br />
Returns ''true'' if the ped is pressing the specified control, ''false'' if not or an invalid argument was passed.<br />
<br />
===Example===<br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
local controlTable = {"forwards", "backwards", "left", "right", "jump", "crouch"}<br />
<br />
function invisibleOnSpawn()<br />
setElementAlpha (localPlayer, 0)<br />
checkControlState = setTimer(controlState, 50, 0)<br />
end<br />
addEventHandler ("onClientPlayerSpawn", localPlayer, invisibleOnSpawn)<br />
<br />
function controlState()<br />
for i,control in ipairs(controlTable) do<br />
local state = getPedControlState(localPlayer, control)<br />
if (state) then<br />
setElementAlpha (localPlayer, 255)<br />
if (isTimer(checkControlState)) then<br />
killTimer(checkControlState)<br />
checkControlState = nil<br />
end <br />
end<br />
end<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client ped functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=SetPedControlState&diff=51311SetPedControlState2017-06-19T10:45:12Z<p>Einheit-101: Changed the fact that it now works with the local player just fine after r11427</p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
This function makes a [[ped]] press or release a certain control. It doesn't work with the local player, so use [[setControlState]] instead.<br />
<br />
{{New feature/item|3.0160|1.5|11427|<br />
*Works with local player aswell.<br />
}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPedControlState ( ped thePed, string control, bool state )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''thePed:''' the ped you want to press or release a control.<br />
*'''control:''' the name of the control of which to change the state. See [[control names]] for a list of valid names.<br />
*'''state:''' the new control state. ''true'' means pressed, ''false'' is released.<br />
<br />
===Returns===<br />
Returns ''true'' if successful, ''false'' if otherwise.<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function newPed()<br />
local x, y, z = getElementPosition(localPlayer)<br />
local myPed = createPed(0, x + 1, y, z)<br />
if myPed then <br />
setPedControlState(myPed,"forwards", true)<br />
end <br />
end<br />
addCommandHandler("ped",newPed)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client ped functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=User:Einheit-101&diff=50495User:Einheit-1012017-02-22T21:50:30Z<p>Einheit-101: /* Sites */</p>
<hr />
<div>=Einheit-101=<br />
(Marco Kunz)<br />
<br />
[[File:371940 100003116044889 1093838528 n.jpg]]<br />
<br />
==Overview==<br />
* Born 19th February 1993<br />
* MTA user and scripter since 2010<br />
* Gamemodder since ... too long ago<br />
<br />
==Sites==<br />
<br />
https://www.youtube.com/channel/UC9XyHGZoeQcA9AQQJ1zwDrA<br />
<br />
http://gta-saaw.blogspot.de/<br />
<br />
==Most important creations==<br />
* Some modifications for X³- Terran Conflict (X³ - The Jupiter Incident mod is the biggest, http://forum.egosoft.com/viewtopic.php?t=325895&highlight=)<br />
* Some modifications for Grand Theft Auto San Andreas (Biggest ones: Devastation Weapon Modification, Star Wars Weapons Mod, found on GTAinside.com)<br />
* Small other Mods or Maps for many different games (Rome Total War, Thunder Brigade, Empire Earth, Crashday, IL-2 Sturmovik and maybe some others i forgot over years)<br />
* Many scripts and some W.I.P. giant maps for Multi Theft Auto<br />
* Creator of the famous SAAW Zombie Server (R.I.P. 2011) and creator of SAAW World War 2, work in progress since 2011<br />
<br />
==What is he doing now?==<br />
After giving up the SAAW Zombie Server 2011 i started working on something new, i thought about World War 2 setting in MTA.<br />
Unfortunately MTA 1.0.3 was not far enough for my plans so i had to wait until MTA gets further developed.<br />
Almost 3 years later, at the end of 2013, i decided to continue my work because i have seen the great progress MTA has made (1.3.5).<br />
<br />
SAAW World War 2 has been released in 24th May, 2016 and gets continous updates.</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=User:Einheit-101&diff=50494User:Einheit-1012017-02-22T21:50:20Z<p>Einheit-101: /* Sites</p>
<hr />
<div>=Einheit-101=<br />
(Marco Kunz)<br />
<br />
[[File:371940 100003116044889 1093838528 n.jpg]]<br />
<br />
==Overview==<br />
* Born 19th February 1993<br />
* MTA user and scripter since 2010<br />
* Gamemodder since ... too long ago<br />
<br />
==Sites==<br />
<br />
https://www.youtube.com/channel/UC9XyHGZoeQcA9AQQJ1zwDrA<br />
*/ <br />
http://gta-saaw.blogspot.de/<br />
<br />
==Most important creations==<br />
* Some modifications for X³- Terran Conflict (X³ - The Jupiter Incident mod is the biggest, http://forum.egosoft.com/viewtopic.php?t=325895&highlight=)<br />
* Some modifications for Grand Theft Auto San Andreas (Biggest ones: Devastation Weapon Modification, Star Wars Weapons Mod, found on GTAinside.com)<br />
* Small other Mods or Maps for many different games (Rome Total War, Thunder Brigade, Empire Earth, Crashday, IL-2 Sturmovik and maybe some others i forgot over years)<br />
* Many scripts and some W.I.P. giant maps for Multi Theft Auto<br />
* Creator of the famous SAAW Zombie Server (R.I.P. 2011) and creator of SAAW World War 2, work in progress since 2011<br />
<br />
==What is he doing now?==<br />
After giving up the SAAW Zombie Server 2011 i started working on something new, i thought about World War 2 setting in MTA.<br />
Unfortunately MTA 1.0.3 was not far enough for my plans so i had to wait until MTA gets further developed.<br />
Almost 3 years later, at the end of 2013, i decided to continue my work because i have seen the great progress MTA has made (1.3.5).<br />
<br />
SAAW World War 2 has been released in 24th May, 2016 and gets continous updates.</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=User:Einheit-101&diff=50493User:Einheit-1012017-02-22T21:49:58Z<p>Einheit-101: </p>
<hr />
<div>=Einheit-101=<br />
(Marco Kunz)<br />
<br />
[[File:371940 100003116044889 1093838528 n.jpg]]<br />
<br />
==Overview==<br />
* Born 19th February 1993<br />
* MTA user and scripter since 2010<br />
* Gamemodder since ... too long ago<br />
<br />
==Sites==<br />
<br />
https://www.youtube.com/channel/UC9XyHGZoeQcA9AQQJ1zwDrA<br />
http://gta-saaw.blogspot.de/<br />
<br />
==Most important creations==<br />
* Some modifications for X³- Terran Conflict (X³ - The Jupiter Incident mod is the biggest, http://forum.egosoft.com/viewtopic.php?t=325895&highlight=)<br />
* Some modifications for Grand Theft Auto San Andreas (Biggest ones: Devastation Weapon Modification, Star Wars Weapons Mod, found on GTAinside.com)<br />
* Small other Mods or Maps for many different games (Rome Total War, Thunder Brigade, Empire Earth, Crashday, IL-2 Sturmovik and maybe some others i forgot over years)<br />
* Many scripts and some W.I.P. giant maps for Multi Theft Auto<br />
* Creator of the famous SAAW Zombie Server (R.I.P. 2011) and creator of SAAW World War 2, work in progress since 2011<br />
<br />
==What is he doing now?==<br />
After giving up the SAAW Zombie Server 2011 i started working on something new, i thought about World War 2 setting in MTA.<br />
Unfortunately MTA 1.0.3 was not far enough for my plans so i had to wait until MTA gets further developed.<br />
Almost 3 years later, at the end of 2013, i decided to continue my work because i have seen the great progress MTA has made (1.3.5).<br />
<br />
SAAW World War 2 has been released in 24th May, 2016 and gets continous updates.</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=Lua_matrix_library&diff=49106Lua matrix library2016-09-11T18:31:29Z<p>Einheit-101: Re-uploaded the two LUA files to my Dropbox so the links are no longer dead.</p>
<hr />
<div>The Lua matrix library is a collection of stuff to help with matrix math. The original Lua source for that is here: [https://github.com/davidm/lua-matrix Lua matrix library on github]<br />
<br />
However, we recommend you use the following files as they have been changed slightly to work better with MTA:<br />
:*[https://www.dropbox.com/s/lazx5wytnj8bv73/matrix.lua?dl=0 matrix.lua]<br />
:*[https://www.dropbox.com/s/yjds4ddgs0p23lr/complex.lua?dl=0 complex.lua]</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=OnVehicleWeaponFire&diff=46865OnVehicleWeaponFire2016-03-15T15:07:01Z<p>Einheit-101: SWAT Tank ID 601 was missing in both examples. Added.</p>
<hr />
<div>{{Useful Function}}<br />
__NOTOC__<br />
This code implements an '''event''' that is triggered when a player in a vehicle fires a vehicles weapon. A list of vehicles that have weapons are listed below:<br />
<br />
* Hydra - Fighter Jet (ID: 520)<br />
* Hunter - Assault Helicopter (ID: 425)<br />
* Rustler - World War 2 style fighter (ID: 476)<br />
* Predator - Police Boat with side guns (ID: 430)<br />
* Rhino - Heavily armoured tank (ID: 432)<br />
* Firetruck - Firetruck with sprayable hose (ID: 407)<br />
* S.W.A.T. - Police tank with sprayable hose (ID: 601)<br />
* RC Baron - A mini fighter (ID: 464)<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua">string vehicleFireType, int vehicleModel</syntaxhighlight><br />
<br />
* vehicleFireType: this will be "primary" or "secondary" depending on which player the button pressed.<br />
* vehicleModel: the model number the player is in when they triggered the event.<br />
<br />
==Source==<br />
The source of this event is the player who fired the vehicles gun(s).<br />
<br />
==Code==<br />
<section name="Clientside Script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
armedVehicles = {[425]=true, [520]=true, [476]=true, [447]=true, [430]=true, [432]=true, [464]=true, [407]=true, [601]=true}<br />
function vehicleWeaponFire(key, keyState, vehicleFireType)<br />
local vehModel = getElementModel(getPedOccupiedVehicle(localPlayer))<br />
if (armedVehicles[vehModel]) then<br />
triggerEvent("onClientVehicleWeaponFire", localPlayer, vehicleFireType, vehModel)<br />
end<br />
end<br />
bindKey("vehicle_fire", "down", vehicleWeaponFire, "primary")<br />
bindKey("vehicle_secondary_fire", "down", vehicleWeaponFire, "secondary")<br />
</syntaxhighlight><br />
</section><br />
<section name="Serverside Script" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
armedVehicles = {[425]=true, [520]=true, [476]=true, [447]=true, [430]=true, [432]=true, [464]=true, [407]=true, [601]=true}<br />
function vehicleWeaponFire(thePresser, key, keyState, vehicleFireType)<br />
local vehModel = getElementModel(getPedOccupiedVehicle(thePresser))<br />
if (armedVehicles[vehModel]) then<br />
triggerEvent("onVehicleWeaponFire", thePresser, vehicleFireType, vehModel)<br />
end<br />
end<br />
<br />
function bindOnJoin()<br />
bindKey(source, "vehicle_fire", "down", vehicleWeaponFire, "primary")<br />
bindKey(source, "vehicle_secondary_fire", "down", vehicleWeaponFire, "secondary")<br />
end<br />
addEventHandler("onPlayerJoin", root, bindOnJoin)<br />
<br />
function bindOnStart()<br />
for index, thePlayer in pairs(getElementsByType("player")) do<br />
bindKey(thePlayer, "vehicle_fire", "down", vehicleWeaponFire, "primary")<br />
bindKey(thePlayer, "vehicle_secondary_fire", "down", vehicleWeaponFire, "secondary")<br />
end<br />
end<br />
addEventHandler("onResourceStart", getResourceRootElement(), bindOnStart)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example Code==<br />
<section name="Clientside Example" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function eventVehicleFire(typeOfFire, theModel)<br />
outputChatBox(getPlayerName(source).." fired his "..getVehicleNameFromModel(theModel).."'s weapon ("..typeOfFire..")")<br />
end<br />
addEvent("onClientVehicleWeaponFire", false)<br />
addEventHandler("onClientVehicleWeaponFire", getLocalPlayer(), eventVehicleFire)<br />
</syntaxhighlight><br />
</section><br />
<section name="Serverside Example" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
function eventVehicleFire(typeOfFire, theModel)<br />
outputChatBox(getPlayerName(source).." fired his "..getVehicleNameFromModel(theModel).."'s weapon ("..typeOfFire..")", root, 0, 255, 0)<br />
end<br />
addEvent("onVehicleWeaponFire", false)<br />
addEventHandler("onVehicleWeaponFire", root, eventVehicleFire)<br />
</section><br />
<br />
'''Author: Tuna'''<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=OnVehicleWeaponFire&diff=46864OnVehicleWeaponFire2016-03-15T15:03:47Z<p>Einheit-101: Predator ID in both examples changed from 340 (doensnt exist) to 430 (correct ID)</p>
<hr />
<div>{{Useful Function}}<br />
__NOTOC__<br />
This code implements an '''event''' that is triggered when a player in a vehicle fires a vehicles weapon. A list of vehicles that have weapons are listed below:<br />
<br />
* Hydra - Fighter Jet (ID: 520)<br />
* Hunter - Assault Helicopter (ID: 425)<br />
* Rustler - World War 2 style fighter (ID: 476)<br />
* Predator - Police Boat with side guns (ID: 430)<br />
* Rhino - Heavily armoured tank (ID: 432)<br />
* Firetruck - Firetruck with sprayable hose (ID: 407)<br />
* S.W.A.T. - Police tank with sprayable hose (ID: 601)<br />
* RC Baron - A mini fighter (ID: 464)<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua">string vehicleFireType, int vehicleModel</syntaxhighlight><br />
<br />
* vehicleFireType: this will be "primary" or "secondary" depending on which player the button pressed.<br />
* vehicleModel: the model number the player is in when they triggered the event.<br />
<br />
==Source==<br />
The source of this event is the player who fired the vehicles gun(s).<br />
<br />
==Code==<br />
<section name="Clientside Script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
armedVehicles = {[425]=true, [520]=true, [476]=true, [447]=true, [430]=true, [432]=true, [464]=true, [407]=true}<br />
function vehicleWeaponFire(key, keyState, vehicleFireType)<br />
local vehModel = getElementModel(getPedOccupiedVehicle(localPlayer))<br />
if (armedVehicles[vehModel]) then<br />
triggerEvent("onClientVehicleWeaponFire", localPlayer, vehicleFireType, vehModel)<br />
end<br />
end<br />
bindKey("vehicle_fire", "down", vehicleWeaponFire, "primary")<br />
bindKey("vehicle_secondary_fire", "down", vehicleWeaponFire, "secondary")<br />
</syntaxhighlight><br />
</section><br />
<section name="Serverside Script" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
armedVehicles = {[425]=true, [520]=true, [476]=true, [447]=true, [430]=true, [432]=true, [464]=true, [407]=true}<br />
function vehicleWeaponFire(thePresser, key, keyState, vehicleFireType)<br />
local vehModel = getElementModel(getPedOccupiedVehicle(thePresser))<br />
if (armedVehicles[vehModel]) then<br />
triggerEvent("onVehicleWeaponFire", thePresser, vehicleFireType, vehModel)<br />
end<br />
end<br />
<br />
function bindOnJoin()<br />
bindKey(source, "vehicle_fire", "down", vehicleWeaponFire, "primary")<br />
bindKey(source, "vehicle_secondary_fire", "down", vehicleWeaponFire, "secondary")<br />
end<br />
addEventHandler("onPlayerJoin", root, bindOnJoin)<br />
<br />
function bindOnStart()<br />
for index, thePlayer in pairs(getElementsByType("player")) do<br />
bindKey(thePlayer, "vehicle_fire", "down", vehicleWeaponFire, "primary")<br />
bindKey(thePlayer, "vehicle_secondary_fire", "down", vehicleWeaponFire, "secondary")<br />
end<br />
end<br />
addEventHandler("onResourceStart", getResourceRootElement(), bindOnStart)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example Code==<br />
<section name="Clientside Example" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function eventVehicleFire(typeOfFire, theModel)<br />
outputChatBox(getPlayerName(source).." fired his "..getVehicleNameFromModel(theModel).."'s weapon ("..typeOfFire..")")<br />
end<br />
addEvent("onClientVehicleWeaponFire", false)<br />
addEventHandler("onClientVehicleWeaponFire", getLocalPlayer(), eventVehicleFire)<br />
</syntaxhighlight><br />
</section><br />
<section name="Serverside Example" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
function eventVehicleFire(typeOfFire, theModel)<br />
outputChatBox(getPlayerName(source).." fired his "..getVehicleNameFromModel(theModel).."'s weapon ("..typeOfFire..")", root, 0, 255, 0)<br />
end<br />
addEvent("onVehicleWeaponFire", false)<br />
addEventHandler("onVehicleWeaponFire", root, eventVehicleFire)<br />
</section><br />
<br />
'''Author: Tuna'''<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=DxDrawMaterialLine3D&diff=46863DxDrawMaterialLine3D2016-03-15T01:36:23Z<p>Einheit-101: "width" is definitely a float, not an integer.</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function draws a textured 3D line between two points in the 3D world - rendered for one frame. This should be used in conjunction with [[onClientPreRender]] in order to display continuously.<br />
<br />
The 3D line with a large width value effectively becomes a rectangle, so it it possible to construct basic shapes such as boxes with several large width lines and the appropriate values for 'faceToward'.<br />
<br />
3D lines are drawn at a particular place in the [[Game_Processing_Order|game processing order]], so use [[onClientPreRender]] for drawing if you are attaching them to world elements.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool dxDrawMaterialLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ, element material, float width,<br />
[ int color = white, float faceTowardX, float faceTowardY, float faceTowardZ ] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
* '''startX/Y/Z:''' The start position of the 3D line, representing a coordinate in the GTA world.<br />
* '''endX/Y/Z:''' The end position of the 3D line, representing a coordinate in the GTA world.<br />
* '''material:''' A [[material]] to draw the line with.<br />
* '''width:''' The width/thickness of the line in GTA world units. (This is 1/75th of the width used in dxDrawLine3D)<br />
<br />
==Optional Arguments==<br />
{{OptionalArg}}<br />
* '''color:''' An [[int|integer]] of the hex color, produced using [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).<br />
* '''faceTowardX/Y/Z:''' The position the front of the line should face towards. If this is not set, the camera position is used, so the front of the line faces toward the camera.<br />
<br />
===Returns===<br />
Returns a ''true'' if the operation was successful, ''false'' otherwise.<br />
<br />
==Example== <br />
<section name="Client" class="client" show="true"><br />
Draws an Image ( "test.png" Download : [http://i.epvpimg.com/dwsTe.png test.png] ) from the Position 0,0,3 to 0,0,15<br />
<syntaxhighlight lang="lua">local img = dxCreateTexture("test.png")<br />
addEventHandler("onClientRender", root,<br />
function() -- x,y,z, targetx,targety,targetz,texture,width,color<br />
dxDrawMaterialLine3D (0,0,3,0,0,15,img, 7, tocolor(255,255,255,255))<br />
end)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Requirements==<br />
{{Requirements|n/a|1.3.0-9.03931|}}<br />
<br />
==See Also==<br />
{{Drawing_functions}}</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=User:Einheit-101&diff=41727User:Einheit-1012014-09-07T20:44:46Z<p>Einheit-101: </p>
<hr />
<div>=Einheit-101=<br />
(Marco Kunz)<br />
<br />
[[File:371940 100003116044889 1093838528 n.jpg]]<br />
<br />
==Overview==<br />
* Born 19th February 1993<br />
* MTA user and scripter since 2010<br />
* Gamemodder since ... too long ago<br />
<br />
==Sites==<br />
<br />
https://www.youtube.com/channel/UC9XyHGZoeQcA9AQQJ1zwDrA<br />
<br />
==Most important creations==<br />
* Some modifications for X³- Terran Conflict (X³ - The Jupiter Incident mod is the biggest, http://forum.egosoft.com/viewtopic.php?t=325895&highlight=)<br />
* Some modifications for Grand Theft Auto San Andreas (Biggest ones: Devastation Weapon Modification, Star Wars Weapons Mod, found on GTAinside.com)<br />
* Small other Mods or Maps for many different games (Rome Total War, Thunder Brigade, Empire Earth, Crashday, IL-2 Sturmovik and maybe some others i forgot over years)<br />
* Many scripts and some W.I.P. giant maps for Multi Theft Auto<br />
* Creator of the famous SAAW Zombie Server (R.I.P. 2011) and creator of SAAW World War 2 (Work in progress since 2011 and not released yet due to bugs in MTA)<br />
<br />
==What is he doing now?==<br />
After giving up the SAAW Zombie Server 2011 i started working on something new, i thought about World War 2 setting in MTA.<br />
Unfortunately MTA 1.0.3 was not far enough for my plans so i had to wait until MTA gets further developed.<br />
Almost 3 years later, at the end of 2013, i decided to continue my work because i have seen the great progress MTA has made (1.3.5).<br />
I did a lot of scripting stuff but some bugs still prevent me to finish my work. Only MTA:Eir will be able to render my maps correctly <br />
and only some more bug fixes and feature additions will make the game playable. I hope they will come soon.</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=File:371940_100003116044889_1093838528_n.jpg&diff=41726File:371940 100003116044889 1093838528 n.jpg2014-09-07T20:43:57Z<p>Einheit-101: The Logo of Einheit-101</p>
<hr />
<div>The Logo of Einheit-101</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=User:Einheit-101&diff=41725User:Einheit-1012014-09-07T20:34:16Z<p>Einheit-101: Created page with "=Einheit-101= (Marco Kunz) https://lh5.googleusercontent.com/-Ho-ut0B69To/U7CMv9LAGSI/AAAAAAAAADw/2iZx0Ed5uP8/s250-no/assi.jpg ==Overview== * Born 19th February 1993 * M..."</p>
<hr />
<div>=Einheit-101=<br />
(Marco Kunz)<br />
<br />
[[https://lh5.googleusercontent.com/-Ho-ut0B69To/U7CMv9LAGSI/AAAAAAAAADw/2iZx0Ed5uP8/s250-no/assi.jpg]]<br />
<br />
==Overview==<br />
* Born 19th February 1993<br />
* MTA user and scripter since 2010<br />
* Gamemodder since ... too long ago<br />
<br />
==Sites==<br />
<br />
https://www.youtube.com/channel/UC9XyHGZoeQcA9AQQJ1zwDrA<br />
<br />
==Most important creations==<br />
* Some modifications for X³- Terran Conflict (X³ - The Jupiter Incident mod is the biggest, http://forum.egosoft.com/viewtopic.php?t=325895&highlight=)<br />
* Some modifications for Grand Theft Auto San Andreas (Biggest ones: Devastation Weapon Modification, Star Wars Weapons Mod, found on GTAinside.com)<br />
* Small other Mods or Maps for many different games (Rome Total War, Thunder Brigade, Empire Earth, Crashday, IL-2 Sturmovik and maybe some others i forgot over years)<br />
* Many scripts and some W.I.P. giant maps for Multi Theft Auto<br />
* Creator of the famous SAAW Zombie Server (R.I.P. 2011) and creator of SAAW World War 2 (Work in progress since 2011 and not released yet due to bugs in MTA)<br />
<br />
==What is he doing now?==<br />
After giving up the SAAW Zombie Server 2011 i started working on something new, i thought about World War 2 setting in MTA.<br />
Unfortunately MTA 1.0.3 was not far enough for my plans so i had to wait until MTA gets further developed.<br />
Almost 3 years later, at the end of 2013, i decided to continue my work because i have seen the great progress MTA has made (1.3.5).<br />
I did a lot of scripting stuff but some bugs still prevent me to finish my work. Only MTA:Eir will be able to render my maps correctly <br />
and only some more bug fixes and feature additions will make the game playable. I hope they will come soon.</div>Einheit-101https://wiki.multitheftauto.com/index.php?title=SetVehicleHandling&diff=41724SetVehicleHandling2014-09-07T19:50:19Z<p>Einheit-101: Changing suspension is also disabled for trailers (At least it doesn`t work), so i added this fact.</p>
<hr />
<div>{{Server function}} <br />
__NOTOC__ <br />
This function is used to change the handling data of a vehicle.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool setVehicleHandling ( element theVehicle, string property, var value ) <br />
</syntaxhighlight><br />
<br />
Syntaxes for reset configurations:<br />
<syntaxhighlight lang="lua"><br />
bool setVehicleHandling ( element theVehicle, string property, nil, false ) -- Reset one property to model handling value<br />
bool setVehicleHandling ( element theVehicle, string property, nil, true ) -- Reset one property to GTA default value<br />
bool setVehicleHandling ( element theVehicle, false ) -- Reset all properties to model handling value<br />
bool setVehicleHandling ( element theVehicle, true ) -- Reset all properties to GTA default value<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''theVehicle:''' The vehicle you wish to set the handling of.<br />
*'''property:''' The property you wish to set the handling of the vehicle to.<br />
{{Handling Properties}}<br />
*'''value:''' The value of the property you wish to set the handling of the vehicle to.<br />
<br />
===Returns===<br />
Returns ''true'' if the handling was set successfully, ''false'' otherwise. See below a list of valid propertys and their required values:<br />
<br />
==Notes==<br />
for functionality reasons suspension modification is disabled on monster trucks, trains, boats and trailers.<br />
==Example== <br />
<syntaxhighlight lang="lua"><br />
function massChange ( me, command, mass )<br />
mass = tonumber ( mass ) -- Convert mass to a number<br />
local veh = getPedOccupiedVehicle ( me ) -- Get the player's vehicle<br />
<br />
if mass and veh then -- If valid mass and in a vehicle<br />
local success = setVehicleHandling ( veh, "mass", mass ) -- Set the vehicle's mass, and check if successful<br />
<br />
if success then -- If successful<br />
outputChatBox ( "Your vehicle's mass has been changed to: "..mass.." kg", me, 0, 255, 0 ) -- Notify the player of success<br />
else -- Too bad failure is still an option<br />
outputChatBox ( "Setting mass failed. It's probably above or below allowed limits", me, 255, 0, 0 ) -- Notify the player of failure, and give a possible reason<br />
end<br />
elseif not veh then -- If not in a vehicle<br />
outputChatBox ( "You're not in a vehicle", me, 255, 0, 0 ) -- Tell the player; He / she obviously doesn't know<br />
elseif not mass then -- If not a valid mass<br />
outputChatBox ( "Syntax: /changemass [mass]", me, 255, 0, 0 ) -- Tell the player the proper syntax<br />
end<br />
end<br />
addCommandHandler ( "changemass", massChange )<br />
</syntaxhighlight><br />
<br />
==See other vehicle functions==<br />
{{Vehicle functions}}</div>Einheit-101