Time/Weather System
#1

Hello,

With this time/weather system, would it be possible to make the Players Class Section (OnPlayerRequestClass) to night? Then when he/she spawns, it sets the back to normal on spawn.



Код:
//Includes
#include <a_samp>

//Colors
#define BLACK			0x000000FF
#define WHITE 			0xFFFFFFFF
#define YELLOW 			0xFFFF00FF

//TextDraw
new Text:TextdrawHour;
new Text:TextdrawMinute;
new Text:TextdrawSeconds;
new Text:TextdrawDay;
new Text:TextdrawMonth;

//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);

#define FILTERSCRIPT
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	//News
	new Year, Month, Day;
	new Hour, Minute, Second;
	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(Hour, Minute, Second);

	//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(551.000000, 54.000000, "--");
	TextDrawAlignment(TextdrawDay, 2);
	TextDrawBackgroundColor(TextdrawDay, BLACK);
	TextDrawFont(TextdrawDay, 3);
	TextDrawLetterSize(TextdrawDay, 0.289999, 1.299999);
	TextDrawColor(TextdrawDay, -1);
	TextDrawSetOutline(TextdrawDay, 1);
	TextDrawSetProportional(TextdrawDay, 1);

	//Month
	TextdrawMonth = TextDrawCreate(585.000000, 54.000000, "---------");
	TextDrawAlignment(TextdrawMonth, 2);
	TextDrawBackgroundColor(TextdrawMonth, BLACK);
	TextDrawFont(TextdrawMonth, 3);
	TextDrawLetterSize(TextdrawMonth, 0.289999, 1.299999);
	TextDrawColor(TextdrawMonth, WHITE);
	TextDrawSetOutline(TextdrawMonth, 1);
	TextDrawSetProportional(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]);
	}
	if(Hour == 22){SetWorldTime(22);}
	else{SetWorldTime(Hour);}

	//Timers
	SetTimer("RemiX_Time_Tools", 1000, true);
	return 1;
}

public OnFilterScriptExit()
{
	TextDrawDestroy(TextdrawHour);
	TextDrawDestroy(TextdrawMinute);
	TextDrawDestroy(TextdrawSeconds);
	TextDrawDestroy(TextdrawDay);
	TextDrawDestroy(TextdrawMonth);
	return 1;
}

#endif

public OnPlayerRequestClass(playerid, classid)
{
	TextDrawHideForPlayer(playerid,TextdrawHour);
	TextDrawHideForPlayer(playerid,TextdrawMinute);
	TextDrawHideForPlayer(playerid,TextdrawSeconds);
	TextDrawHideForPlayer(playerid,TextdrawDay);
	TextDrawHideForPlayer(playerid,TextdrawMonth);
	return 1;
}

public OnPlayerConnect(playerid)
{
	TextDrawHideForPlayer(playerid,TextdrawHour);
	TextDrawHideForPlayer(playerid,TextdrawMinute);
	TextDrawHideForPlayer(playerid,TextdrawSeconds);
	TextDrawHideForPlayer(playerid,TextdrawDay);
	TextDrawHideForPlayer(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 OnPlayerSpawn(playerid)
{

	TextDrawShowForPlayer(playerid,TextdrawHour);
	TextDrawShowForPlayer(playerid,TextdrawMinute);
	TextDrawShowForPlayer(playerid,TextdrawSeconds);
	TextDrawShowForPlayer(playerid,TextdrawDay);
	TextDrawShowForPlayer(playerid,TextdrawMonth);
	return 1;
}

public RemiX_Time_Tools(playerid)
{
	//News
	new string[256];
	new Hour, Minute, Second;
	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(Hour,Minute,Second);
	getdate(Year, Month, Day);

	//TextDraw Clock
	format(string, sizeof(string), "%02d", Hour);
	TextDrawSetString(TextdrawHour, string);

	format(string, sizeof(string), ":%02d", Minute);
	TextDrawSetString(TextdrawMinute, string);

	format(string, sizeof(string), ":%02d", Second);
	TextDrawSetString(TextdrawSeconds, string);

	//DayTime set
	SetPlayerTime(playerid, Hour, Minute);

	//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(Minute == 0 && Second == 0)
	{
		format(string, sizeof(string), "It's %02d o' clock. The weather is changed.",Hour);
		SendClientMessageToAll(YELLOW, string);
		format(string, sizeof(string), "The weather is changed.  [%02d:%02d:%02d]",Hour, Minute, Second);
		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]);
		}
  		if(Hour == 22){SetWorldTime(22);}
		else{SetWorldTime(Hour);}
	}
	return 1;
}
Thanks
Reply
#2

Yes, it is possible using SetPlayerWeather function:

https://sampwiki.blast.hk/wiki/SetPlayerWeather

Under the OnPlayerConnect, you set the player's weather to a night weather ID ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)