GetGaragePosition: Difference between revisions
Jump to navigation
Jump to search
(Example.) |
|||
Line 16: | Line 16: | ||
==Example== | ==Example== | ||
<section name="Client" class="client" show="true"> | <section name="Client" class="client" show="true"> | ||
This element has to create a blip at the nearest garage and removes it in 10 seconds. (untested) | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function getNearestGarageFromElement (element) | ||
local nearestID = -1 | |||
local nearestDistance = 999999999999 | |||
local ex,ey,ez = getElementPosition (element) | |||
for i=0,49 do | |||
local x,y,z = getGaragePosition (i) | |||
if (getDistanceBetweenPoints3D (ex,ey,ez,x,y,z) < nearestDistance) then | |||
local nearestID = i | |||
end | |||
end | |||
return nearestID | |||
end | |||
addCommandHandler ("findgarage", | |||
function(command) | |||
local garageID = getNearestGarageFromElement (getLocalPlayer()) | |||
if (garageID ~= -1) then | |||
local x,y,z = getGaragePosition (garageID) | |||
local garageBlip = createBlip (x,y,z,41) | |||
setTimer ( | |||
function (garageBlip) | |||
destroyElement (garageBlip) | |||
end | |||
,10000,1,garageBlip) | |||
end | |||
end) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Revision as of 11:15, 9 January 2011
This function outputs X, Y and Z position of given garage.
Syntax
float, float, float getGaragePosition ( int garageID )
Required Arguments
- garageID: The garage ID that represents the garage door that is being checked.
Returns
Returns three floats indicating the position of the garage, x, y and z respectively.
Example
Click to collapse [-]
ClientThis element has to create a blip at the nearest garage and removes it in 10 seconds. (untested)
function getNearestGarageFromElement (element) local nearestID = -1 local nearestDistance = 999999999999 local ex,ey,ez = getElementPosition (element) for i=0,49 do local x,y,z = getGaragePosition (i) if (getDistanceBetweenPoints3D (ex,ey,ez,x,y,z) < nearestDistance) then local nearestID = i end end return nearestID end addCommandHandler ("findgarage", function(command) local garageID = getNearestGarageFromElement (getLocalPlayer()) if (garageID ~= -1) then local x,y,z = getGaragePosition (garageID) local garageBlip = createBlip (x,y,z,41) setTimer ( function (garageBlip) destroyElement (garageBlip) end ,10000,1,garageBlip) end end)
See Also
- createSWATRope
- getBirdsEnabled
- getCoronaReflectionsEnabled
- getGarageBoundingBox
- getGaragePosition
- getGarageSize
- getGroundPosition
- getInteriorFurnitureEnabled
- getNearClipDistance
- getPedsLODDistance
- getRoofPosition
- getScreenFromWorldPosition
- getVehiclesLODDistance
- getWorldFromScreenPosition
- isAmbientSoundEnabled
- isLineOfSightClear
- isWorldSoundEnabled
- processLineOfSight
- resetAmbientSounds
- resetBlurLevel
- resetColorFilter
- resetCoronaReflectionsEnabled
- resetNearClipDistance
- resetPedsLODDistance
- resetVehiclesLODDistance
- resetWorldSounds
- setAmbientSoundEnabled
- setBirdsEnabled
- setColorFilter
- setCoronaReflectionsEnabled
- setInteriorFurnitureEnabled
- setInteriorSoundsEnabled
- setNearClipDistance
- setPedsLODDistance
- setVehiclesLODDistance
- setWorldSoundEnabled
- testLineAgainstWater
- areTrafficLightsLocked
- getAircraftMaxHeight
- getAircraftMaxVelocity
- getCloudsEnabled
- getFarClipDistance
- getFogDistance
- getGameSpeed
- getGravity
- getHeatHaze
- getInteriorSoundsEnabled
- getJetpackMaxHeight
- getMinuteDuration
- getMoonSize
- getOcclusionsEnabled
- getRainLevel
- getSunColor
- getSunSize
- getTime
- getTrafficLightState
- getWeather
- getWindVelocity
- getSkyGradient
- getPlayerBlurLevel
- getZoneName
- isGarageOpen
- removeWorldModel
- resetFarClipDistance
- resetFogDistance
- resetHeatHaze
- resetMoonSize
- resetRainLevel
- resetSkyGradient
- resetSunColor
- resetSunSize
- resetWindVelocity
- restoreAllWorldModels
- restoreWorldModel
- setAircraftMaxHeight
- setAircraftMaxVelocity
- setCloudsEnabled
- setFarClipDistance
- setFogDistance
- setGameSpeed
- setGarageOpen
- setGravity
- setHeatHaze
- setInteriorSoundsEnabled
- setMinuteDuration
- setMoonSize
- setOcclusionsEnabled
- setRainLevel
- setSkyGradient
- setSunColor
- setSunSize
- setTime
- setTrafficLightState
- setTrafficLightsLocked
- setWeather
- setWeatherBlended
- setWindVelocity
- setJetpackMaxHeight
- setPlayerBlurLevel