Change hostname - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Change hostname (
/showthread.php?tid=126482)
Change hostname -
Mike Garber - 08.02.2010
Is there any way I can change the hostname from within the script,
from a string or define?
Re: Change hostname -
Grim_ - 08.02.2010
pawn Code:
new string[128];
format(string, sizeof(string), "hostname %s", DEFINE_HERE);
SendRconCommand(string);
Re: Change hostname -
Mike Garber - 08.02.2010
I've already tried that. Does not work.
I wouldn't ask If It worked.
Re: Change hostname -
Grim_ - 08.02.2010
Quote:
Originally Posted by mavtias
I've already tried that. Does not work.
I wouldn't ask If It worked.
|
Works for me.
Re: Change hostname -
JustinSton - 08.02.2010
Code:
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;
}
Re: Change hostname -
Mike Garber - 08.02.2010
Then why do I get;
warning 202: number of arguments does not match definition
on that line when I try It? I've already tried It, as I said...
Re: Change hostname -
Grim_ - 08.02.2010
Are you putting your define in quotations marks? Like:
pawn Code:
#define HOST_NAME "My Server"
Re: Change hostname -
[HUN]Gamestar - 08.02.2010
Try this.
pawn Code:
stock ChangeServerName(name[])
{
new tmp[256];
format(tmp, sizeof tmp, "hostname %s", name);
SendRconCommand(tmp);
}
If you would like it automatically:
pawn Code:
#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);
}
Re: Change hostname -
Mike Garber - 08.02.2010
LOL I'm not a noob. Now I see why, I've been so slow all day, maybe I've been sleeping too much xD
I tried to do
pawn Code:
SendRconCommand("hostname %s"), SERVERNAME);
wich wouldn't work.
Now enjoy my stupidity xD
Re: Change hostname -
Grim_ - 08.02.2010
I wish I could sleep =(