Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //######################################################### Advanced Weather and Forecast System ##########################################################
- //##################################################################### Version 1.03a ####################################################################
- //##################################################################### By [XST]O_x #####################################################################
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////Credits/////////////////////////////////////////////////////////////////////////
- /*
- Zeex - zcmd
- [MM]RoXoR[FS] - tdgroups.inc
- iPLE0MAX - His amazing textdraw editor
- Y_Less - foreach
- */
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////Includes////////////////////////////////////////////////////////////////////////
- #include <a_samp>
- #include <tdgroups>
- #include <foreach>
- #include <zcmd>
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////Definitons///////////////////////////////////////////////////////////////////////
- #define USE_CLOCK //Comment this to hide clock
- #define VERSION "1.03a"
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #define RELEASED(%0) \
- (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- #define COLOR_PREFIX 0x93DCFFFF
- #define COLOR_BODY "{CB96FC}"
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////Variables////////////////////////////////////////////////////////////////////////
- new Text: fc_Background ;
- new Text: fc_DaySlot[ 7 ] ;
- new Text: fc_Border ;
- new Text: fc_WeatherSlot[ 7 ] ;
- new Text: fc_Title ;
- new tdGroup_Forecast ;
- #if defined USE_CLOCK
- new Text: fc_Clock ;
- new Text: td_ServerDay ;
- #endif
- new weekNeedle ;
- new weekWeather[ 7 ] ;
- new nextWeekWeather[ 7 ] ;
- new weekDays[][] = {
- {"Sunday"},
- {"Monday"},
- {"Tuesday"},
- {"Wednesday"},
- {"Thursday"},
- {"Friday"},
- {"Saturday"}
- } ;
- new possibleWeathers[ ][ ][ ] = {
- {0, "Extra Sunny"},
- {1, "Sunny"},
- {2, "Extra Sunny with Smog"},
- {3, "Sunny with Smog"},
- {4, "Cloudy"},
- {5, "Sunny"},
- {6, "Extra Sunny"},
- {7, "Cloudy"},
- {8, "Rainy"},
- {9, "Foggy"},
- {10, "Sunny"},
- {11, "Extra Sunny"},
- {12, "Cloudy"},
- {13, "Extra Sunny"},
- {14, "Sunny"},
- {15, "Cloudy"},
- {16, "Rainy"},
- {17, "Extra Sunny"},
- {18, "Sunny"}
- } ;
- new timerUpdateTime ;
- new timerWorldHours ;
- new timerWorldMinutes ;
- new bool: playerWatchingForecast[ MAX_PLAYERS ] ;
- forward UpdateServerTime() ;
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public OnFilterScriptInit()
- {
- print("*******************************************************");
- print(" ");
- print("Loaded Advanced Weather and Forecast System by [XST]O_x");
- print(" ");
- printf("Version: %s", VERSION);
- print(" ");
- print("*******************************************************");
- fc_Background = TextDrawCreate(175.666687, 171.739898, "usebox");
- TextDrawLetterSize(fc_Background, 0.000000, 14.797397);
- TextDrawTextSize(fc_Background, -0.666666, 0.000000);
- TextDrawAlignment(fc_Background, 1);
- TextDrawColor(fc_Background, 65535);
- TextDrawUseBox(fc_Background, true);
- TextDrawBoxColor(fc_Background, 35);
- TextDrawSetShadow(fc_Background, 0);
- TextDrawSetOutline(fc_Background, 0);
- TextDrawBackgroundColor(fc_Background, 65405);
- TextDrawFont(fc_Background, 0);
- fc_DaySlot[0] = TextDrawCreate(2.000000, 176.586608, "Wednesday");
- TextDrawLetterSize(fc_DaySlot[0], 0.333998, 1.499200);
- TextDrawAlignment(fc_DaySlot[0], 1);
- TextDrawColor(fc_DaySlot[0], -1);
- TextDrawSetShadow(fc_DaySlot[0], 0);
- TextDrawSetOutline(fc_DaySlot[0], 1);
- TextDrawBackgroundColor(fc_DaySlot[0], 51);
- TextDrawFont(fc_DaySlot[0], 1);
- TextDrawSetProportional(fc_DaySlot[0], 1);
- fc_DaySlot[1] = TextDrawCreate(2.00, 194.013275, "Wednesday");
- TextDrawLetterSize(fc_DaySlot[1], 0.333998, 1.499200);
- TextDrawAlignment(fc_DaySlot[1], 1);
- TextDrawColor(fc_DaySlot[1], -1);
- TextDrawSetShadow(fc_DaySlot[1], 0);
- TextDrawSetOutline(fc_DaySlot[1], 1);
- TextDrawBackgroundColor(fc_DaySlot[1], 51);
- TextDrawFont(fc_DaySlot[1], 1);
- TextDrawSetProportional(fc_DaySlot[1], 1);
- fc_DaySlot[2] = TextDrawCreate(2.00, 211.813293, "Wednesday");
- TextDrawLetterSize(fc_DaySlot[2], 0.333998, 1.499200);
- TextDrawAlignment(fc_DaySlot[2], 1);
- TextDrawColor(fc_DaySlot[2], -1);
- TextDrawSetShadow(fc_DaySlot[2], 0);
- TextDrawSetOutline(fc_DaySlot[2], 1);
- TextDrawBackgroundColor(fc_DaySlot[2], 51);
- TextDrawFont(fc_DaySlot[2], 1);
- TextDrawSetProportional(fc_DaySlot[2], 1);
- fc_DaySlot[3] = TextDrawCreate(2.00, 230.733398, "Wednesday");
- TextDrawLetterSize(fc_DaySlot[3], 0.333998, 1.499200);
- TextDrawAlignment(fc_DaySlot[3], 1);
- TextDrawColor(fc_DaySlot[3], -1);
- TextDrawSetShadow(fc_DaySlot[3], 0);
- TextDrawSetOutline(fc_DaySlot[3], 1);
- TextDrawBackgroundColor(fc_DaySlot[3], 51);
- TextDrawFont(fc_DaySlot[3], 1);
- TextDrawSetProportional(fc_DaySlot[3], 1);
- fc_DaySlot[4] = TextDrawCreate(2.00, 250.773498, "Wednesday");
- TextDrawLetterSize(fc_DaySlot[4], 0.333998, 1.499200);
- TextDrawAlignment(fc_DaySlot[4], 1);
- TextDrawColor(fc_DaySlot[4], -1);
- TextDrawSetShadow(fc_DaySlot[4], 0);
- TextDrawSetOutline(fc_DaySlot[4], 1);
- TextDrawBackgroundColor(fc_DaySlot[4], 51);
- TextDrawFont(fc_DaySlot[4], 1);
- TextDrawSetProportional(fc_DaySlot[4], 1);
- fc_DaySlot[5] = TextDrawCreate(2.00, 271.560119, "Wednesday");
- TextDrawLetterSize(fc_DaySlot[5], 0.333998, 1.499200);
- TextDrawAlignment(fc_DaySlot[5], 1);
- TextDrawColor(fc_DaySlot[5], -1);
- TextDrawSetShadow(fc_DaySlot[5], 0);
- TextDrawSetOutline(fc_DaySlot[5], 1);
- TextDrawBackgroundColor(fc_DaySlot[5], 51);
- TextDrawFont(fc_DaySlot[5], 1);
- TextDrawSetProportional(fc_DaySlot[5], 1);
- fc_DaySlot[6] = TextDrawCreate(2.00, 290.106781, "Wednesday");
- TextDrawLetterSize(fc_DaySlot[6], 0.333998, 1.499200);
- TextDrawAlignment(fc_DaySlot[6], 1);
- TextDrawColor(fc_DaySlot[6], -1);
- TextDrawSetShadow(fc_DaySlot[6], 0);
- TextDrawSetOutline(fc_DaySlot[6], 1);
- TextDrawBackgroundColor(fc_DaySlot[6], 51);
- TextDrawFont(fc_DaySlot[6], 1);
- TextDrawSetProportional(fc_DaySlot[6], 1);
- fc_Border = TextDrawCreate(76.333335, 172.113296, "usebox");
- TextDrawLetterSize(fc_Border, 0.000000, 14.749258);
- TextDrawTextSize(fc_Border, 73.000000, 0.000000);
- TextDrawAlignment(fc_Border, 1);
- TextDrawColor(fc_Border, 0);
- TextDrawUseBox(fc_Border, true);
- TextDrawBoxColor(fc_Border, 102);
- TextDrawSetShadow(fc_Border, 0);
- TextDrawSetOutline(fc_Border, 0);
- TextDrawFont(fc_Border, 0);
- fc_WeatherSlot[0] = TextDrawCreate(78.666633, 176.586608, "Extra Sunny with Smog");
- TextDrawLetterSize(fc_WeatherSlot[0], 0.227333, 1.338667);
- TextDrawAlignment(fc_WeatherSlot[0], 1);
- TextDrawColor(fc_WeatherSlot[0], -1);
- TextDrawSetShadow(fc_WeatherSlot[0], 0);
- TextDrawSetOutline(fc_WeatherSlot[0], 1);
- TextDrawBackgroundColor(fc_WeatherSlot[0], 51);
- TextDrawFont(fc_WeatherSlot[0], 1);
- TextDrawSetProportional(fc_WeatherSlot[0], 1);
- fc_WeatherSlot[1] = TextDrawCreate(78.666633, 194.013275, "Extra Sunny with Smog");
- TextDrawLetterSize(fc_WeatherSlot[1], 0.227333, 1.338667);
- TextDrawAlignment(fc_WeatherSlot[1], 1);
- TextDrawColor(fc_WeatherSlot[1], -1);
- TextDrawSetShadow(fc_WeatherSlot[1], 0);
- TextDrawSetOutline(fc_WeatherSlot[1], 1);
- TextDrawBackgroundColor(fc_WeatherSlot[1], 51);
- TextDrawFont(fc_WeatherSlot[1], 1);
- TextDrawSetProportional(fc_WeatherSlot[1], 1);
- fc_WeatherSlot[2] = TextDrawCreate(78.666633, 211.813293, "Extra Sunny with Smog");
- TextDrawLetterSize(fc_WeatherSlot[2], 0.227333, 1.338667);
- TextDrawAlignment(fc_WeatherSlot[2], 1);
- TextDrawColor(fc_WeatherSlot[2], -1);
- TextDrawSetShadow(fc_WeatherSlot[2], 0);
- TextDrawSetOutline(fc_WeatherSlot[2], 1);
- TextDrawBackgroundColor(fc_WeatherSlot[2], 51);
- TextDrawFont(fc_WeatherSlot[2], 1);
- TextDrawSetProportional(fc_WeatherSlot[2], 1);
- fc_WeatherSlot[3] = TextDrawCreate(78.666633, 230.733398, "Extra Sunny with Smog");
- TextDrawLetterSize(fc_WeatherSlot[3], 0.227333, 1.338667);
- TextDrawAlignment(fc_WeatherSlot[3], 1);
- TextDrawColor(fc_WeatherSlot[3], -1);
- TextDrawSetShadow(fc_WeatherSlot[3], 0);
- TextDrawSetOutline(fc_WeatherSlot[3], 1);
- TextDrawBackgroundColor(fc_WeatherSlot[3], 51);
- TextDrawFont(fc_WeatherSlot[3], 1);
- TextDrawSetProportional(fc_WeatherSlot[3], 1);
- fc_WeatherSlot[4] = TextDrawCreate(78.666633, 250.773498, "Extra Sunny with Smog");
- TextDrawLetterSize(fc_WeatherSlot[4], 0.227333, 1.338667);
- TextDrawAlignment(fc_WeatherSlot[4], 1);
- TextDrawColor(fc_WeatherSlot[4], -1);
- TextDrawSetShadow(fc_WeatherSlot[4], 0);
- TextDrawSetOutline(fc_WeatherSlot[4], 1);
- TextDrawBackgroundColor(fc_WeatherSlot[4], 51);
- TextDrawFont(fc_WeatherSlot[4], 1);
- TextDrawSetProportional(fc_WeatherSlot[4], 1);
- fc_WeatherSlot[5] = TextDrawCreate(78.666633, 271.560119, "Extra Sunny with Smog");
- TextDrawLetterSize(fc_WeatherSlot[5], 0.227333, 1.338667);
- TextDrawAlignment(fc_WeatherSlot[5], 1);
- TextDrawColor(fc_WeatherSlot[5], -1);
- TextDrawSetShadow(fc_WeatherSlot[5], 0);
- TextDrawSetOutline(fc_WeatherSlot[5], 1);
- TextDrawBackgroundColor(fc_WeatherSlot[5], 51);
- TextDrawFont(fc_WeatherSlot[5], 1);
- TextDrawSetProportional(fc_WeatherSlot[5], 1);
- fc_WeatherSlot[6] = TextDrawCreate(78.666633, 290.106781, "Extra Sunny with Smog");
- TextDrawLetterSize(fc_WeatherSlot[6], 0.227333, 1.338667);
- TextDrawAlignment(fc_WeatherSlot[6], 1);
- TextDrawColor(fc_WeatherSlot[6], -1);
- TextDrawSetShadow(fc_WeatherSlot[6], 0);
- TextDrawSetOutline(fc_WeatherSlot[6], 1);
- TextDrawBackgroundColor(fc_WeatherSlot[6], 51);
- TextDrawFont(fc_WeatherSlot[6], 1);
- TextDrawSetProportional(fc_WeatherSlot[6], 1);
- fc_Title = TextDrawCreate(2.666667, 153.813446, "Weather Forecast");
- TextDrawLetterSize(fc_Title, 0.449999, 1.600000);
- TextDrawAlignment(fc_Title, 1);
- TextDrawColor(fc_Title, -1378294017);
- TextDrawSetShadow(fc_Title, 0);
- TextDrawSetOutline(fc_Title, 1);
- TextDrawBackgroundColor(fc_Title, 51);
- TextDrawFont(fc_Title, 0);
- TextDrawSetProportional(fc_Title, 1);
- for(new i = 0; i< 7; i++) TextDrawColor(fc_WeatherSlot[i], -1061109505);
- #if defined USE_CLOCK
- fc_Clock = TextDrawCreate(552.333740, 4.853318, "23:59");
- TextDrawLetterSize(fc_Clock, 0.539999, 2.234666);
- TextDrawAlignment(fc_Clock, 1);
- TextDrawColor(fc_Clock, -1061109505);
- TextDrawSetShadow(fc_Clock, 0);
- TextDrawSetOutline(fc_Clock, 1);
- TextDrawBackgroundColor(fc_Clock, 255);
- TextDrawFont(fc_Clock, 3);
- TextDrawSetProportional(fc_Clock, 1);
- td_ServerDay = TextDrawCreate(487.333374, 5.973349, "Wednesday");
- TextDrawLetterSize(td_ServerDay, 0.449999, 1.600000);
- TextDrawAlignment(td_ServerDay, 2);
- TextDrawColor(td_ServerDay, -1378294017);
- TextDrawSetShadow(td_ServerDay, 0);
- TextDrawSetOutline(td_ServerDay, 1);
- TextDrawBackgroundColor(td_ServerDay, 51);
- TextDrawFont(td_ServerDay, 3);
- TextDrawSetProportional(td_ServerDay, 1);
- #endif
- for(new i=0;i<MAX_GROUPS;++i) tdenum[i][count2] = -1;
- tdGroup_Forecast = CreateTDGroup(fc_Border, fc_Title, fc_Background, fc_DaySlot[0], fc_DaySlot[3], fc_DaySlot[1], fc_DaySlot[2], fc_DaySlot[4], fc_DaySlot[5], fc_DaySlot[6], fc_WeatherSlot[0], fc_WeatherSlot[1], fc_WeatherSlot[2], fc_WeatherSlot[3], fc_WeatherSlot[4], fc_WeatherSlot[5], fc_WeatherSlot[6]);
- SetWorldTime(12);
- timerWorldHours = 12;
- timerWorldMinutes = 0;
- weekNeedle = 0;
- for(new i = 0; i < sizeof weekWeather; i++) {
- weekWeather[i] = possibleWeathers[random(sizeof(possibleWeathers))][0][0];
- nextWeekWeather[i] = weekWeather[i];
- }
- SetWeather(weekWeather[weekNeedle]);
- timerUpdateTime = SetTimer("UpdateServerTime", 1000, true);
- #if defined USE_CLOCK
- TextDrawSetString(td_ServerDay, weekDays[weekNeedle]);
- #endif
- return 1;
- }
- public UpdateServerTime()
- {
- #if defined USE_CLOCK
- new hourString[5];
- new minuteString[5];
- new timeString[5+5+1+1];
- #endif
- timerWorldMinutes++;
- if(timerWorldMinutes >= 60) {
- timerWorldMinutes = 0;
- timerWorldHours++;
- }
- if(timerWorldHours >= 24) {
- timerWorldHours = 0;
- }
- #if defined USE_CLOCK
- if(timerWorldMinutes < 10) {
- format(minuteString, sizeof minuteString, "0%d", timerWorldMinutes);
- }
- else format(minuteString, sizeof minuteString, "%d", timerWorldMinutes);
- if(timerWorldHours < 10) {
- format(hourString, sizeof hourString, "0%d", timerWorldHours);
- }
- else format(hourString, sizeof hourString, "%d", timerWorldHours);
- format(timeString, sizeof timeString, "%s:%s", hourString, minuteString);
- TextDrawSetString(fc_Clock, timeString);
- #endif
- if(timerWorldHours == 23 && timerWorldMinutes == 59) {
- weekNeedle++;
- if(weekNeedle == sizeof(weekWeather)) {
- //print("Week is over. Starting new week...");
- //print("This week's weather:");
- for(new i = 0; i < sizeof weekWeather; i++) {
- weekWeather[i] = nextWeekWeather[i];
- //printf("%s: %s(%d)", weekDays[i], possibleWeathers[weekWeather[i]][1], possibleWeathers[weekWeather[i]][0]);
- }
- weekNeedle = 0;
- //printf("%s: Weather: %s(%d)", weekDays[weekNeedle], possibleWeathers[weekWeather[weekNeedle]][1], weekWeather[weekNeedle]);
- }
- SetWeather(weekWeather[weekNeedle]);
- new msgDay[144];
- format(msgDay, sizeof msgDay, " [aWeather] >> "COLOR_BODY"Today is: %s. Weather foreseen for today: %s", weekDays[weekNeedle], possibleWeathers[weekWeather[weekNeedle]][1]);
- SendClientMessageToAll(COLOR_PREFIX, msgDay);
- #if defined USE_CLOCK
- TextDrawSetString(td_ServerDay, weekDays[weekNeedle]);
- #endif
- //printf("%s: Weather: %s(%d)", weekDays[weekNeedle], possibleWeathers[weekWeather[weekNeedle]][1], weekWeather[weekNeedle]);
- /*for(new i = 0; i < sizeof nextWeekWeather; i++) {
- new day;
- if((weekNeedle + i) > 6) day = ((weekNeedle + i) - 7);
- else day = weekNeedle + i;
- new tmpStr[24]; format(tmpStr, sizeof tmpStr, "~b~~h~~h~%s", weekDays[day]);
- TextDrawSetString(fc_DaySlot[ i], tmpStr);
- TextDrawSetString(fc_WeatherSlot[i], possibleWeathers[nextWeekWeather[i]][1]);
- }*/
- nextWeekWeather[6] = possibleWeathers[random(sizeof(possibleWeathers))][0][0];
- for(new i = 0; i < (sizeof(nextWeekWeather)-1); i++) {
- nextWeekWeather[i] = nextWeekWeather[i+1];
- //printf("Day %d: Weather: %s(%d)", i+1, possibleWeathers[nextWeekWeather[i]][1], nextWeekWeather[i]);
- }
- //printf("Day %d: Weather: %s(%d)", sizeof nextWeekWeather, possibleWeathers[nextWeekWeather[sizeof(nextWeekWeather)-1]][1], nextWeekWeather[sizeof(nextWeekWeather)-1]);*/
- //nextWeekWeather[weekNeedle] = possibleWeathers[random(sizeof(possibleWeathers))][0][0];
- for(new i = 0; i < sizeof nextWeekWeather; i++) {
- new day;
- if((weekNeedle + i) > 6) day = ((weekNeedle + i) - 7);
- else day = weekNeedle + i;
- //printf("%d",day);
- TextDrawSetString(fc_DaySlot[ i ], weekDays[day]);
- TextDrawSetString(fc_WeatherSlot[i], possibleWeathers[nextWeekWeather[i]][1]);
- }
- }
- foreach(new i: Player) {
- SetPlayerTime(i, timerWorldHours, timerWorldMinutes);
- }
- //print(timeString);
- return 1;
- }
- public OnFilterScriptExit()
- {
- #if defined USE_CLOCK
- TextDrawDestroy(fc_Clock);
- TextDrawDestroy(td_ServerDay);
- #endif
- KillTimer(timerUpdateTime);
- TextDrawDestroy(fc_Background);
- TextDrawDestroy(fc_Border);
- TextDrawDestroy(fc_Title);
- for(new i = 0; i < 7; i++) TextDrawDestroy(fc_DaySlot[i]), TextDrawDestroy(fc_WeatherSlot[i]);
- return 1;
- }
- CMD:forecast(playerid, params[])
- {
- if(!playerWatchingForecast[playerid]) {
- TDGroupShowForPlayer(playerid, tdGroup_Forecast);
- for(new i = 0; i < sizeof nextWeekWeather; i++) {
- new day;
- if((weekNeedle + i) > 6) day = ((weekNeedle + i) - 7);
- else day = weekNeedle + i;
- new tmpStr[24]; format(tmpStr, sizeof tmpStr, "~b~~h~~h~%s", weekDays[day]);
- TextDrawSetString(fc_DaySlot[ i], tmpStr);
- TextDrawSetString(fc_WeatherSlot[i], possibleWeathers[nextWeekWeather[i]][1]);
- playerWatchingForecast[playerid] = true;
- }
- }
- else {
- TDGroupHideForPlayer(playerid, tdGroup_Forecast);
- playerWatchingForecast[playerid] = false;
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(PRESSED(KEY_NO)) {
- TDGroupShowForPlayer(playerid, tdGroup_Forecast);
- for(new i = 0; i < sizeof nextWeekWeather; i++) {
- new day;
- if((weekNeedle + i) > 6) day = ((weekNeedle + i) - 7);
- else day = weekNeedle + i;
- new tmpStr[24]; format(tmpStr, sizeof tmpStr, "~b~~h~~h~%s", weekDays[day]);
- TextDrawSetString(fc_DaySlot[ i], tmpStr);
- TextDrawSetString(fc_WeatherSlot[i], possibleWeathers[nextWeekWeather[i]][1]);
- playerWatchingForecast[playerid] = true;
- }
- }
- if(RELEASED(KEY_NO)) {
- TDGroupHideForPlayer(playerid, tdGroup_Forecast);
- playerWatchingForecast[playerid] = false;
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- #if defined USE_CLOCK
- TextDrawShowForPlayer(playerid, fc_Clock);
- TextDrawShowForPlayer(playerid, td_ServerDay);
- #endif
- playerWatchingForecast[playerid] = false;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment