Save time game in MySQL
#5

I count time in OnPlayerSpawn.

OnPlayerSpawn:

Код:
SetPVarInt(playerid, "GraszDzis", GetTickCount());
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);
	format(czas_gry_ogol,sizeof czas_gry_ogol,"UPDATE `Gracze` SET `Czas_gry_ogol` = `Czas_gry_ogol` + '%02d:%02d:%02d'  WHERE `Nick` = '%s'",  Hour, Minute, Second,  PlayerName(playerid));
	mysql_query(czas_gry_ogol);
Structure table:


Код:
CREATE TABLE  `Gracze` (
 `Id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
 `Nick` VARCHAR( 24 ) NOT NULL ,
 `Haslo` VARCHAR( 32 ) NOT NULL ,
 `Data_urodzin` DATE NOT NULL COMMENT  'W urodziny dostaje się prezent',
 `Data_rejestracji` DATETIME NOT NULL ,
 `Punkty` INT( 11 ) NOT NULL DEFAULT  '0',
 `Lvl` INT( 11 ) UNSIGNED NOT NULL ,
 `Exp` INT( 11 ) UNSIGNED NOT NULL ,
 `Zabojstwa` INT( 11 ) UNSIGNED NOT NULL DEFAULT  '0',
 `Smierci` INT( 11 ) NOT NULL DEFAULT  '0',
 `Wizyty` INT( 11 ) UNSIGNED NOT NULL ,
 `Vip` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT  '0',
 `Pozycja` DECIMAL( 65, 0 ) NOT NULL COMMENT  'Zapisana pozycja po wyjściu',
 `Czas_gry_dzis` TIME NOT NULL COMMENT  'Łączny czas gry dziś',
 `Czas_gry_ogol` TIME NOT NULL COMMENT  'Łączny czas gry w ogуle',
PRIMARY KEY (  `Id` ,  `Nick` ) ,
FULLTEXT KEY  `HASLO` (  `Haslo` )
) ENGINE = MYISAM DEFAULT CHARSET = latin1;
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)