Problem with value. Simple - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with value. Simple (
/showthread.php?tid=599530)
Problem with value. Simple -
Mikeydoo - 27.01.2016
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(string, sizeof(string), "* Your cow has been fed and got bigger by %d lbs", cw);
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_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] < 100) cw = 50;
else if(PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 300) cw = 75;
else if(PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 700) cw = 100;
else if(PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 1200) cw = 125;
else if(PlayerInfo[playerid][pJobSkill][JOB_FARMER] >= 1200) cw = 150;
PlayerInfo[playerid][pCow][cow] += cw;
format(string, sizeof(string), "* Your cow has been fed and got bigger by %d lbs", cw);
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
DestroyDynamicObject(CowFence);
KillTimer(CowCooldown[playerid]);
}
return 1;
}
Thanks much
Re: Problem with value. Simple -
[KHK]Khalid - 27.01.2016
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)
Re: Problem with value. Simple -
Mikeydoo - 27.01.2016
damn.. This should do.. Changed == 5 to == 0 ... thanks a lot budd