Stuck On Weather Texdraws - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Stuck On Weather Texdraws (
/showthread.php?tid=644157)
Stuck On Weather Texdraws -
AgusZ - 04.11.2017
I dont know why this code didnt work.
First, i make a statement about textdraw will change based on weather.
Example : If weather rainy, the textdraw will show Rainy.
My code.
PHP код:
new Text:Weather, Weathers;
//OnGameModeInit
Weather = TextDrawCreate(556.000000, 126.000000, "");
TextDrawAlignment(Weather, 2);
TextDrawBackgroundColor(Weather, 255);
TextDrawFont(Weather, 2);
TextDrawLetterSize(Weather, 0.420000, 1.600000);
TextDrawColor(Weather, -1);
TextDrawSetOutline(Weather, 1);
TextDrawSetProportional(Weather, 1);
TextDrawSetSelectable(Weather, 0);
SetTimer("RandomWeathers", 60000*3, true);
//Function
forward RandomWeathers();
public RandomWeathers()
{
Weathers = random(20);
SetWeather(Weathers);
switch(Weathers)
{
case 0:
{
new string[50];
format(string, sizeof string, "Sunny");
TextDrawSetString(Weather, string);
}
case 1:
{
new string[50];
format(string, sizeof string, "Sunny");
TextDrawSetString(Weather, string);
}
Anyone know why this code didnt work?
Re: Stuck On Weather Texdraws -
TrueThing - 04.11.2017
this code looks good but you formatting string to sunny in both cases
Re: Stuck On Weather Texdraws -
ExTaZZ69 - 04.11.2017
I suppose you have more than 2 cases in that switch. If not, you should catch all cases:
case 0: case 1: ... case 19: ... or case 1: .. case 2: .. default: ..
The problem is that you have to show the textdraw after you set a new string for it.
Use TextDrawShowForPlayer(playerid, Weather); or TextDrawShowForAll(Weather) after that "switch".
Re: Stuck On Weather Texdraws -
AgusZ - 04.11.2017
I have found the problem, its a timer.
I've set the timer 6000 milisecond * 2, this is why the textdraw not showing.
But i made a new function for the textdraw for 1000 milisecond but the textdraw didnt matches from weather id, what can i do?