Advertisement
Jstylezzz

Maploader V1.1 - by Jstylezzz

May 7th, 2013
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.88 KB | None | 0 0
  1. /*
  2.                                                             *********************************
  3.                                                             *   Maploader by Jstylezzz      *
  4.                                                             *       Keep the credits!       *
  5.                                                             *                               *
  6.                                                             *               V1.1            *
  7.                                                             *********************************
  8. Idea by zClaw - http://forum.sa-mp.com/member.php?u=190121
  9. Link to the Idea post - http://forum.sa-mp.com/showthread.php?t=415791
  10. Script by Jstylezzz - http://forum.sa-mp.com/member.php?u=140130
  11. I updated the release thread with a detailed explanation on how to add maps.
  12.  
  13. Feel free to send me any script requests! ~ Jstylezzz
  14.  
  15. Update marked as done - 7/5/13 - DD/MM/YY
  16. */
  17.  
  18. #include <a_samp> //Credits to the SA-MP Team
  19. #include <zcmd> //Credits to Zeex
  20. #include <streamer> //Credits to Incognito
  21. #include <timerfix> //Credits to Slice
  22. #include <mapping> //All your mapping needs to be placed here, read the release thread for detailed instructions
  23.  
  24. #define CHANGE_INTERVAL 15*60000 //change this to the amount of minutes to trigger the map change, change the first number (time in minutes)
  25. //default is 15 minutes
  26. #define MAX_FASES 3 //max number of maps, to add more maps, increase this number
  27. #define COLOR_RED 0xFF0000FF
  28. #define COLOR_ORANGE 0xFFA500FF
  29.  
  30. public OnFilterScriptInit()
  31. {
  32.    
  33.     print("\n--------------------------------------");
  34.     print(" Maploader by Jstylezzz             ");
  35.     print("--------------------------------------\n");
  36.     if(!fexist("fase.txt"))
  37.     {
  38.     new File:fasenum=fopen("fase.txt", io_write);
  39.     new text[128];
  40.     format(text,128,"%d",0);
  41.     fwrite(fasenum, text);
  42.     fclose(fasenum);
  43.     print("\n---------------------------------------------");
  44.     print("Fase config file not existing.. Creating it now");
  45.     print("---------------------------------------------\n");
  46.     }
  47.     new fase;
  48.     new tempstring[64];
  49.     new File:fasenum = fopen("fase.txt", io_read);
  50.     fread(fasenum, tempstring);
  51.     fclose(fasenum);
  52.     fase = strval(tempstring);
  53.     Changemap(fase);
  54.    
  55.    
  56.     return 1;
  57. }
  58. forward Warnplayers();
  59. public Warnplayers()
  60. {
  61. SendClientMessageToAll(COLOR_ORANGE,"[Maploader]Attention all players! In 10 seconds the server will move on to the next map!");
  62. print("[Maploader]Switching to next map in 10 seconds!");
  63. }
  64. forward Changemap(fase);
  65. public Changemap(fase)
  66. {
  67.     SendClientMessageToAll(COLOR_ORANGE,"[Maploader]Next map loaded!");
  68.     DestroyAllDynamicObjects();
  69.     switch(fase)
  70.     {
  71.         case 0:
  72.         {
  73.         Mapping_CreateFaseOne();
  74.         }
  75.         case 1:
  76.         {
  77.         Mapping_CreateFaseTwo();
  78.         }
  79.         case 2:
  80.         {
  81.         Mapping_CreateFaseThree();
  82.         }
  83.     }
  84.     new File:fasenum=fopen("fase.txt", io_write);
  85.     new text[128];
  86.     format(text,128,"%d",random(MAX_FASES));
  87.     fwrite(fasenum, text);
  88.     fclose(fasenum);
  89.     new nfase = strval(text);
  90.     SetTimer("Warnplayers",CHANGE_INTERVAL-10000,false);
  91.     SetTimerEx("Changemap",CHANGE_INTERVAL,false,"i",nfase);
  92.    
  93.     print("\n---------------------------------------------");
  94.     printf("Maploader switching to next map in %d minutes.\nMap loaded: %d ",CHANGE_INTERVAL/60000,nfase);
  95.     print("---------------------------------------------\n");
  96.    
  97.    
  98. }
  99.  
  100.  
  101. public OnPlayerConnect(playerid)
  102. {
  103.     SendClientMessage(playerid,COLOR_ORANGE,"[Maploader] This server is powered by Jstylezzz' Maploader");
  104.     return 1;
  105. }
  106.  
  107. //commands
  108. CMD:changenow(playerid,params[])
  109. {
  110.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"Only RCON admins can use this command.");
  111.     new File:fasenum=fopen("fase.txt", io_write);
  112.     new text[128];
  113.     format(text,128,"%d",random(MAX_FASES));
  114.     fwrite(fasenum, text);
  115.     fclose(fasenum);
  116.     SendClientMessage(playerid,COLOR_ORANGE,"[Maploader] You have initiated the map changing process.");
  117.     SendClientMessageToAll(COLOR_RED,"[Maploader] Map changing forced by admin.");
  118.     SetTimerEx("Changemap",10000,false,"i",strval(text));
  119.     Warnplayers();
  120.     return 1;
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement