Save time game in MySQL
#10

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 :
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);
}
This is just an example of how you might be able to do it.
Reply


Messages In This Thread
Save time game in MySQL - by Kerth - 02.11.2013, 14:48
Re: Save time game in MySQL - by Jefff - 02.11.2013, 15:02
Re: Save time game in MySQL - by Kerth - 02.11.2013, 15:17
Re: Save time game in MySQL - by Jefff - 02.11.2013, 18:50
Re: Save time game in MySQL - by Kerth - 02.11.2013, 21:03
Re: Save time game in MySQL - by rappy93 - 02.11.2013, 21:16
Re: Save time game in MySQL - by Kerth - 02.11.2013, 21:28
Re: Save time game in MySQL - by Jefff - 02.11.2013, 21:32
Re: Save time game in MySQL - by Kerth - 02.11.2013, 21:51
Re: Save time game in MySQL - by rappy93 - 02.11.2013, 21:55

Forum Jump:


Users browsing this thread: 1 Guest(s)