08.02.2010, 19:23 
	
	
	
		Is there any way I can change the hostname from within the script, from a string or define?
	
	
	
	
new string[128];
format(string, sizeof(string), "hostname %s", DEFINE_HERE);
SendRconCommand(string);
| 
 
					Originally Posted by mavtias  
I've already tried that. Does not work. 
I wouldn't ask If It worked.  | 
forward RandomServerNames();
new SVNAMES[1][256] = {
"Name",
"Name"
};
public RandomServerNames()
{
new string[256];
new random1 = random(sizeof(SVNAMES));
format(string, sizeof(string), "hostname %s", SVNAMES[random1] );
SendRconCommand(string);
return 1;
}
#define HOST_NAME "My Server"
stock ChangeServerName(name[])
{
new tmp[256];
format(tmp, sizeof tmp, "hostname %s", name);
SendRconCommand(tmp);
}
#include a_samp
new server_names[][]={ "my server", "my server2", "my server3..." };
new gServerNameCounter=0;
//-------------------------------------------------
public OnFilterScriptInit() SetTimer("ChangeServerNameRun",30*1000,true);
//-------------------------------------------------
public ChangeServerNameRun();
public ChangeServerNameRun()
{
ChangeServerName(server_names[gServerNameCounter]);
gServerNameCounter++;
if(gServerNameCounter>=sizeof server_names) gServerNameCounter =0;
return 1;
}
//-------------------------------------------------
stock ChangeServerName(name[])
{
new tmp[256];
format(tmp, sizeof tmp, "hostname %s", name);
SendRconCommand(tmp);
}
SendRconCommand("hostname %s"), SERVERNAME);