Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*---------------------------------------------------------------------------------------------*\
- | (C)Remi-X |
- | _________ _______ ______ ______ ____ ____ ____ |
- | | _ \ | | | \ / | | | \ \ / / |
- | | | | | | ____| | \ / | | | \ \ / / |
- | | |_| | | |____ | |\ \ / /| | | | ______ \ \/ / |
- | | _ \ | | | | \ \ / / | | | | | | \ / |
- | | | \ \ | ____| | | \ \_/ / | | | | |______| / \ |
- | | | \ \ | |____ | | \ / | | | | / /\ \ |
- | | | \ \ | | | | \ / | | | | / / \ \ |
- | |___| \____\ |_______| |___| \___/ |___| |____| /___/ \___\ |
- | |
- | The Remi-X Time Tools V1.3 |
- | Please, do not remove any credits. |
- \*---------------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------------*\
- | Changelog V1.3: |
- | -You can coose if players must see their time, or the servertime. |
- | -Edit line: 239, and set it to true if you want the servertime, or false for the playertime.|
- | -Commands (RCON): |
- | -/rw : Sets a random weather. |
- | -/w [weatherid] to choose a weather. |
- | -/settime [hour] to set the Server World Time. |
- \*---------------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------------*\
- | Changelog V1.2: |
- | -Stupid red weather hopefully deleted... |
- \*---------------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------------*\
- | Changelog V1.1: |
- | -Some Dutch text translated, that I was forgotten. |
- | -If you startup the FilterScript, a random weather will be choosen. |
- | -If you startup the FilterScript, the worldtime will also set directly. |
- | -The weather, changed at the older version just one time (Bug). Now always. |
- \*---------------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------------*\
- | The Remi-X Time Tools V1.0: |
- | -Ingame clock, working on servertime, in seconds. |
- | -If it is night in your server time, than will it be also ingame night. |
- | -A random weather script, that will change the weather every hour. |
- | -The weather is based on the seasons, so if it's summer, you don't get winter weather. |
- | -There are no bullshit weathers, like the darkest weather ever. |
- | -The clock works on servertime, with seconds. |
- | -The clock has the same place as the original clock of San Andreas. |
- | -There is also a simple date, only without the year. |
- | -If it's month 4, the game says April. |
- | -The WorldTime change also, so if someone check your server values, he see also the hour. |
- | -There is a SetPlayerTime, so every minute will the daytime changed. |
- \*---------------------------------------------------------------------------------------------*/
- ///////////Includes//////////
- #include <a_samp>
- ///////////Defines//////////
- //Colors
- #define BLACK 0x000000FF
- #define WHITE 0xFFFFFFFF
- #define YELLOW 0xFFFF00FF
- #define RED 0xE60000FF
- //FilterScript
- #define FILTERSCRIPT
- ///////////News//////////
- //TextDraw
- new Text:TextdrawHour;
- new Text:TextdrawMinute;
- new Text:TextdrawSeconds;
- new Text:TextdrawDay;
- new Text:TextdrawMonth;
- //Bools
- new bool:ServerTimeWanted;
- //Weather
- new SpringWeather[8] = {1,10,11,14,17,23,29,33};
- new SummerWeather[5] = {0,1,10,11,19};
- new AutumnWeather[10] = {7,8,9,12,15,16,17,25,30,32};
- new WinterWeather[13] = {1,4,5,7,8,9,12,15,17,20,25,27,30};
- ///////////Forwards//////////
- forward RemiX_Time_Tools(playerid);
- ///////////Callbacks//////////
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- //Print
- print("\n--------------------------------------");
- print(" Remi-X Time-Tools V 1.3 started up.");
- print("--------------------------------------\n");
- //News
- new Year, Month, Day;
- new ServerHour, ServerMinute, ServerSecond;
- new summerrand = random(sizeof(SummerWeather));
- new winterrand = random(sizeof(WinterWeather));
- new springrand = random(sizeof(SpringWeather));
- new autumnrand = random(sizeof(AutumnWeather));
- //Gets
- getdate(Year, Month, Day);
- gettime(ServerHour, ServerMinute, ServerSecond);
- //Time hours Textdraw
- TextdrawHour = TextDrawCreate(546.000000,22.000000,"--");
- TextDrawAlignment(TextdrawHour,0);
- TextDrawBackgroundColor(TextdrawHour,BLACK);
- TextDrawFont(TextdrawHour,3);
- TextDrawLetterSize(TextdrawHour,0.634,2.4);
- TextDrawColor(TextdrawHour,WHITE);
- TextDrawSetOutline(TextdrawHour,1);
- TextDrawSetProportional(TextdrawHour,1);
- TextDrawSetShadow(TextdrawHour,1);
- //Time minutes Textdraw
- TextdrawMinute = TextDrawCreate(570.200000,22.000000,"--");
- TextDrawAlignment(TextdrawMinute,0);
- TextDrawBackgroundColor(TextdrawMinute,BLACK);
- TextDrawFont(TextdrawMinute,3);
- TextDrawLetterSize(TextdrawMinute,0.634,2.4);
- TextDrawColor(TextdrawMinute,WHITE);
- TextDrawSetOutline(TextdrawMinute,1);
- TextDrawSetProportional(TextdrawMinute,1);
- TextDrawSetShadow(TextdrawMinute,1);
- //Time Seconds Textdraw
- TextdrawSeconds = TextDrawCreate(606.500000,33.000000,"--");
- TextDrawAlignment(TextdrawSeconds,0);
- TextDrawBackgroundColor(TextdrawSeconds,BLACK);
- TextDrawFont(TextdrawSeconds,3);
- TextDrawLetterSize(TextdrawSeconds,0.3,1.0);
- TextDrawColor(TextdrawSeconds,WHITE);
- TextDrawSetOutline(TextdrawSeconds,1);
- TextDrawSetProportional(TextdrawSeconds,1);
- TextDrawSetShadow(TextdrawSeconds,1);
- //Day
- TextdrawDay = TextDrawCreate(500.000000,10.000000,"--");
- TextDrawAlignment(TextdrawDay,0);
- TextDrawBackgroundColor(TextdrawDay,BLACK);
- TextDrawFont(TextdrawDay,3);
- TextDrawLetterSize(TextdrawDay,0.44,1.2);
- TextDrawColor(TextdrawDay,WHITE);
- TextDrawSetOutline(TextdrawDay,1);
- TextDrawSetProportional(TextdrawDay,1);
- TextDrawSetShadow(TextdrawDay,1);
- //Month
- TextdrawMonth = TextDrawCreate(515.000000,10.000000,"---------");
- TextDrawAlignment(TextdrawMonth,0);
- TextDrawBackgroundColor(TextdrawMonth,BLACK);
- TextDrawFont(TextdrawMonth,3);
- TextDrawLetterSize(TextdrawMonth,0.44,1.2);
- TextDrawColor(TextdrawMonth,WHITE);
- TextDrawSetOutline(TextdrawMonth,1);
- TextDrawSetProportional(TextdrawMonth,1);
- TextDrawSetShadow(TextdrawMonth,1);
- //Random weather
- //Autumn
- if(Month == 12)
- {
- if(Day <21){SetWeather(AutumnWeather[autumnrand]);}
- //Winter
- else
- {
- SetWeather(WinterWeather[winterrand]);
- }
- }
- else if(Month == 1 || Month == 2)
- {
- SetWeather(winterrand);
- }
- else if(Month == 3)
- {
- if(Day <21)
- {
- SetWeather(WinterWeather[winterrand]);
- }
- //Spring
- else
- {
- SetWeather(SpringWeather[springrand]);
- }
- }
- else if (Month == 4 || Month == 5)
- {
- SetWeather(SpringWeather[springrand]);
- }
- else if(Month == 6)
- {
- if(Day <21)
- {
- SetWeather(SpringWeather[springrand]);
- }
- //Summer
- else
- {
- SetWeather(SummerWeather[summerrand]);
- }
- }
- else if(Month == 7 || Month == 8)
- {
- SetWeather(SummerWeather[summerrand]);
- }
- else if(Month == 9)
- {
- if(Day <21)
- {
- SetWeather(SummerWeather[summerrand]);
- }
- //Autumn
- else
- {
- SetWeather(AutumnWeather[autumnrand]);
- }
- }
- else if(Month == 10 || Month == 11)
- {
- SetWeather(AutumnWeather[autumnrand]);
- }
- SetWorldTime(ServerHour);
- //Timers
- SetTimer("RemiX_Time_Tools", 1000, true);
- //Bool
- ServerTimeWanted = false; //Edit this line to show the ServerTime (true) or PlayerTime (false).
- return 1;
- }
- public OnFilterScriptExit()
- {
- TextDrawDestroy(TextdrawHour);
- TextDrawDestroy(TextdrawMinute);
- TextDrawDestroy(TextdrawSeconds);
- TextDrawDestroy(TextdrawDay);
- TextDrawDestroy(TextdrawMonth);
- return 1;
- }
- #endif
- public OnPlayerConnect(playerid)
- {
- TextDrawHideForPlayer(playerid,TextdrawHour);
- TextDrawHideForPlayer(playerid,TextdrawMinute);
- TextDrawHideForPlayer(playerid,TextdrawSeconds);
- TextDrawHideForPlayer(playerid,TextdrawDay);
- TextDrawHideForPlayer(playerid,TextdrawMonth);
- SendClientMessage(playerid, YELLOW, "This server uses the Remi-X Time Tools V1.3.");
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- TextDrawHideForPlayer(playerid,TextdrawHour);
- TextDrawHideForPlayer(playerid,TextdrawMinute);
- TextDrawHideForPlayer(playerid,TextdrawSeconds);
- TextDrawHideForPlayer(playerid,TextdrawDay);
- TextDrawHideForPlayer(playerid,TextdrawMonth);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- TextDrawShowForPlayer(playerid,TextdrawHour);
- TextDrawShowForPlayer(playerid,TextdrawMinute);
- TextDrawShowForPlayer(playerid,TextdrawSeconds);
- TextDrawShowForPlayer(playerid,TextdrawDay);
- TextDrawShowForPlayer(playerid,TextdrawMonth);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- TextDrawHideForPlayer(playerid,TextdrawHour);
- TextDrawHideForPlayer(playerid,TextdrawMinute);
- TextDrawHideForPlayer(playerid,TextdrawSeconds);
- TextDrawHideForPlayer(playerid,TextdrawDay);
- TextDrawHideForPlayer(playerid,TextdrawMonth);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256],tmp[256];
- new idx;
- //gets
- cmd = strtok(cmdtext, idx);
- if(strcmp("/w", cmd, true, 10) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- new WID;
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, RED,"USAGE: /w [weatherid]");
- return 1;
- }
- WID = strval(tmp)
- SetWeather(WID);
- SendClientMessage(playerid, YELLOW, "Weather succesfull changed.");
- return 1;
- }
- else
- {
- SendClientMessage(playerid, RED, "You're not allowed to use RXTT commands!");
- return 1;
- }
- }
- if (strcmp("/rw", cmdtext, true) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- new Year, Month, Day;
- new summerrand = random(sizeof(SummerWeather));
- new winterrand = random(sizeof(WinterWeather));
- new springrand = random(sizeof(SpringWeather));
- new autumnrand = random(sizeof(AutumnWeather));
- getdate(Year, Month, Day);
- if(Month == 12)
- {
- if(Day <21){SetWeather(AutumnWeather[autumnrand]);}
- else {SetWeather(WinterWeather[winterrand]);}
- }
- else if(Month == 1 || Month == 2){SetWeather(winterrand);}
- else if(Month == 3)
- {
- if(Day <21){SetWeather(WinterWeather[winterrand]);}
- else{SetWeather(SpringWeather[springrand]);}
- }
- else if (Month == 4 || Month == 5){SetWeather(SpringWeather[springrand]);}
- else if(Month == 6)
- {
- if(Day <21){SetWeather(SpringWeather[springrand]);}
- else{SetWeather(SummerWeather[summerrand]);}
- }
- else if(Month == 7 || Month == 8){SetWeather(SummerWeather[summerrand]);}
- else if(Month == 9)
- {
- if(Day <21){SetWeather(SummerWeather[summerrand]);}
- else{SetWeather(AutumnWeather[autumnrand]);}
- }
- else if(Month == 10 || Month == 11){SetWeather(AutumnWeather[autumnrand]);}
- SendClientMessage(playerid, YELLOW, "Weather succesfull changed.");
- return 1;
- }
- else
- {
- SendClientMessage(playerid, RED, "You're not allowed to use RXTT commands!");
- return 1;
- }
- }
- if(strcmp("/settime", cmd, true, 10) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- new TimeHour;
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, RED,"USAGE: /settime [hour]");
- return 1;
- }
- TimeHour = strval(tmp)
- SetWorldTime(TimeHour);
- SendClientMessage(playerid, YELLOW, "Weather succesfull changed.");
- return 1;
- }
- else
- {
- SendClientMessage(playerid, RED, "You're not allowed to use RXTT commands!");
- return 1;
- }
- }
- return 1;
- }
- public RemiX_Time_Tools(playerid)
- {
- //News
- new string[256];
- new ServerHour, ServerMinute, ServerSecond;
- new PlayerHour, PlayerMinute;
- new Year, Month, Day;
- new summerrand = random(sizeof(SummerWeather));
- new winterrand = random(sizeof(WinterWeather));
- new springrand = random(sizeof(SpringWeather));
- new autumnrand = random(sizeof(AutumnWeather));
- //Gets
- gettime(ServerHour,ServerMinute,ServerSecond);
- getdate(Year, Month, Day);
- GetPlayerTime(playerid, PlayerHour, PlayerMinute);
- //TextDraw Clock
- if(ServerTimeWanted == true)
- {
- format(string, sizeof(string), "%02d", ServerHour);
- TextDrawSetString(TextdrawHour, string);
- format(string, sizeof(string), ":%02d", ServerMinute);
- TextDrawSetString(TextdrawMinute, string);
- format(string, sizeof(string), ":%02d", ServerSecond);
- TextDrawSetString(TextdrawSeconds, string);
- }
- else
- {
- format(string, sizeof(string), "%02d", PlayerHour);
- TextDrawSetString(TextdrawHour, string);
- format(string, sizeof(string), ":%02d", PlayerMinute);
- TextDrawSetString(TextdrawMinute, string);
- format(string, sizeof(string), ":%02d", ServerSecond);
- TextDrawSetString(TextdrawSeconds, string);
- }
- //DayTime set
- if(ServerTimeWanted == true){SetPlayerTime(playerid, ServerHour, ServerMinute);}
- else{SetPlayerTime(playerid, PlayerHour, PlayerMinute);}
- //TextDraw Day
- format(string, sizeof(string), "%02d", Day);
- TextDrawSetString(TextdrawDay, string);
- //TextDraw Month
- if(Month == 1)
- {
- format(string, sizeof(string), " January");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 2)
- {
- format(string, sizeof(string), " February");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 3)
- {
- format(string, sizeof(string), " March");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 4)
- {
- format(string, sizeof(string), " April");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 5)
- {
- format(string, sizeof(string), " May");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 6)
- {
- format(string, sizeof(string), " June");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 7)
- {
- format(string, sizeof(string), " July");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 8)
- {
- format(string, sizeof(string), " August");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 9)
- {
- format(string, sizeof(string), " September");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 10)
- {
- format(string, sizeof(string), " Oktober");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 11)
- {
- format(string, sizeof(string), " November");
- TextDrawSetString(TextdrawMonth, string);
- }
- else if(Month == 12)
- {
- format(string, sizeof(string), " December");
- TextDrawSetString(TextdrawMonth, string);
- }
- //Weather Changer
- if(ServerMinute == 0 && ServerSecond == 0)
- {
- if(ServerTimeWanted == true){format(string, sizeof(string), "It's %02d o' clock. The weather is changed.",ServerHour);}
- else{format(string, sizeof(string), "It's %02d o' clock. The weather is changed.",PlayerHour);}
- SendClientMessageToAll(YELLOW, string);
- format(string, sizeof(string), "The weather is changed. [%02d:%02d:%02d]",ServerHour, ServerMinute, ServerSecond);
- print(string);
- if(Month == 12)
- {
- if(Day <21)
- {
- SetWeather(AutumnWeather[autumnrand]);
- }
- //Winter
- else
- {
- SetWeather(WinterWeather[winterrand]);
- }
- }
- else if(Month == 1 || Month == 2)
- {
- SetWeather(winterrand);
- }
- else if(Month == 3)
- {
- if(Day <21)
- {
- SetWeather(WinterWeather[winterrand]);
- }
- //Spring
- else
- {
- SetWeather(SpringWeather[springrand]);
- }
- }
- else if (Month == 4 || Month == 5)
- {
- SetWeather(SpringWeather[springrand]);
- }
- else if(Month == 6)
- {
- if(Day <21)
- {
- SetWeather(SpringWeather[springrand]);
- }
- //Summer
- else
- {
- SetWeather(SummerWeather[summerrand]);
- }
- }
- else if(Month == 7 || Month == 8)
- {
- SetWeather(SummerWeather[summerrand]);
- }
- else if(Month == 9)
- {
- if(Day <21)
- {
- SetWeather(SummerWeather[summerrand]);
- }
- //Autumn
- else
- {
- SetWeather(AutumnWeather[autumnrand]);
- }
- }
- else if(Month == 10 || Month == 11)
- {
- SetWeather(AutumnWeather[autumnrand]);
- }
- SetWorldTime(ServerHour);
- }
- return 1;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment