Change hostname
#1

Is there any way I can change the hostname from within the script, from a string or define?
Reply
#2

pawn Code:
new string[128];
format(string, sizeof(string), "hostname %s", DEFINE_HERE);
SendRconCommand(string);
Reply
#3

I've already tried that. Does not work.
I wouldn't ask If It worked.
Reply
#4

Quote:
Originally Posted by mavtias
I've already tried that. Does not work.
I wouldn't ask If It worked.
Works for me.
Reply
#5

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;
}
Reply
#6

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...
Reply
#7

Are you putting your define in quotations marks? Like:
pawn Code:
#define HOST_NAME "My Server"
Reply
#8

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);
}
Reply
#9

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
Reply
#10

I wish I could sleep =(
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)