Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <filemanager>
- //#define MODE_NAME "larp" exemple of MODE_NAME defining.Please remember to set ur gm name without .amx and/or .pwn.This name MUST be the same as the file! If ur GM is named "Another RolePlay" and ur file is "anrp.pwn"/"anrp.amx" please put "anrp" and not "Another RP"
- #if !defined MODE_NAME
- #error "Please define MODE_NAME with the name of ur GM before compiling and using this!"
- #endif
- new bool:gRemoveGMConfirm = false;
- new gMaxID = 1;//This is not my own idea.It's Minimicro's idea but i use it only because i understand how it works.
- public OnFilterScriptInit()
- {
- print("\n-------------------------------------------------------------------------------------------------");
- print(" Security Launcher started");
- print("WARNING: Please remember to put a fake GM as second one in config.cfg file !");
- print("---------------------------------------------------------------------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("----------------------------------------------------------------------------------------");
- print("Security Launcher has been unloaded");
- print(" WARNING: Please remember to keep this FS running while ur server is runing!");
- print("-----------------------------------------------------------------------------------------");
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- if(strsame(cmd, "removegm") && CheckRCONSecurity())
- {
- if(!gRemoveGMConfirm)
- {
- print("You are going to delete ur gamemode from the server !");
- print(" Please use this command only when it's REALY needed !");
- print("Are you SURE ?");
- print("To answer \"yes\", just type this command again.");
- gRemoveGMConfirm = true;
- }
- else
- {
- SendRconCommand("gmx");
- new string[250];
- format(string, sizeof(string), "gamemodes/%s.amx", MODE_NAME);
- if(file_delete(string))
- {
- print("GM sucefully deleted from the server");
- }
- else
- {
- print("An error occured.Please check that u have correctly defined MODE_NAME");
- }
- }
- return 1;
- }
- return 0;
- }
- stock strsame(string1[], string2[])//This func' compare 2 specified string to know if they are "same"
- {
- if(!strcmp(string1, string2) && strlen(string1) && strlen(string2))//Please remember that strcmp() also return 0 if either string is empty and any string have at least one cell
- {
- return true;
- }
- else{ return false; }
- }
- stock CheckRCONSecurity()//This is not realy a "security" check but it checks if there is only 1 admin connected in RCON
- {
- new rconConnected = 0;
- for(new i = 0; i < gMaxID; i++)
- {
- if(IsPlayerAdmin(i))
- {
- rconConnected++;
- }
- }
- if(rconConnected <= 1) { return true; }
- else { return false; }
- }
- public OnPlayerConnect(playerid)
- {
- if(playerid > gMaxID) { gMaxID = playerid; }
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(playerid == gMaxID)
- {
- for(new i = gMaxID-1; i > 0; i--)
- {
- if(IsPlayerConnected(i))
- {
- gMaxID = i;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement