Weird Weather System bug
#1

I have edited this so many times I can't see where the problem is..

pawn Код:
#define weather_debug // Comment this out to disable debug printing

forward Weather();
#define WeatherTime 4500 // used in WeatherTimer
new WeatherTimer, Wrun=0, WeatherID;


public Weather()
{
    new change = 0;
    #if defined weather_debug
        print("Weather Changer Function called");
    #endif
    if(Wrun <= 3)
    {
        Wrun++;
    }
    else
    {
      change = random(7);
    }
    #if defined weather_debug
        printf("change: %i", change);
    #endif
    if(change == 1 || change == 3 || change == 4)
    {
        WeatherID = random(55);
        if(WeatherID >= 0 && WeatherID <= 8) SetWeather(WeatherID);
        else if(WeatherID == 9) WeatherID=90;
        else if(WeatherID >= 10 && WeatherID <= 12) WeatherID=WeatherID+0;
        else if(WeatherID == 13) WeatherID=16;
        else if(WeatherID == 14) WeatherID=18;
        else if(WeatherID == 15) WeatherID=53;
        else if(WeatherID == 16) WeatherID=56;
        else if(WeatherID == 17) WeatherID=58;
        else if(WeatherID == 18) WeatherID=63;
        else if(WeatherID == 19) WeatherID=69;
        else if(WeatherID >= 20 && WeatherID <= 23) WeatherID=WeatherID+14;
        else if(WeatherID >= 24 && WeatherID <= 31) WeatherID=40;
        else WeatherID=1337;
        if(WeatherID < 0 && WeatherID > 8) SetWeather(WeatherID);
        #if defined weather_debug
        format(Nstring, sizeof(Nstring), "Wrun: %i      WeatherID: %i", Wrun, WeatherID);
            SendClientMessageToAll(0x00FF00FF, Nstring);
        #endif
    }
    if(change == 2 || change == 4)
    {
        Wrun=0;
    }
    #if defined weather_debug
        printf("Wrun: %i", Wrun);
    #endif
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerWeather(playerid, WeatherID);
}
This sort of works, but the problem is that, it seems to work only if this happends:

* Player1234 joined the server
* Player1234 left the server
* Player1234 joined the server

(Names doesn't matter)

Someone must first connect then leave, then the code works
Reply
#2

I assume you are actually running the weather timer?
Reply
#3

Yes, under GameModeInit:

Код:
WeatherTimer = SetTimer("Weather", WeatherTime, 1);
Forgot to include it in the first post
Reply
#4

Thats odd. You don't get any printouts on the command line?
Reply
#5

No, not before this weird thing happens:

Quote:

* Player1234 joined the server
* Player1234 left the server
* Player1234 joined the server

(Names doesn't matter)

After that the code works, as it should..


EDIT:
Changed the code a little, same problem
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)