Squirrel/Server/Functions/Server/GetPort
From Liberty Unleashed Wiki
(Difference between revisions)
Line 15: | Line 15: | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | function | + | function onPlayerCommand( plr, cmd, text ) |
{ | { | ||
− | if ( cmd == " | + | if ( cmd == "players" ) |
{ | { | ||
− | + | Message( "Server is running on port: " + GetPort(), plr ); | |
} | } | ||
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 26: | 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 the corresponding pages. |
== Related Functions == | == Related Functions == | ||
− | {{Squirrel/Functions/Server}} | + | {{Squirrel/Server/Functions/Server}} |
Latest revision as of 23:23, 9 June 2011
This returns the port the server is running on.
[edit] Syntax
int GetPort()
[edit] Arguments
- None
[edit] Example
This will return the server port when a player types '/port'
function onPlayerCommand( plr, cmd, text ) { if ( cmd == "players" ) { Message( "Server is running on port: " + GetPort(), plr ); } return 1; }
[edit] Notes
The function MessagePlayer and call onPlayerCommand were used in this example. More info about them can be found in the corresponding pages.