Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Simple Rcon Restart by dEcooR ©
- */
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #define FILE "restarts.log"
- #define MAX_SECONDS 600 // 10 minutes
- #define CO_ORANGE 0xFF9900AA
- #define CO_RED 0xF81414AA
- #define W "{FFFFFF}"
- new count = -1,restart,started = 0;
- CMD:restart(playerid, params[])
- {
- new secs;
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,CO_ORANGE,"You are not the admin !");
- else if(sscanf(params, "d", secs)) return SendClientMessage(playerid, CO_ORANGE, "Type: "W"/restart [ Seconds ]");
- else if(started == 1) return SendClientMessage(playerid, CO_ORANGE, "One timer for the restart is already started wait please!");
- else if(secs > MAX_SECONDS) return SendClientMessage(playerid, CO_ORANGE, "Maximum of seconds is 10 minutes!");
- else
- {
- new string[100],string2[100],rstring[100],Name[MAX_PLAYER_NAME],
- year,month,day,hour,minute,second;
- getdate(year, month, day);
- gettime(hour,minute,second);
- GetPlayerName(playerid,Name,24);
- format(string2,100,"Administrator %s has started timer to restart the server for %d seconds.",Name,secs);
- format(string,100,"~r~WARNING ] ~g~Server restart in %d seconds.",secs);
- GameTextForAll(string, 3800, 4);
- SendClientMessageToAll(CO_RED,string2);
- format(rstring, sizeof(rstring), "Name: %s - Time: %d:%d:%d - Date: %d/%d/%d\n", Name,hour, minute, second,day,month,year);
- new File:restarts = fopen(FILE, io_write);
- fwrite(restarts, rstring);
- fclose(restarts);
- count = secs;
- restart = SetTimerEx("RestartGM",1000,true,"i",playerid);
- started = 1;
- }
- return 1;
- }
- forward RestartGM();
- public RestartGM()
- {
- new counts[100];
- count--;
- format(counts,1000,"~n~~n~~n~~n~~n~~n~~n~~n~ ~y~Server restart in: ~g~%d",count);
- GameTextForAll(counts,1000,3);
- if(count == 0)
- {
- for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) SendRconCommand("gmx");
- GameTextForAll("~w~]~r~Restaring Server..~n~~y~wait please",5000,3);
- KillTimer(restart);
- count = 0;
- started = 0;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement