Advertisement
Guest User

[Simple FS]Anti-Steal

a guest
May 11th, 2012
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.05 KB | None | 0 0
  1. #include <a_samp>
  2. #include <filemanager>
  3.  
  4. //#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"
  5.  
  6.  
  7. #if !defined MODE_NAME
  8.     #error "Please define MODE_NAME with the name of ur GM before compiling and using this!"
  9. #endif
  10.  
  11. new bool:gRemoveGMConfirm = false;
  12. 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.
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.     print("\n-------------------------------------------------------------------------------------------------");
  17.     print(" Security Launcher started");
  18.     print("WARNING: Please remember to put a fake GM as second one in config.cfg file !");
  19.     print("---------------------------------------------------------------------------------------------------\n");
  20.     return 1;
  21. }
  22.  
  23. public OnFilterScriptExit()
  24. {
  25.     print("----------------------------------------------------------------------------------------");
  26.     print("Security Launcher has been unloaded");
  27.     print(" WARNING: Please remember to keep this FS running while ur server is runing!");
  28.     print("-----------------------------------------------------------------------------------------");
  29.     return 1;
  30. }
  31.  
  32.  
  33. public OnRconCommand(cmd[])
  34. {
  35.     if(strsame(cmd, "removegm") && CheckRCONSecurity())
  36.     {
  37.         if(!gRemoveGMConfirm)
  38.         {
  39.             print("You are going to delete ur gamemode from the server !");
  40.             print(" Please use this command only when it's REALY needed !");
  41.             print("Are you SURE ?");
  42.             print("To answer \"yes\", just type this command again.");
  43.            
  44.            
  45.             gRemoveGMConfirm = true;
  46.         }
  47.         else
  48.         {
  49.             SendRconCommand("gmx");
  50.             new string[250];
  51.             format(string, sizeof(string), "gamemodes/%s.amx", MODE_NAME);
  52.             if(file_delete(string))
  53.             {
  54.                 print("GM sucefully deleted from the server");
  55.             }
  56.             else
  57.             {
  58.                 print("An error occured.Please check that u have correctly defined MODE_NAME");
  59.             }
  60.         }
  61.         return 1;
  62.     }
  63.     return 0;
  64. }
  65.  
  66. stock strsame(string1[], string2[])//This func' compare 2 specified string to know if they are "same"
  67. {
  68.     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
  69.     {
  70.         return true;
  71.     }
  72.     else{ return false; }
  73. }
  74.  
  75. stock CheckRCONSecurity()//This is not realy a "security" check but it checks if there is only 1 admin connected in RCON
  76. {
  77.     new rconConnected = 0;
  78.    
  79.     for(new i = 0; i < gMaxID; i++)
  80.     {
  81.         if(IsPlayerAdmin(i))
  82.         {
  83.             rconConnected++;
  84.         }
  85.     }
  86.    
  87.    
  88.     if(rconConnected <= 1) { return true; }
  89.     else { return false; }
  90. }
  91.  
  92.  
  93. public OnPlayerConnect(playerid)
  94. {
  95.     if(playerid > gMaxID) { gMaxID = playerid; }
  96. }
  97.  
  98. public OnPlayerDisconnect(playerid, reason)
  99. {
  100.     if(playerid == gMaxID)
  101.     {
  102.         for(new i = gMaxID-1; i > 0; i--)
  103.         {
  104.             if(IsPlayerConnected(i))
  105.             {
  106.                 gMaxID = i;
  107.                 break;
  108.             }
  109.         }
  110.     }
  111.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement