Squirrel/Server/Functions/Server/GetServerName
From Liberty Unleashed Wiki
(Difference between revisions)
Line 1: | Line 1: | ||
{{Squirrel/Title|GetServerName}} | {{Squirrel/Title|GetServerName}} | ||
− | |||
− | |||
This returns the name of the server. | This returns the name of the server. | ||
Line 17: | Line 15: | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | function | + | function onPlayerCommand( plr, cmd, text ) |
{ | { | ||
if ( cmd == "server" ) | if ( cmd == "server" ) | ||
{ | { | ||
− | MessagePlayer( "You are playing on: " + GetServerName(), | + | MessagePlayer( "You are playing on: " + GetServerName(), plr ); |
} | } | ||
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 28: | Line 28: | ||
=== Notes === | === Notes === | ||
− | The function [[Squirrel/Functions/ | + | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them can be found in corresponding pages. |
== Related Functions == | == Related Functions == | ||
− | {{Squirrel/Functions/Server}} | + | {{Squirrel/Server/Functions/Server}} |
Latest revision as of 23:25, 9 June 2011
This returns the name of the server.
[edit] Syntax
string GetServerName()
[edit] Arguments
- None
[edit] Example
This example will return the server name when a player types '/server'.
function onPlayerCommand( plr, cmd, text ) { if ( cmd == "server" ) { MessagePlayer( "You are playing on: " + GetServerName(), plr ); } return 1; }
[edit] Notes
The function MessagePlayer and call onPlayerCommand were used in this example. More info about them can be found in corresponding pages.