Save timestamp questions(mysql)
#1

Hi guys

I'm using timestamp for Prison Time.For example,when i put player in prison:
//time is minutes
Код:
PlayerInfo[ID][Prison] = (gettime() +time*60);
It's all fine.But i have "problem" when i want to save it.(I'm find way to do it,but i'm sure that here have better way to do it)
I can't save it as timestamp,i need to convert it into seconds.My code(i think it's bad idea so..)

Код:
  		if(PlayerInfo[playerid][Prison] > 1000000)
	    {
   			format(szQuery, sizeof(szQuery), "UPDATE `accounts` SET `Prison`='%i' WHERE `ID`='%i'", PlayerInfo[playerid][Prison]-gettime(),PlayerInfo[playerid][dbID]);
			mysql_tquery(g_SQL, szQuery);
		}
		else
		{
			format(szQuery, sizeof(szQuery), "UPDATE `accounts` SET `Prison`='%i' WHERE `ID`='%i'", PlayerInfo[playerid][Prison],PlayerInfo[playerid][dbID]);
			mysql_tquery(g_SQL, szQuery);
		}
Why I'm make check if(PlayerInfo[playerid][Prison] > 10000000 ).Because when player is not in Prison he have Prison = 0 .(So without this check it will be 0-gettime() and it's -252522525

When Player log in game:

PlayerInfo[playerid][Prison] = (PlayerInfo[playerid][Prison] + gettime());
It all works good,but my question is better way to do this..Because i don't have idea

Thank you(sorry for English)
Reply
#2

Bump..Second page
Reply
#3

Last bump...I'm stil don't fix this..
So I need best way to save timestamp into seconds in MySQL.
Reply
#4

You can use DATETIME in MySQL.
Why don't just store the time of the player in 3 different fields when jailed?
Day
Hour
Minute

You can calculate much more easy that way
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)