View Single Post
adma
Senior Member
Join Date: Oct 2015
Old 03-23-2019 , 07:41   Re: help novice in sourcepawn
Reply With Quote #2

To change the server name, which is controlled by hostname console variable (cvar):
1. Use FindConVar to grab hostname cvar.

PHP Code:
ConVar hHostName FindConVar("hostname"); 
2. Use ConVar.SetString to change the hostname cvar.

PHP Code:
hHostName.SetString("New Server Name"); 
If you want to get the current hostname, then you can use ConVar.GetString to store the current hostname in a buffer.

PHP Code:
char szBuffer[64];
hHostName.GetString(szBuffersizeof(szBuffer));
PrintToServer("The server's current hostname is: %s"szBuffer); 
Side-note: even though ConVars are Handles, you do not need to close them because they are global variables that you access using FindConVar.
adma is offline