Squirrel/Server/Functions/Server/GetPort

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
 
Line 15: Line 15:
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function OnPlayerCommand( id, cmd, text )
+
function onPlayerCommand( plr, cmd, text )
 
{
 
{
     if ( cmd == "port" )
+
     if ( cmd == "players" )
 
     {
 
     {
           MessagePlayer( "Server is running on port: " + GetPort(), id );
+
           Message( "Server is running on port: " + GetPort(), plr );
 
     }
 
     }
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 26: Line 28:
 
=== Notes ===
 
=== Notes ===
  
The function [[Squirrel/Functions/Misc/MessagePlayer|MessagePlayer]] and call [[Squirrel/Events/Player/OnPlayerCommand|OnPlayerCommand]] were used in in this example. More info about them in corresponding pages.
+
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

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This returns the port the server is running on.

[edit] Syntax

  1. int GetPort()

[edit] Arguments

  • None

[edit] Example

This will return the server port when a player types '/port'

  1.  
  2. function onPlayerCommand( plr, cmd, text )
  3. {
  4. if ( cmd == "players" )
  5. {
  6. Message( "Server is running on port: " + GetPort(), plr );
  7. }
  8. return 1;
  9. }
  10.  

[edit] Notes

The function MessagePlayer and call onPlayerCommand were used in this example. More info about them can be found in the corresponding pages.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox