IsElementWaitingForGroundToLoad: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Needs_Checking|Example is wrong? --[[User:MrTasty|MrTasty]] ([[User talk:MrTasty|talk]]) 18:45, 7 August 2014 (UTC)}}
{{Client function}}
{{Server client function}}
__NOTOC__
__NOTOC__
{{New feature/item|3.0140|1.4.0|6715|This function checks if an [[element]] is frozen (unable to move without scripting) waiting until a [[client]] loads collisions of the area it is in. This allows MTA to automatically freeze vehicles when nobody is near them so they don't fall through the map, for example.}}
{{New feature/item|3.0140|1.4.0|6715|This function checks whether MTA has frozen an element because it is above map objects which are still loading or not.}}
{{Note|When vehicles are frozen waiting for collisions to load they '''do not''' overwrite the frozen status set by [[setElementFrozen]].}}
{{Note|When vehicles are frozen waiting for collisions to load they '''do not''' overwrite the frozen status set by [[setElementFrozen]].}}


Line 9: Line 8:
bool isElementWaitingForGroundToLoad ( element theElement )
bool isElementWaitingForGroundToLoad ( element theElement )
</syntaxhighlight>
</syntaxhighlight>
{{New feature/item|3.0141|1.4.0|6987|{{OOP||[[element]]:isWaitingForGroundToLoad|waitingForGroundToLoad}}}}


===Required arguments===
===Required arguments===
* '''theElement:''' the element to check its frozen waiting for collisions to load status. It can be a [[vehicle]], [[ped]] or [[player]].
* '''theElement:''' the element to check its frozen waiting for custom map objects to load status. It can be a [[vehicle]], [[ped]] or [[player]].


===Returns===
===Returns===
Returns ''true'' if the specified [[element]] is frozen waiting for collisions of the area to load. Returns ''false'' if it's not or if the specified variable is invalid.
Returns ''true'' if the specified [[element]] is frozen waiting for collisions of custom map objects to load. Returns ''false'' if it's not or if the specified [[element]] is invalid.


==Example==
==Example==
<section name="Serverside example" class="server" show="true">
<section name="Clientside example" class="client" show="true">
The next code snippet outputs a message when a vehicle respawns far away from players.
The next code snippet outputs a message when a vehicle respawns far away from players, above an [[object]].


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function notifyFarRespawn()
local function notifyFarRespawnOnMap()
     outputChatBox("* A " .. getVehicleName(source) .. " respawned far away! Find it quick!", root, 128, 255, 0)
     if isElementWaitingForGroundToLoad(source) then
        outputChatBox("* A " .. getVehicleName(source) .. " respawned above an object which is far away! Find it quick!", 128, 255, 0)
    end
end
end
addEventHandler("onVehicleRespawn", root, notifyFarRespawn)
addEventHandler("onClientVehicleRespawn", root, notifyFarRespawnOnMap)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Latest revision as of 22:14, 8 August 2018

This function checks whether MTA has frozen an element because it is above map objects which are still loading or not.

[[{{{image}}}|link=|]] Note: When vehicles are frozen waiting for collisions to load they do not overwrite the frozen status set by setElementFrozen.

Syntax

bool isElementWaitingForGroundToLoad ( element theElement )

OOP Syntax Help! I don't understand this!

Method: element:isWaitingForGroundToLoad(...)
Variable: .waitingForGroundToLoad

Required arguments

  • theElement: the element to check its frozen waiting for custom map objects to load status. It can be a vehicle, ped or player.

Returns

Returns true if the specified element is frozen waiting for collisions of custom map objects to load. Returns false if it's not or if the specified element is invalid.

Example

Click to collapse [-]
Clientside example

The next code snippet outputs a message when a vehicle respawns far away from players, above an object.

local function notifyFarRespawnOnMap()
    if isElementWaitingForGroundToLoad(source) then
        outputChatBox("* A " .. getVehicleName(source) .. " respawned above an object which is far away! Find it quick!", 128, 255, 0)
    end
end
addEventHandler("onClientVehicleRespawn", root, notifyFarRespawnOnMap)

See also