02.11.2013, 21:55
In this case I think you should make a variable under OnPlayerConnect to store the existing time and then,when he disconnects add the new time to the old one and then insert it into the database. Here is an example :
This is just an example of how you might be able to do it.
pawn Код:
// at the top of your gamemode
new playedtime[MAX_PLAYERS];
// then
public OnPlayerConnect
{
new czas_gry_ogol[128];
playedtime[playerid] = format(czas_gry_ogol,sizeof czas_gry_ogol,"SELECT `Czas_gry_ogol` FROM `Gracze` WHERE Nick` = '%s'", PlayerName(playerid)); // now it stored the last updated played hours
mysql_query(czas_gry_ogol);
}
public OnPlayerDisconnect
{
new czas_gry_ogol[128];
new Hour, Minute, Second;
gettime( Hour, Minute, Second);
ConvertMS(GetTickCount()-GetPVarInt(playerid, "GraszDzis"), Hour, Minute, Second);
printf("%02d:%02d:%02d", Hour, Minute, Second);
new update_playedtime = playedtime[playerid] + "Hour, Minute, Second" // or something like this,im not sure
format(czas_gry_ogol,sizeof czas_gry_ogol,"UPDATE `Gracze` SET `Czas_gry_ogol` = '%02d:%02d:%02d' WHERE `Nick` = '%s'", update_playedtime, PlayerName(playerid));
mysql_query(czas_gry_ogol);
}