Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *********************************
- * Maploader by Jstylezzz *
- * Keep the credits! *
- * *
- * V1.0b *
- *********************************
- Idea by zClaw - http://forum.sa-mp.com/member.php?u=190121
- Link to the Idea post - http://forum.sa-mp.com/showthread.php?t=415791
- Script by Jstylezzz - http://forum.sa-mp.com/member.php?u=140130
- */
- #include <a_samp>
- #include <zcmd> //Credits to Zeex
- #include <streamer> //Credits to Incognito
- #define CHANGE_INTERVAL 15*60000 //change this to the amount of minutes to trigger the map change, change the first number (time in minutes)
- //default is 15 minutes
- #define MAX_FASES 3 //max number of maps, to add more maps, increase this number, and add maps to the Changemap public
- #define COLOR_RED 0xFF0000FF
- #define COLOR_ORANGE 0xFFA500FF
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Maploader by Jstylezzz ");
- print("--------------------------------------\n");
- if(!fexist("fase.txt"))
- {
- new File:fasenum=fopen("fase.txt", io_write);
- new text[128];
- format(text,128,"%d",0);
- fwrite(fasenum, text);
- fclose(fasenum);
- print("\n---------------------------------------------");
- print("Fase config file not existing.. Creating it now");
- print("---------------------------------------------\n");
- }
- new fase;
- new tempstring[64];
- new File:fasenum = fopen("fase.txt", io_read);
- fread(fasenum, tempstring);
- fclose(fasenum);
- fase = strval(tempstring);
- Changemap(fase);
- return 1;
- }
- forward Warnplayers();
- public Warnplayers()
- {
- SendClientMessageToAll(COLOR_ORANGE,"[Maploader]Attention all players! In 10 seconds the server will move on to the next map!");
- print("[Maploader]Switching to next map in 10 seconds!");
- }
- forward Changemap(fase);//Mapping in this callback IN STREAMER FORMAT!! {CreateDynamicObject(...);}
- public Changemap(fase)
- {
- SendClientMessageToAll(COLOR_ORANGE,"[Maploader]Next map loaded!");
- DestroyAllDynamicObjects();
- if(fase == 0)
- {
- //add mapping here
- }
- if(fase == 1)
- {
- //add mapping here
- }
- if(fase == 2)
- {
- //add mapping here
- }
- new File:fasenum=fopen("fase.txt", io_write);
- new text[128];
- format(text,128,"%d",random(MAX_FASES));
- fwrite(fasenum, text);
- fclose(fasenum);
- new nfase = strval(text);
- SetTimer("Warnplayers",CHANGE_INTERVAL-10000,false);
- SetTimerEx("Changemap",CHANGE_INTERVAL,false,"i",nfase);
- print("\n---------------------------------------------");
- printf("Maploader switching to next map in %d minutes.\nMap loaded: %d ",CHANGE_INTERVAL/60000,nfase);
- print("---------------------------------------------\n");
- //to add more maps, just write if(fase == mapnumber)
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid,COLOR_ORANGE,"[Maploader]This server is powered by Jstylezzz' Maploader");
- return 1;
- }
- //commands
- CMD:changenow(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"Only RCON admins can use this command.");
- new File:fasenum=fopen("fase.txt", io_write);
- new text[128];
- format(text,128,"%d",random(MAX_FASES));
- fwrite(fasenum, text);
- fclose(fasenum);
- SendClientMessage(playerid,COLOR_ORANGE,"[Maploader]You have initiated the map changing process.");
- SendClientMessageToAll(COLOR_RED,"[Maploader]Server restarting in 10 seconds. Reason: admin command");
- SetTimer("OnFilterScriptExit",10000,false);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement