PayDay bug
#1

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!
Reply
#2

Where do you set the timer?
Reply
#3

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

I'm guessing not everyones pLevel is more than 0
Reply
#5

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

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();
}
Reply
#7

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!
Reply
#8

bump
Reply
#9

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]];
}
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)