GetZoneName: Difference between revisions
Jump to navigation
Jump to search
m (→Example) |
JavadOmidi (talk | contribs) No edit summary |
||
(10 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | |||
This function allows you to retrieve the zone name of a certain location. | This function allows you to retrieve the zone name of a certain location. | ||
''Note that between versions 1.1 and 1.3.0-3749 the default value for '''citiesonly''' was incorrect when called the client side. The work around for clients before 1.3.0-3749 is to always declare a value for '''citiesonly'''. Server side getZoneName was unaffected.'' | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 20: | Line 23: | ||
==Example== | ==Example== | ||
'''Example 1:''' This example | <section name="Server" class="server" show="true"> | ||
'''Example 1:''' This example returns the player's City & Zone. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function outputPlayerZone(thePlayer) | ||
-- get the player position | |||
x, y, z = getElementPosition(thePlayer) | |||
-- get the player zone | |||
zone = getZoneName(x, y, z) | |||
-- get the player city (citiesonly as true) | |||
city = getZoneName(x, y, z, true) | |||
-- output to local player's chatbox | |||
outputChatBox("City: ".. city .." / Zone: ".. zone, thePlayer) | |||
end | end | ||
addCommandHandler( " | addCommandHandler("getloc", outputPlayerZone) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 32: | Line 42: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function scriptGetLoc ( source, command, playername ) --when getloc is called | function scriptGetLoc ( source, command, playername ) --when getloc is called | ||
local | local thePlayer = getPlayerFromName ( playername ) --get the player from nickname | ||
if ( | if ( thePlayer ~= false ) then --if there is a player from the nickname | ||
local x, y, z = getElementPosition ( | local x, y, z = getElementPosition ( thePlayer ) | ||
local location = getZoneName ( x, y, z ) | local location = getZoneName ( x, y, z ) | ||
local city = getZoneName ( x, y, z, true ) | local city = getZoneName ( x, y, z, true ) | ||
Line 43: | Line 53: | ||
addCommandHandler( "getloc", scriptGetLoc ) -- add a command "getloc" which initiates "scriptGetloc" function | addCommandHandler( "getloc", scriptGetLoc ) -- add a command "getloc" which initiates "scriptGetloc" function | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{World functions}} | {{World functions}} | ||
[[ru:getZoneName]] |
Revision as of 15:57, 1 January 2020
This function allows you to retrieve the zone name of a certain location.
Note that between versions 1.1 and 1.3.0-3749 the default value for citiesonly was incorrect when called the client side. The work around for clients before 1.3.0-3749 is to always declare a value for citiesonly. Server side getZoneName was unaffected.
Syntax
string getZoneName ( float x, float y, float z, [bool citiesonly=false] )
Required Arguments
- x: The X axis position
- y: The Y axis position
- z: The Z axis position
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- citiesonly: An optional argument to choose if you want to return the city name (eg Las Venturas)
Returns
Returns the string of the zone name
Example
Click to collapse [-]
ServerExample 1: This example returns the player's City & Zone.
function outputPlayerZone(thePlayer) -- get the player position x, y, z = getElementPosition(thePlayer) -- get the player zone zone = getZoneName(x, y, z) -- get the player city (citiesonly as true) city = getZoneName(x, y, z, true) -- output to local player's chatbox outputChatBox("City: ".. city .." / Zone: ".. zone, thePlayer) end addCommandHandler("getloc", outputPlayerZone)
Example 2: This example will tell you what zone a specified player is in when the "getloc" console command is used.
function scriptGetLoc ( source, command, playername ) --when getloc is called local thePlayer = getPlayerFromName ( playername ) --get the player from nickname if ( thePlayer ~= false ) then --if there is a player from the nickname local x, y, z = getElementPosition ( thePlayer ) local location = getZoneName ( x, y, z ) local city = getZoneName ( x, y, z, true ) outputChatBox ( playername .. " is at " .. location .. " (" .. city .. ")", source ) --announce his zone else outputChatBox ( "Player does not exist" ) end end addCommandHandler( "getloc", scriptGetLoc ) -- add a command "getloc" which initiates "scriptGetloc" function
See Also
- areTrafficLightsLocked
- getAircraftMaxVelocity
- getCloudsEnabled
- getFarClipDistance
- getFogDistance
- getGameSpeed
- getGravity
- getHeatHaze
- getJetpackMaxHeight
- getJetpackWeaponEnabled
- getMinuteDuration
- getMoonSize
- getOcclusionsEnabled
- getRainLevel
- getSkyGradient
- getSunColor
- getSunSize
- getTime
- getTrafficLightState
- getWeather
- getWindVelocity
- getZoneName
- isGarageOpen
- removeWorldModel
- resetColorFilter
- resetFarClipDistance
- resetFogDistance
- resetHeatHaze
- resetMoonSize
- resetRainLevel
- resetSkyGradient
- resetSunColor
- resetSunSize
- resetWindVelocity
- restoreAllWorldModels
- restoreWorldModel
- setAircraftMaxVelocity
- setCloudsEnabled
- setColorFilter
- setFarClipDistance
- setFogDistance
- setGameSpeed
- setGarageOpen
- setGravity
- setHeatHaze
- setInteriorSoundsEnabled
- setJetpackWeaponEnabled
- setMinuteDuration
- setMoonSize
- setOcclusionsEnabled
- setRainLevel
- setSkyGradient
- setSunColor
- setSunSize
- setTime
- setTrafficLightState
- setTrafficLightsLocked
- setWeather
- setWeatherBlended
- setWindVelocity