Stuck On Weather Texdraws
#1

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:WeatherWeathers;
       
//OnGameModeInit
Weather TextDrawCreate(556.000000126.000000"");
TextDrawAlignment(Weather2);
TextDrawBackgroundColor(Weather255);
TextDrawFont(Weather2);
TextDrawLetterSize(Weather0.4200001.600000);
TextDrawColor(Weather, -1);
TextDrawSetOutline(Weather1);
TextDrawSetProportional(Weather1);
TextDrawSetSelectable(Weather0);
SetTimer("RandomWeathers"60000*3true);
//Function
forward RandomWeathers();
public 
RandomWeathers()
{
Weathers random(20);
SetWeather(Weathers);
switch(
Weathers)
{
              case 
0:
            {
                new 
string[50];
                
format(stringsizeof string"Sunny");
                
TextDrawSetString(Weatherstring);
            }
           case 
1:
            {
                new 
string[50];
                
format(stringsizeof string"Sunny");
                
TextDrawSetString(Weatherstring);
            } 
Anyone know why this code didnt work?
Reply
#2

this code looks good but you formatting string to sunny in both cases
Reply
#3

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".
Reply
#4

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)