[FilterScript] Server Restart Command for Rcon Admins - The first of its kind!
#1

Server Restart Command for Rcon Admins
By Aerotactics


Includes *new*
-zcmd

Changelog
-made string arrays smaller
-revised a section of script to be even smaller
-utilized zcmd to shorten the script a couple lines, and for it's efficiency
-corrected duplicating objects script -- see below
-added a fix for objects duplicating after a restart, causing issues with Incognito's Streamer
-fixed a bug that allowed the command to be called by 2 people at once, causing a server crash
-Removed define "MAX_FS"
-fixed a typo

About
I was on my way to bed, when I got a random idea. Since I learned how to make a server restart command today, I thought "why don't I create a filterscript that lets the server owner set it up easier?" This idea bugged me until I got out of bed and started scripting.

The Script
This was, by far, my favorite script to write because I have not seen this anywhere before. This script is completely original, and it is mine. Don't take it as your own. I wrote this script to be customizable by the user and easy to use for anyone. While the script looks noobish and simple at best, there is NO other filterscript like it.

The script is TINY and has a nice settings setup for server owners. When restarting the server, it also restarts every filterscript in live time. If you were to edit a filterscript and restart the server, your filterscript would be updated as well. The ONLY filterscript not able to be updated is THIS filterscript, which causes the server to crash. To update the restart filterscript, make changes as necessary, then type the command "/rcon reloadfs restart" and the filterscript will update for your use.

The command to restart your server is "/restart" which is an Rcon only command. You don't have to type "/rcon restart," you just have to be logged into rcon to type "/restart."

If you are interested in the script, here it is:
pawn Код:
#define FILTERSCRIPT
#define COLOR_RED 0xFF0606FF
#include <a_samp>
#include <zcmd>
//==========================================//
// Server Restart Command filterscript
// by Aerotactics
//==========================================//

//SETTINGS
#define TIME 3 // In Seconds, the time before the server restarts.
new FS[][] =
{
    "filterscript1",
    "filterscript2",
    "filterscript3"
};
// Add each of your filterscript's names in this section. Be sure that
// the last item in the list does NOT have a comma, and DO NOT add
// the filterscript "restart" as it will crash your server.
// Therefor, the only filterscript you can't update live is this one.
//==========================================//
new restartcheck = 0;
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
    print("\n------------------------------------------");
    print("Server Restart Filterscript by Aerotactics");
    print("------------------------------------------\n");
    return 1;
}
#endif
CMD:restart(playerid, params[])
{
    if (!IsPlayerAdmin(playerid)) return 0;
    if (restartcheck == 1) return SendClientMessage(playerid,COLOR_RED,"The server is already restarting!");
    restartcheck = 1;
    new string[36];
    format(string,sizeof(string),"Server is restarting in %i seconds.",TIME);
    SendClientMessageToAll(COLOR_RED,string);
    SetTimer("ServerRestart", TIME*1000, 0);
    return 1;
}
forward ServerRestart();
public ServerRestart()
{
    SendRconCommand("gmx");
    for(new i = 0; i <sizeof(FS); i++)
    {
        new string[32];
        format(string,sizeof(string),"reloadfs %s",FS[i]);
        SendRconCommand(string);
    }
    restartcheck = 0;
    return 1;
}
Download the Filterscript here: Mediafire

Compile it in Pawno and add it under filterscripts in your server.cfg

If you like it, show your thanks by giving me rep. Thank you for your time.


Warnings
-the server might crash if you try to restart while someone else is uploading files via FTP.
-To fix the object duplication due to GMX, you must add this script to your map filterscript (or whatever script your map is located in):
pawn Код:
public OnGameModeExit()
{
    for(new i; i<MAX_OBJECTS; i++)
    {
        if(IsValidObject(i)){DestroyObject(i);}
    }
}
Conclusion
My partner and I have implemented this filterscript in our server and use it constantly. It is extremely handy for bugfixing and restarting constantly in development. Thanks for downloading!
Reply
#2

It's nice I guess but there are already ways to restart the server and load reload scripts built into rcon but this seems good as well because you don't have to /rcon loadfilterscript or what ever it is.

Good work.
Reply
#3

Good work
Reply
#4

Nice job
Reply
#5

Quote:
Originally Posted by jueix
Посмотреть сообщение
It's nice I guess but there are already ways to restart the server and load reload scripts built into rcon but this seems good as well because you don't have to /rcon loadfilterscript or what ever it is.

Good work.
Thanks. I know there's simpler ways, but yes, I didn't want to write "sendrconcommand("reloadfs whatever")" either because it's easier to just add the names to a list and run a "foreach" loop. And I wanted it to be as simple as possible for the user, and that is writing in just the names. Thank you for your feedback, though!
Reply
#6

It would be nice if sa-mp had a native function to tell what filterscripts are running in that moment (I think I suggested it some months ago). This way, this filterscript of yours could automatically reload all other filterscripts without the user having to add their names in your list.
Reply
#7

Not bad.
Reply
#8

good work
Reply
#9

Quote:
Originally Posted by Hax0rm
Посмотреть сообщение
good work
Thanks!

Quote:
Originally Posted by Gryphus One
Посмотреть сообщение
It would be nice if sa-mp had a native function to tell what filterscripts are running in that moment (I think I suggested it some months ago). This way, this filterscript of yours could automatically reload all other filterscripts without the user having to add their names in your list.
That would be nice, except if it were to be implemented, I would have to skip the server reading this restart because restarting this filterscript crashes the game. Good idea though.

By the way I updated the script, removing the "MAX_FS" define because its not needed.
Reply
#10

Bump

Reason: update
Reply
#11

Not too nice , but good work
Reply
#12

gmx causes too many client bugs to be useful it\'s a foolish way to restart a server.
Reply
#13

Quote:
Originally Posted by [uL]Pottus
View Post
gmx causes too many client bugs to be useful it\'s a foolish way to restart a server.
What kind of client bugs? The only bug I ran into was an issue with objects not being removed after restart. I can even add a fix for that to the script.
Reply
#14

Cool i like it
Reply
#15

Quote:
Originally Posted by Aerotactics
View Post
What kind of client bugs? The only bug I ran into was an issue with objects not being removed after restart. I can even add a fix for that to the script.
There is all sorts of issues such as sound bugs, textdraw bugs, removebuildingforplayer and other stuff weird problems. I\'ll try and get Slice to reply to this because he can explain a lot better than myself why gmx sucks and why you should not rely on it.
Reply
#16

I added the fix for duplicating objects. If there are any more fixable issues, let me know.
Reply
#17

Good work man
Reply
#18

good work
Reply
#19

Quote:
Originally Posted by sterling123
View Post
Good work man
Quote:
Originally Posted by burke1234
View Post
good work
Thanks guys!
Reply
#20

Nice+-.
Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)