02.03.2016, 20:19
Hey guys!
I am working on a script and something is not working correctly:
I'm trying to do an interest/lvlup system, which gives the +amount of interest and gives +1 score every 1 hour online.
Everything else is working correctly, the problem is the constantly growing delay between saved timer seconds and saved played seconds.
After joining and leaving, the timer saved 17 seconds, and with the gettime().. it saved 19 seconds.
I've also tried SetTimerEx, but there was a delay too.
Also, I've checked that after a minute the delay grows into 7 seconds (timer saves 60 seconds, gettime()... saves 67 secs.)
Sorry for unclear explanation and bad english, if something is not clear please tell me.
Please help me with this one.
I am working on a script and something is not working correctly:
I'm trying to do an interest/lvlup system, which gives the +amount of interest and gives +1 score every 1 hour online.
Everything else is working correctly, the problem is the constantly growing delay between saved timer seconds and saved played seconds.
Код:
new FizuIdo; // timer new fizump[MAX_PLAYERS]; // seconds forward FizuTimer(playerid); public FizuTimer(playerid) { fizump[playerid]++; if(fizump[playerid] >= 3600) // 1 hour -- { new time = gettime() - gPlayerJoin[playerid]; new score = GetPlayerScore(playerid); new string[128], kamat[128], ora, egyenleg; ora = (PlayerInfo[playerid][pJatszottIdo]+time)/3600; egyenleg = PlayerInfo[playerid][pBank]; fizump[playerid] = 0; ... } return 1; } public OnPlayerSpawn(playerid) { gPlayerJoin[playerid] = gettime(); SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]); fizump[playerid] = PlayerInfo[playerid][pFizetesOra]; // load saved seconds FizuIdo = SetTimer("FizuTimer", 1000, 1); // paycheck timer start again return 1; } public OnPlayerDisconnect(playerid, reason) { KillTimer(FizuIdo); // shall this be after saving timer seconds? (line above return 1) new time = gettime() - gPlayerJoin[playerid]; new jOra = (PlayerInfo[playerid][pJatszottIdo]+time)/3600; new jPerc = (PlayerInfo[playerid][pJatszottIdo]+time)/60; new jMp = PlayerInfo[playerid][pJatszottIdo]+time-(60*jPerc); ... INI_WriteInt(File, "Уra", jOra); INI_WriteInt(File, "Perc", jPerc); INI_WriteInt(File, "Mбsodperc", jMp); INI_WriteInt(File, "JбtszottIdő", PlayerInfo[playerid][pJatszottIdo] + time); INI_WriteInt(File, "FizetйsУra", fizump[playerid]); // SAVING TIMER SECONDS return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == dialog_register) { ... INI_WriteInt(File, "JбtszottIdő", 0); // saving played seconds INI_WriteInt(File, "FizetйsУra", 0); // saving timer seconds } if(dialogid == dialog_login) { fizump[playerid] = PlayerInfo[playerid][pFizetesOra]; // loading timer seconds } return 1; }
I've also tried SetTimerEx, but there was a delay too.
Also, I've checked that after a minute the delay grows into 7 seconds (timer saves 60 seconds, gettime()... saves 67 secs.)
Sorry for unclear explanation and bad english, if something is not clear please tell me.
Please help me with this one.