20.07.2015, 10:27
Hello.
I seem to have a problem here, regarding Daily Bonuses when the player logs into his account or registers.
Basically, every 24 hours, after the player logs in he will recieve score, money..
That's not a problem.
However i don't know how to check each 24 hours, i made a script which doesn't seem to be working.
The saving system is MySQL, but i think this can be done without saving, which i would prefer if possible.
And then here i have the online time that's constantly counting.
Any help appreciated.
I seem to have a problem here, regarding Daily Bonuses when the player logs into his account or registers.
Basically, every 24 hours, after the player logs in he will recieve score, money..
That's not a problem.
However i don't know how to check each 24 hours, i made a script which doesn't seem to be working.
The saving system is MySQL, but i think this can be done without saving, which i would prefer if possible.
Код:
function CheckDailyBonus(playerid) { if(PInfo[playerid][TotalTime] % 24 == 0) { GivePlayerMoney(playerid, 50000); GivePlayerScore(playerid, 20); new string[128]; format(string,sizeof(string),"[+] "CBLUE"%s(%i) has collected "CGREEN"Daily bonus"CBLUE".",GetPName(playerid),playerid); SendClientMessageToAll(COL_GREEN, string); ShowBonusTDs(playerid); } else { return 1; } }
Код:
TotalGameTime(playerid, &h = 0, &m = 0) { PInfo[playerid][TotalTime] = ( (gettime() - PInfo[playerid][ConnectTime]) + (PInfo[playerid][PlayedHours]*60*60) + (PInfo[playerid][PlayedMins]*60) ); h = floatround(PInfo[playerid][TotalTime] / 3600, floatround_floor); m = floatround(PInfo[playerid][TotalTime] / 60, floatround_floor) % 60; return PInfo[playerid][TotalTime]; }