SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/01/2016, 02:01 AM   #1
Mikeydoo
Big Clucker
 
Mikeydoo's Avatar
 
Join Date: Mar 2012
Location: Quebec, Canada
Posts: 93
Reputation: 1
Default Problem with value. Simple

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
Mikeydoo is offline   Reply With Quote
Old 27/01/2016, 03:13 AM   #2
[KHK]Khalid
Gangsta
 
[KHK]Khalid's Avatar
 
Join Date: Jan 2012
Location: Alexandria, Egypt
Posts: 854
Reputation: 136
Default Re: Problem with value. Simple

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)
[KHK]Khalid is offline   Reply With Quote
Old 27/01/2016, 07:34 PM   #3
Mikeydoo
Big Clucker
 
Mikeydoo's Avatar
 
Join Date: Mar 2012
Location: Quebec, Canada
Posts: 93
Reputation: 1
Default Re: Problem with value. Simple

damn.. This should do.. Changed == 5 to == 0 ... thanks a lot budd
Mikeydoo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple problem please help friezakinght Scripting Help 28 07/07/2014 04:09 PM
Killing Spree problem[Most simple and I have problem :( ] SpiderWalk Scripting Help 13 29/04/2012 08:13 AM
Simple Problem... Littlehelper Scripting Help 6 02/03/2012 09:40 AM
Simple problem -.- again nejc001 Help Archive 6 25/09/2010 12:32 PM


All times are GMT. The time now is 09:42 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.