Advertisement
Jstylezzz

Maploader V1.0b - by Jstylezzz

May 7th, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.66 KB | None | 0 0
  1. /*
  2.                                                             *********************************
  3.                                                             *   Maploader by Jstylezzz      *
  4.                                                             *       Keep the credits!       *
  5.                                                             *                               *
  6.                                                             *               V1.0b           *
  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.  
  12.  
  13. */
  14.  
  15. #include <a_samp>
  16. #include <zcmd> //Credits to Zeex
  17. #include <streamer> //Credits to Incognito
  18.  
  19. #define CHANGE_INTERVAL 15*60000 //change this to the amount of minutes to trigger the map change, change the first number (time in minutes)
  20. //default is 15 minutes
  21. #define MAX_FASES 3 //max number of maps, to add more maps, increase this number, and add maps to the Changemap public
  22. #define COLOR_RED 0xFF0000FF
  23. #define COLOR_ORANGE 0xFFA500FF
  24.  
  25. public OnFilterScriptInit()
  26. {
  27.    
  28.     print("\n--------------------------------------");
  29.     print(" Maploader by Jstylezzz             ");
  30.     print("--------------------------------------\n");
  31.     if(!fexist("fase.txt"))
  32.     {
  33.     new File:fasenum=fopen("fase.txt", io_write);
  34.     new text[128];
  35.     format(text,128,"%d",0);
  36.     fwrite(fasenum, text);
  37.     fclose(fasenum);
  38.     print("\n---------------------------------------------");
  39.     print("Fase config file not existing.. Creating it now");
  40.     print("---------------------------------------------\n");
  41.     }
  42.     new fase;
  43.     new tempstring[64];
  44.     new File:fasenum = fopen("fase.txt", io_read);
  45.     fread(fasenum, tempstring);
  46.     fclose(fasenum);
  47.     fase = strval(tempstring);
  48.     Changemap(fase);
  49.    
  50.    
  51.     return 1;
  52. }
  53. forward Warnplayers();
  54. public Warnplayers()
  55. {
  56. SendClientMessageToAll(COLOR_ORANGE,"[Maploader]Attention all players! In 10 seconds the server will move on to the next map!");
  57. print("[Maploader]Switching to next map in 10 seconds!");
  58. }
  59. forward Changemap(fase);//Mapping in this callback IN STREAMER FORMAT!! {CreateDynamicObject(...);}
  60. public Changemap(fase)
  61. {
  62.     SendClientMessageToAll(COLOR_ORANGE,"[Maploader]Next map loaded!");
  63.     DestroyAllDynamicObjects();
  64.     if(fase == 0)
  65.     {
  66.     //add mapping here
  67.    
  68.     }
  69.     if(fase == 1)
  70.     {
  71.     //add mapping here
  72.     }
  73.     if(fase == 2)
  74.     {
  75.     //add mapping here
  76.     }
  77.  
  78.     new File:fasenum=fopen("fase.txt", io_write);
  79.     new text[128];
  80.     format(text,128,"%d",random(MAX_FASES));
  81.     fwrite(fasenum, text);
  82.     fclose(fasenum);
  83.     new nfase = strval(text);
  84.     SetTimer("Warnplayers",CHANGE_INTERVAL-10000,false);
  85.     SetTimerEx("Changemap",CHANGE_INTERVAL,false,"i",nfase);
  86.    
  87.     print("\n---------------------------------------------");
  88.     printf("Maploader switching to next map in %d minutes.\nMap loaded: %d ",CHANGE_INTERVAL/60000,nfase);
  89.     print("---------------------------------------------\n");
  90.    
  91.     //to add more maps, just write if(fase == mapnumber)
  92. }
  93.  
  94.  
  95. public OnPlayerConnect(playerid)
  96. {
  97.     SendClientMessage(playerid,COLOR_ORANGE,"[Maploader]This server is powered by Jstylezzz' Maploader");
  98.     return 1;
  99. }
  100.  
  101. //commands
  102. CMD:changenow(playerid,params[])
  103. {
  104.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"Only RCON admins can use this command.");
  105.     new File:fasenum=fopen("fase.txt", io_write);
  106.     new text[128];
  107.     format(text,128,"%d",random(MAX_FASES));
  108.     fwrite(fasenum, text);
  109.     fclose(fasenum);
  110.     SendClientMessage(playerid,COLOR_ORANGE,"[Maploader]You have initiated the map changing process.");
  111.     SendClientMessageToAll(COLOR_RED,"[Maploader]Server restarting in 10 seconds. Reason: admin command");
  112.     SetTimer("OnFilterScriptExit",10000,false);
  113.     return 1;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement