Auto-Change server name

Started by KAKAN, Jan 24, 2016, 03:39 PM

Previous topic - Next topic

KAKAN

Well, 3 guys PM'ed me on IRC asking me to make a script to change the server name every one minute. So, I made this and going to release it here so that everyone can use it.

//Lets have the global variables here:-
lastElement <- 0; //Don't change this directly.

Names <- ["dafuq", "lol", "just", "trying","this","shit"]; //Add how many you want

function onScriptLoad(){
NewTimer("ChangeTehName",60000,0);
}

function ChangeTehName(){
    SetServerName( Names[lastElement] );
    lastElement++;

    if( lastElement >= Names.len() - 1 ) lastElement = 0;
}

Well, I'll try my best to explain this code.
lastElement <- 0; This is the thing which tells us which number is going on from the array.( just to be simple )
Names <- [] Well, this is the array containing the names which will be cycled through.

function onScriptLoad(){
NewTimer("ChangeTehName",60000,0);
}
This is pretty simple, it means when the script is loaded it makes a new timer which repeats itself every 60 seconds.

From the function ChangeTehName:-
    SetServerName( Names[lastElement] ); Well, now, if the lastElement is 0, then it'll set the name to the 1st element of the array.

    lastElement++; We'll increase the counter so that we get a different name after the next 60 seconds.

    if( lastElement >= Names.len() - 1 ) lastElement = 0; Well now, if the lastElement goes more than the last name in the array, then it'll get resetted. It's like a loop. The reason I used - 1 is that the .Len() index starts from 1 while the array's index starts from 0.
oh no

Anik


Williams

Hey, i m always at IRC and Forum you can comtact me at IRC channel :- #GDM @LUNet and Forum :- http://pro-fighter.tk/index.php

luchgox

function onScriptLoad(){
NewTimer("ChangeTehName",60000,0); :edit:
}

Thats why my server got crashed
Strength does not come from wining.Your struggles develop your strengths.

Anik

Quote from: QW.jester on Apr 03, 2017, 03:11 AMfunction onScriptLoad(){
NewTimer("ChangeTehName",60000,0); :edit:
}

Thats why my server got crashed
-_- Nice Bump mate. And how can it crash?? The function is named as ChangeTehName .

KAKAN

Quote from: QW.jester on Apr 03, 2017, 03:11 AMfunction onScriptLoad(){
NewTimer("ChangeTehName",60000,0); :edit:
}

Thats why my server got crashed
Nice one, mate. haha :D
Actually, teh means the. Just the ancient name. Google for more :D

P.S:- I forgot that I actually released something like that lol
oh no