15.10.2015, 12:28
Well, I think that your new function won't fix your problem because you didn't define hours, minutes, seconds in function for example when you get the time the system will get 0 0 0 (I think)
should sth like this
But I am not so sure
- EDIT -
I just tested what I said and gives normal times instead of 0 0 0 that it used to give before edit
Код:
PlayerConnectedTime(playerid, &hours, &minutes, &seconds) { new connected_time = NetStats_GetConnectedTime(playerid); new CurrentTime[3]; CurrentTime[2] = (connected_time / 1000) % 60; CurrentTime[1] = (connected_time / (1000 * 60)) % 60; CurrentTime[0] = (connected_time / (1000 * 60 * 60)); new SavedTime[3]; SavedTime[2] = SQL::GetIntEntry(""PLAYERS_TABLE"", "seconds", "id", User[playerid][id]); SavedTime[1] = SQL::GetIntEntry(""PLAYERS_TABLE"", "minutes", "id", User[playerid][id]); SavedTime[0] = SQL::GetIntEntry(""PLAYERS_TABLE"", "hours", "id", User[playerid][id]); new TotalTime[3]; TotalTime[2] = CurrentTime[2] + SavedTime[2]; TotalTime[1] = CurrentTime[1] + SavedTime[1]; TotalTime[0] = CurrentTime[0] + SavedTime[0]; if (TotalTime[2] >= 60) { TotalTime[2] = 0; TotalTime[1]++; if (TotalTime[1] >= 60) { TotalTime[1] = 0; TotalTime[2]++; } } return true; }
Код:
PlayerConnectedTime(playerid, &hours, &minutes, &seconds) { new connected_time = NetStats_GetConnectedTime(playerid); new CurrentTime[3]; CurrentTime[2] = (connected_time / 1000) % 60; CurrentTime[1] = (connected_time / (1000 * 60)) % 60; CurrentTime[0] = (connected_time / (1000 * 60 * 60)); new key = DB::RetrieveKey(gGlobal[s_usertable], "username", ReturnPlayerName(playerid)); new SavedTime[3]; if(key != DB::INVALID_KEY) { SavedTime[2] = DB::GetIntEntry(gGlobal[s_usertable], key, "seconds"); SavedTime[1] = DB::GetIntEntry(gGlobal[s_usertable], key, "minutes"); SavedTime[0] = DB::GetIntEntry(gGlobal[s_usertable], key, "hours"); } new TotalTime[3]; TotalTime[2] = CurrentTime[2] + SavedTime[2]; TotalTime[1] = CurrentTime[1] + SavedTime[1]; TotalTime[0] = CurrentTime[0] + SavedTime[0]; if (TotalTime[2] >= 60) { TotalTime[2] = 0; TotalTime[1]++; if (TotalTime[1] >= 60) { TotalTime[1] = 0; TotalTime[2]++; } } seconds = TotalTime[2]; minutes = TotalTime[1]; hours = TotalTime[0]; return true; }
- EDIT -
I just tested what I said and gives normal times instead of 0 0 0 that it used to give before edit