SA-MP Forums Archive
PayDay bug - 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: PayDay bug (/showthread.php?tid=470240)



PayDay bug - Jacksta21 - 16.10.2013

Hello, so I made this payday, and I can't seem to figure out why not all the players get the payday every hour.
It can be viewed here: http://pastebin.com/McN9p05b
Any help would be appreciated.
Also the playing hours "[pConnectTime]" dont get added to the player every hour either (Sometimes works sometimes doesnt) Again, any help would be much appreciated!


Re: PayDay bug - tyler12 - 16.10.2013

Where do you set the timer?


Re: PayDay bug - Jacksta21 - 16.10.2013

http://pastebin.com/ny65dP1z
Thats what syncs the time, and calls the payday each hour.


Re: PayDay bug - cessil - 16.10.2013

I'm guessing not everyones pLevel is more than 0


Re: PayDay bug - Jacksta21 - 17.10.2013

All players start off as level 1.
I'm really not sure why, sometimes it gives players paydays, sometimes it doesnt, it's strange :/


Re: PayDay bug - HolyScripter - 17.10.2013

try change
pawn Код:
PayDay();

using Timer like this

delete PayDay(); from sync timer and change with this
SetTimerEx("TimerPayDay",2000,false,"d",playerid);

After 2 Second They will got payday

forward TimerPayday(playerid);
public TimerPayDay(playerid)
{
    PayDay();
}



Re: PayDay bug - Jacksta21 - 17.10.2013

Quote:
Originally Posted by HolyScripter
Посмотреть сообщение
try change
pawn Код:
PayDay();

using Timer like this

delete PayDay(); from sync timer and change with this
SetTimerEx("TimerPayDay",2000,false,"d",playerid);

After 2 Second They will got payday

forward TimerPayday(playerid);
public TimerPayDay(playerid)
{
    PayDay();
}
Doesn't work.
Any more help would be greatly appreciated!


Re: PayDay bug - Jacksta21 - 19.10.2013

bump


Re: PayDay bug - cessil - 19.10.2013

If you access an invalid index of an array the function will end.
You could also add a loop at the top of payday to just count everyone online, then in the loop, print out the index each time so you know if its stopping too early, or you can try using the crash detect plugin which will tell you each time you access an invalid index.

Other than that, try making your script more readable, use switch statements for multiple ifs, stop using magic numbers for constants

for example, something like this
pawn Код:
if(PlayerInfo[i][pDonateRank] == 0 && interest > 50000)
{
    interest = 50000;
}
else if(PlayerInfo[i][pDonateRank] == 1 && interest > 100000)
{
    interest = 100000;
}
else if(PlayerInfo[i][pDonateRank] == 2 && interest > 150000)
{
    interest = 150000;
}
else if(PlayerInfo[i][pDonateRank] == 3 && interest > 200000)
{
    interest = 200000;
}
else if(PlayerInfo[i][pDonateRank] >= 4 && interest > 250000)
{
    interest = 250000;
}
could be trimmed down to one simple check
pawn Код:
if(interest > InterestRates[PlayerInfo[i][pDonateRank]])
{
    interest = InterestRates[PlayerInfo[i][pDonateRank]];
}



Re: PayDay bug - Jacksta21 - 21.10.2013

Thanks I'll try trimming it down, and I'll also try out that Crash Detect plugin, Thanks for your help Cessil!