Timer Problem
#1

I tested this out(without the debugging code), and wondered why the timer won't be called. I tried debugging it, and found where the problem was, but don't know what's wrong about it. The problem was after the second print("1") cause only 2 one's showed up.
PHP код:
forward FishUpdate(playerid);
public 
FishUpdate(playerid)
{
    if(
isFishing[playerid] == true)
    {
        print(
"1");
        if(
Fishes[playerid][pWeight1] < && Fishes[playerid][pWeight2] < && Fishes[playerid][pWeight3] < && Fishes[playerid][pWeight4] < && Fishes[playerid][pWeight5] < 0)
        {
            print(
"1");
            new 
string[128];
            print(
"1");
            if(
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                print(
"1");
                if(
IsABoat(GetPlayerVehicleID(playerid)))
                {
                    print(
"1");
                    new 
Caught;
                    print(
"1");
                    new 
rand;
                    print(
"1");
                    new 
fstring[MAX_PLAYER_NAME];
                    print(
"1");
                    
Caught random(100)-50;
                    print(
"1");
                    
rand random(FishNamesNumber);
                    print(
"1");
                    if(
Caught <= 0)
                    {
                        print(
"1");
                        
SendClientMessage(playeridCOLOR_FGREY"The line snapped.");
                        return 
1;
                    }
                    else if(
rand == 0)
                    {
                        print(
"1");
                        
SendClientMessage(playeridCOLOR_FGREY"You caught a jacket and threw it away.");
                        return 
1;
                    }
                    else if(
rand == 4)
                    {
                        print(
"1");
                        
SendClientMessage(playeridCOLOR_FGREY"You caught a pair of trousers and threw it away.");
                        return 
1;
                    }
                    else if(
rand == 7)
                    {
                        print(
"1");
                        
SendClientMessage(playeridCOLOR_FGREY"You caught a can and threw it away.");
                        return 
1;
                    }
                    else if(
rand == 10)
                    {
                        print(
"1");
                        
SendClientMessage(playeridCOLOR_FGREY"You caught a pair of shoes and threw it away.");
                        return 
1;
                    }
                    else if(
rand == 13)
                    {
                        print(
"1");
                        
SendClientMessage(playeridCOLOR_FGREY"You caught some garbage and threw it away.");
                        return 
1;
                    }
                    else if(
rand == 20)
                    {
                        print(
"1");
                        new 
mrand random(50);
                        
format(stringsizeof(string), "* You caught a bag filled with money ($%d)."mrand);
                        
SendClientMessage(playeridCOLOR_FLIGHTBLUEstring);
                        
GivePlayerMoney(playeridmrand);
                        return 
1;
                    }
                    if(
Fishes[playerid][pWeight1] == 0)
                    {
                        print(
"1");
                        
format(fstringsizeof(fstring), "%s"FishNames[rand]);
                        
strmid(Fishes[playerid][pFish1], fstring0strlen(fstring), 255);
                        
Fishes[playerid][pWeight1] = Caught;
                        
format(stringsizeof(string), "* You have caught a %s, weighing %d pounds."Fishes[playerid][pFish1], Caught);
                        
SendClientMessage(playeridCOLOR_FLIGHTBLUEstring);
                        
Fishes[playerid][pFid1] = rand;
                    }
                    else if(
Fishes[playerid][pWeight2] == 0)
                    {
                        print(
"1");
                        
format(fstringsizeof(fstring), "%s"FishNames[rand]);
                        
strmid(Fishes[playerid][pFish2], fstring0strlen(fstring), 255);
                        
Fishes[playerid][pWeight2] = Caught;
                        
format(stringsizeof(string), "* You have caught a %s, weighing %d pounds."Fishes[playerid][pFish2], Caught);
                        
SendClientMessage(playeridCOLOR_FLIGHTBLUEstring);
                        
Fishes[playerid][pFid2] = rand;
                    }
                    else if(
Fishes[playerid][pWeight3] == 0)
                    {
                        print(
"1");
                        
format(fstringsizeof(fstring), "%s"FishNames[rand]);
                        
strmid(Fishes[playerid][pFish3], fstring0strlen(fstring), 255);
                        
Fishes[playerid][pWeight3] = Caught;
                        
format(stringsizeof(string), "* You have caught a %s, weighing %d pounds."Fishes[playerid][pFish3], Caught);
                        
SendClientMessage(playeridCOLOR_FLIGHTBLUEstring);
                        
Fishes[playerid][pFid3] = rand;
                    }
                    else if(
Fishes[playerid][pWeight4] == 0)
                    {
                        print(
"1");
                         
format(fstringsizeof(fstring), "%s"FishNames[rand]);
                        
strmid(Fishes[playerid][pFish4], fstring0strlen(fstring), 255);
                        
Fishes[playerid][pWeight4] = Caught;
                        
format(stringsizeof(string), "* You have caught a %s, weighing %d pounds."Fishes[playerid][pFish4], Caught);
                        
SendClientMessage(playeridCOLOR_FLIGHTBLUEstring);
                        
Fishes[playerid][pFid4] = rand;
                    }
                    else if(
Fishes[playerid][pWeight5] == 0)
                    {
                        print(
"1");
                        
format(fstringsizeof(fstring), "%s"FishNames[rand]);
                        
strmid(Fishes[playerid][pFish5], fstring0strlen(fstring), 255);
                        
Fishes[playerid][pWeight5] = Caught;
                        
format(stringsizeof(string), "* You have caught a %s, weighing %d pounds."Fishes[playerid][pFish5], Caught);
                        
SendClientMessage(playeridCOLOR_FLIGHTBLUEstring);
                        
Fishes[playerid][pFid5] = rand;
                    }
                    else
                    {
                        print(
"1");
                        return 
1;
                    }
                }
            }
        }
        else
        {
            print(
"1");
            
KillTimer(fishtimer[playerid]);
        }
    }
    return 
1;

Reply
#2

Correction: Error line is here

PHP код:
if(Fishes[playerid][pWeight1] < && Fishes[playerid][pWeight2] < && Fishes[playerid][pWeight3] < && Fishes[playerid][pWeight4] < && Fishes[playerid][pWeight5] < 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)