GetZoneName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
 
(13 intermediate revisions by 7 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.
 
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 14: Line 15:
===Optional Arguments===
===Optional Arguments===
{{OptionalArg}}
{{OptionalArg}}
* '''citiesonly''': An optional argument to choose if you want to return the city name (eg Las Venturas)
* '''citiesonly''': An optional argument to choose if you want to return one of the following city names:
** Tierra Robada
** Bone County
** Las Venturas
** San Fierro
** Red County
** Whetstone
** Flint County
** Los Santos


===Returns===
===Returns===
Returns the string of the zone name
Returns the string of the zone name.
{{ZoneNames}}


==Example==
==Example==
'''Example 1:''' This example shows you how to return a zone name by doing /loc x y z in the chatbox or just loc x y z in console ( replace x, y and z with the co-ords you wanna check, eg /loc 1200 523 12.3 )
<section name="Server" class="server" show="true">
'''Example 1:''' This example returns the player's City & Zone.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function playerLoc ( source, command, x, y, z )
function outputPlayerZone(thePlayer)
  local location = getZoneName ( x, y, z )
    -- get the player position
  outputChatBox ( "* Location: " .. location, getRootElement(), 0, 255, 255 ) -- Output the zone name
    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( "loc", playerLoc )
addCommandHandler("getloc", outputPlayerZone)
</syntaxhighlight>
</syntaxhighlight>


Line 32: Line 49:
<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 player = getPlayerFromNick(playername)--get the player from nickname
   local thePlayer = getPlayerFromName ( playername ) --get the player from nickname
   if ( player ~= false ) then --if there is a player from the nickname
   if ( thePlayer ~= false ) then --if there is a player from the nickname
     local x, y, z = getElementPosition ( player )
     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 41: Line 58:
   end
   end
end
end
addCommandHandler( "getloc", scriptGetLoc ) -- add a command "getloc" which initiates "getloc" 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]]

Latest revision as of 21:50, 29 August 2022

This function allows you to retrieve the zone name of a certain location.

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 one of the following city names:
    • Tierra Robada
    • Bone County
    • Las Venturas
    • San Fierro
    • Red County
    • Whetstone
    • Flint County
    • Los Santos

Returns

Returns the string of the zone name.

All GTA SA zones and cities
  • Whetstone
    • Angel Pine
    • Flint County *
    • Foster Valley
    • Mount Chiliad
    • Shady Cabin
    • Shady Creeks
  • Flint County
    • Back o Beyond
    • Beacon Hill
    • Easter Bay Chemicals
    • The Farm
    • Flint Intersection
    • Flint Range
    • Leafy Hollow
    • Los Santos Inlet
  • Los Santos
    • Commerce
    • Conference Center
    • Downtown Los Santos
    • East Beach
    • East Los Santos
    • El Corona
    • Ganton
    • Glen Park
    • Idlewood
    • Jefferson
    • Las Colinas
    • Little Mexico
    • Los Flores
    • Los Santos International
    • Marina
    • Market
    • Market Station
    • Mulholland
    • Mulholland Intersection
    • Ocean Docks
    • Pershing Square
    • Playa del Seville
    • Richman
    • Rodeo
    • Santa Maria Beach
    • Temple
    • Unity Station
    • Verdant Bluffs
    • Verona Beach
    • Vinewood
    • Willowfield
  • San Fierro
    • Avispa Country Club
    • Battery Point
    • Calton Heights
    • Chinatown
    • City Hall
    • Cranberry Station
    • Doherty
    • Downtown
    • Easter Basin
    • Easter Bay Airport
    • Easter Tunnel
    • Esplanade East
    • Esplanade North
    • Financial
    • Foster Valley
    • Gant Bridge
    • Garcia
    • Garver Bridge
    • Hashbury
    • Juniper Hill
    • Juniper Hollow
    • Kincaid Bridge
    • King's
    • Missionary Hill
    • Mount Chiliad
    • Ocean Flats
    • Palisades
    • Paradiso
    • Queens
    • San Fierro Bay
    • Santa Flora
  • Red County
    • Blueberry
    • Blueberry Acres
    • Dillimore
    • Easter Bay Airport
    • Easter Bay Chemicals
    • Fallen Tree
    • Fallow Bridge
    • Fern Ridge
    • Fisher's Lagoon
    • Flint County *
    • Flint Water
    • Frederick Bridge
    • Hampton Barns
    • Hankypanky Point
    • Hilltop Farm
    • Las Venturas *
    • Martin Bridge
    • Montgomery
    • Montgomery Intersection
    • Mulholland
    • North Rock
    • Palomino Creek
    • Richman
    • San Andreas Sound
    • San Fierro *
    • The Mako Span
    • The Panopticon
  • Tierra Robada
    • Aldea Malvada
    • Arco del Oeste
    • Bayside
    • Bayside Marina
    • Bayside Tunnel
    • Bone County *
    • El Quebrados
    • Gant Bridge
    • Garver Bridge
    • Kincaid Bridge
    • Las Barrancas
    • Robada Intersection
    • San Fierro Bay
    • Sherman Reservoir
    • The Sherman Dam
    • Valle Ocultado
  • Bone County
    • 'The Big Ear'
    • El Castillo del Diablo
    • Fort Carson
    • Green Palms
    • Hunter Quarry
    • Las Brujas
    • Las Payasadas
    • Lil' Probe Inn
    • Octane Springs
    • Regular Tom
    • Restricted Area
    • Verdant Meadows
  • Las Venturas
    • Blackfield
    • Blackfield Chapel
    • Blackfield Intersection
    • Caligula's Palace
    • Come-A-Lot
    • Creek
    • Greenglass College
    • Harry Gold Parkway
    • Julius Thruway East
    • Julius Thruway North
    • Julius Thruway South
    • Julius Thruway West
    • K.A.C.C. Military Fuels
    • Las Venturas Airport
    • Last Dime Motel
    • Linden Side
    • Linden Station
    • LVA Freight Depot
    • Old Venturas Strip
    • Pilgrim
    • Pilson Intersection
    • Pirates in Men's Pants
    • Prickle Pine
    • Randolph Industrial Estate
    • Redsands East
    • Redsands West
    • Roca Escalante
    • Rockshore East
    • Rockshore West
    • Royal Casino
    • Sobell Rail Yards
    • Spinybed
    • Starfish Casino
    • The Camel's Toe
    • The Clown's Pocket
    • The Emerald Isle
    • The Four Dragons Casino
    • The High Roller
    • The Pink Swan
    • The Strip
    • The Visage
    • Whitewood Estates
    • Yellow Bell Golf Course
    • Yellow Bell Station

* Not real zone, but it still can be found using getZoneName

Example

Click to collapse [-]
Server

Example 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