Auto-change of server's name - 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)
+--- Thread: Auto-change of server's name (
/showthread.php?tid=618249)
Auto-change of server's name -
Irish - 03.10.2016
Hi there! I am requesting to please make a auto-change of server name every 2 seconds. Thanks I appreciate your effort +rep if anyone could help me.
Re: Auto-change of server's name -
SsHady - 03.10.2016
Above Main
Код:
forward ChangeNameNigga();
Код:
public OnFilterScriptInit()
{
SetTimer("ChangeNameNigga",5000,1); // It will change the name every 5 seconds.
return 1;
}
somewhere out of callbacks or functions
Код:
public ChangeNameNigga()
{
new var = random(3);
switch (var)
{
case 0: SendRconCommand("hostname My server name 1");
case 1: SendRconCommand("hostname Server name 2");
case 2: SendRconCommand("hostname Name 3 here");
}
}
Re: Auto-change of server's name -
JaKe Elite - 03.10.2016
Just a note from SsHady;
Change this
PHP код:
SetTimer("ChangeNameNigga",5000,1);
to
PHP код:
SetTimer("ChangeNameNigga", 2000, true); // 2000 ms = 2 seconds
And if you are using a gamemode, Place it OnGameModeInit not OnFilterScriptInit.
PHP код:
public OnGameModeInit() // or OnFilterScriptInit
{
SetTimer("ChangeNameNigga", 2000, true);
return 1;
}
forward ChangeNameNigga();
public ChangeNameNigga()
{
new var = random(3);
switch (var)
{
case 0: SendRconCommand("hostname My server name 1");
case 1: SendRconCommand("hostname Server name 2");
case 2: SendRconCommand("hostname Name 3 here");
}
return 1;
}
Re: Auto-change of server's name -
Irish - 03.10.2016
Quote:
Originally Posted by JaKe Elite
Just a note from SsHady;
Change this
PHP код:
SetTimer("ChangeNameNigga",5000,1);
to
PHP код:
SetTimer("ChangeNameNigga", 2000, true); // 2000 ms = 2 seconds
And if you are using a gamemode, Place it OnGameModeInit not OnFilterScriptInit.
PHP код:
public OnGameModeInit() // or OnFilterScriptInit
{
SetTimer("ChangeNameNigga", 2000, true);
return 1;
}
forward ChangeNameNigga();
public ChangeNameNigga()
{
new var = random(3);
switch (var)
{
case 0: SendRconCommand("hostname My server name 1");
case 1: SendRconCommand("hostname Server name 2");
case 2: SendRconCommand("hostname Name 3 here");
}
return 1;
}
|
thanks +rep all of you. you helped me a lot
Re: Auto-change of server's name -
SickAttack - 03.10.2016
Quote:
Originally Posted by JaKe Elite
Just a note from SsHady;
Change this
PHP код:
SetTimer("ChangeNameNigga",5000,1);
to
PHP код:
SetTimer("ChangeNameNigga", 2000, true); // 2000 ms = 2 seconds
And if you are using a gamemode, Place it OnGameModeInit not OnFilterScriptInit.
PHP код:
public OnGameModeInit() // or OnFilterScriptInit
{
SetTimer("ChangeNameNigga", 2000, true);
return 1;
}
forward ChangeNameNigga();
public ChangeNameNigga()
{
new var = random(3);
switch (var)
{
case 0: SendRconCommand("hostname My server name 1");
case 1: SendRconCommand("hostname Server name 2");
case 2: SendRconCommand("hostname Name 3 here");
}
return 1;
}
|
You can put the function random inside the switch. No need for a variable.