Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Paste Description for GMCycle FS

Rotate as many gamemodes as you want!

GMCycle FS
Sunday, September 30th, 2007 at 11:16:36pm MDT 

  1. #include <a_samp>
  2.  
  3. #define FILTERSCRIPT
  4. #define File_To_Read "gmcycle.txt"
  5.  
  6. new counter = 1; // Because we are running on gamemode0 at init.
  7. new gmcount = 0;
  8.  
  9. forward GameModeExitEx();
  10. forward GMCycleExists();
  11.  
  12. public OnFilterScriptInit()
  13. {
  14.         print(" Unlimited Gamemode Cycle by Ramjet loaded.");
  15.         return 1;
  16. }
  17.  
  18. public OnFilterScriptExit()
  19. {
  20.     print(" Unlimited Gamemode Cycle by Ramjet unloaded.");
  21.         return 1;
  22. }
  23.  
  24. // Our public function called remotely.
  25.  
  26. public GameModeExitEx()
  27. {
  28.         // Declare and initialise variables.
  29.         gmcount = GetGamemodeCount();
  30.         new string[256];
  31.     new File:filename = fopen(File_To_Read, io_readwrite);
  32.    
  33.     // Start the fille processing.
  34.     if(filename)
  35.         {
  36.             new i;
  37.                 while(fread(filename, string, 256))
  38.                 {
  39.                     // The mode we want to change to.
  40.                         if(i == counter)
  41.                         {
  42.                                new temp[256];
  43.                         StripNewLine(string);
  44.                         format(temp, sizeof(temp), "changemode %s", string);
  45.                         SendRconCommand(temp);
  46.                         counter++;
  47.                         break;
  48.                         }
  49.                        
  50.                         // We want to go back to gamemode0, so we will reset counter and reset the function.
  51.                         if(i == gmcount - 1)
  52.                         {
  53.                         counter = 0;
  54.                         fclose(filename);
  55.                         GameModeExitEx();
  56.                         }
  57.                         i++;
  58.                 }
  59.               fclose(filename);
  60.         }
  61.         return 1;
  62. }
  63.  
  64.  
  65. /**
  66.  *  Strips Newline from the end of a string.
  67.  *  Idea: Y_Less, Bugfixing (when length=1) by DracoBlue
  68.  *  @param   string
  69.  */
  70. stock StripNewLine(string[])
  71. {
  72.   new len = strlen(string);
  73.   if (string[0]==0) return ;
  74.   if ((string[len - 1] == '\n') || (string[len - 1] == '\r'))
  75.     {
  76.       string[len - 1] = 0;
  77.       if (string[0]==0) return ;
  78.       if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0;
  79.     }
  80. }
  81.  
  82. GetGamemodeCount()
  83. {
  84.     new File:filename = fopen("gmcycle.txt", io_readwrite), temp[256], i;
  85.         if(filename)
  86.         {
  87.                 while(fread(filename, temp, 256)) i++;
  88.                 fclose(filename);
  89.         }
  90.         return i;
  91. }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

fantasy-obligation