SA-MP Forums Archive
[FilterScript] ruddeTR's Simple Hostname Changer System - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] ruddeTR's Simple Hostname Changer System (/showthread.php?tid=493878)



ruddeTR's Simple Hostname Changer System - ruddeTR - 10.02.2014

Sorry, my english is not very good so dont just pastebin will throw codes even ****** Translate this article I'm writing to try to understand the buzzwords and topics now

Pastebin Link:

Click Here


Respuesta: ruddeTR's Simple Hostname Changer System - Zume - 11.02.2014

Do not know, I think it's too much code for something so simple..

pawn Код:
new TimerChange, ChangerWalk;
stock InformationChanger[][] =
{
    {"WebHost1", "NameHost 1"}, {"WebHost2", "NameHost 2"},
    {"WebHost3", "NameHost 3"}, {"WebHost4", "NameHost 4"}
};

forward ChangerHostname();
public ChangerHostname()
{
    new string[50];
    format(string, sizeof(string), "weburl %s", InformationChanger[ChangerWalk][0]);
    SendRconCommand(string);

    format(string, sizeof(string), "hostname %s", InformationChanger[ChangerWalk][1]);
    SendRconCommand(string);
    switch(ChangerWalk)
    {
        case 0, 1, 2: ChangerWalk++;
        case 3: ChangerWalk = 0;
    }
    return 1;
}

public OnFilterScriptInit()
{
    TimerChange = SetTimer("ChangerHostname", 5000, true);
    return 1;
}

public OnFilterScriptExit()
{
    KillTimer(TimerChange);
    return 1;
}



Re: Respuesta: ruddeTR's Simple Hostname Changer System - omur1905 - 12.02.2014

Quote:
Originally Posted by Zume-Zero
Посмотреть сообщение
Do not know, I think it's too much code for something so simple..
More practical and efficient way can be arranged.

Код:
static const hostNames[][] =
{
	"Hostname 1",
	"Hostname 2"
        // ...... 
};

public OnGameModeInit()
{
SetTimer("hostnameChange", 4000, 1);
}

forward hostnameChange();
public hostnameChange()
{
   new string[128];
   format(string, sizeof(string), "hostname %s", hostNames[random(sizeof(hostNames))]);
   SendRconCommand(string);
   return 1;
}