GetElementZoneName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Server function}}
__NOTOC__
__NOTOC__
This function allows you to retrieve the zone name of an element (eg. Verdant Bluffs or Ocean Docks)
This function allows you to retrieve the zone name of an element (eg. Verdant Bluffs or Ocean Docks)
The same can be achieved client side by getting element coordinates and using [[GetZoneName]].


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getElementZoneName ( element theElement )
string getElementZoneName ( element theElement, [bool citiesonly=false] )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[element]]:getZoneName||}}


===Required Arguments===
===Required Arguments===
*'''theElement:''' The element in which you'd like to retrieve the dimension of.
*'''theElement:''' The element which you'd like to retrieve the zone name from
 
===Optional Arguments===
{{OptionalArg}}
*'''citiesonly''': An optional argument to choose if you want to return the city name (eg Las Venturas)


===Returns===
===Returns===
Returns the string of the elements location.
Returns the string of the elements zone name.


==Example==
==Example==
This example shows you how to return your own location by doing /loc in the chatbox or just loc in console
This example shows you how to return your own location by doing /loc in the chatbox or just loc in console
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler("loc", "playerloc")
function playerloc ( source )
function playerloc ( source )
  local playername = getClientName ( source )
    local playername = getPlayerName ( source )
  local location = getElementZoneName ( source )
    local location = getElementZoneName ( source )
  if ( source ) then -- if the player is found
     outputChatBox ( "* " .. playername .. "'s Location: " .. location, getRootElement(), 0, 255, 255 ) -- Output the player's name and zone name
     outputChatBox ( "* " ..playername.. "'s Location: " ..location, root, 0, 255, 255 ) -- Output the player's name and zone name
    else
    outputChatBox ( "* " ..playername.. "'s Location not found.", root, 0, 255, 255 ) -- Output error message if not found
  end
end
end
addCommandHandler ( "loc", playerloc )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Element functions}}
{{Element_functions|server}}

Latest revision as of 22:30, 6 September 2024

This function allows you to retrieve the zone name of an element (eg. Verdant Bluffs or Ocean Docks)

The same can be achieved client side by getting element coordinates and using GetZoneName.

Syntax

string getElementZoneName ( element theElement, [bool citiesonly=false] )

OOP Syntax Help! I don't understand this!

Method: element:getZoneName(...)


Required Arguments

  • theElement: The element which you'd like to retrieve the zone name from

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 elements zone name.

Example

This example shows you how to return your own location by doing /loc in the chatbox or just loc in console

function playerloc ( source )
    local playername = getPlayerName ( source )
    local location = getElementZoneName ( source )
    outputChatBox ( "* " .. playername .. "'s Location: " .. location, getRootElement(), 0, 255, 255 ) -- Output the player's name and zone name
end
addCommandHandler ( "loc", playerloc )

See Also