Raised This Month: $51 Target: $400
 12% 

help novice in sourcepawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Munoon
Member
Join Date: Jul 2018
Location: www.Train4Game.com
Old 03-23-2019 , 07:28   help novice in sourcepawn
Reply With Quote #1

Hi guys. Working about my first plugin and have a trouble...
I need to change server name and can’t find how to do it. Firstly I was looking for command that send command to console but nothing found. Then I remembered that I was reading something about command that change parameters of other commands but also can’t find...
So my question is: may some one say me how to get current parameter of console command (for example hostname) and how to change it?
Munoon is offline
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
Munoon
Member
Join Date: Jul 2018
Location: www.Train4Game.com
Old 03-23-2019 , 07:47   Re: help novice in sourcepawn
Reply With Quote #3

Quote:
Originally Posted by adma View Post
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.
Lots of thanks!
Munoon is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode