Problem with value. Simple
#1

Ok so I'm having a hard time figuring this out. I know it's a simple mistake but when I run the script and start the timer, the timer works but when it reaches 5 second ( else if(CowTime[playerid] == 5) ) , this part doesn't work. Looks like ''cw'' isnt well defined or syntax is wrong.

So this part doesnt work
PHP Code:
   PlayerInfo[playerid][pCow][cow] += cw;
        
format(stringsizeof(string), "* Your cow has been fed and got bigger by %d lbs"cw);
        
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
        
DestroyDynamicObject(CowFence); 
This is the whole timer

PHP Code:
forward CowTimeCooldown(playerid);
public 
CowTimeCooldown(playerid)
{
    if(
CowTime[playerid] > 0)
    {
        
CowTime[playerid] --;
    }
    else if(
CowTime[playerid] == 5)
    {
           new 
string[128], cow;
           new 
cw;
        if(
PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 100cw 50;
        else if(
PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 300cw 75;
        else if(
PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 700cw 100;
        else if(
PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 1200cw 125;
        else if(
PlayerInfo[playerid][pJobSkill][JOB_FARMER] >= 1200cw 150;
        
PlayerInfo[playerid][pCow][cow] += cw;
        
format(stringsizeof(string), "* Your cow has been fed and got bigger by %d lbs"cw);
        
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
        
DestroyDynamicObject(CowFence);
        
KillTimer(CowCooldown[playerid]);
       }
    return 
1;

Thanks much
Reply
#2

In your first if statement, you check if CowTime is greater than 0, being that 5 is greater than 0, your else-if will not be reached when CowTime equals 5, the if statement code will take place instead. To fix this, you should check if CowTime is greater than 5, not 0:

pawn Code:
if(CowTime[playerid] > 5)
Reply
#3

damn.. This should do.. Changed == 5 to == 0 ... thanks a lot budd
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)