MySQL DATETIME -
Runn3R - 28.09.2014
How do i take a DATETIME from the table and send it in SendClientMessage? I mean is there any mysql function to do this?
Looks like this:
Loading:
Код:
PlayerInfo[playerid][LastActivity] = cache_get_field_content_int(0, "LastActivity");
Displays in chat:
Thanks.
Re: MySQL DATETIME -
TheNerka - 28.09.2014
use this
on the enum
[code]LastLogin[50]/CODE]
Код:
Save:
new texts[128];
new y,m,d;
new hr,mins,sec;
getdate(y,m,d);
gettime(hr,mins,sec);
format(texts, sizeof(texts), "%d-%d-%d %d-%d-%d", y, m, d, hr, mins, sec);
mysql_format(Mysql_users, query, sizeof(query), "UPDATE `you_user_table` SET LastLogin = '%e' WHERE Fullname= '%e'",texts, GetPlayersName(playerid));
mysql_tquery(Mysql_users, query, "", "");
Show in msg:
Код:
new msg[128];
format(msg, sizeof(msg), "%s", PlayerData[playerid][LastLogin]);
SendClientMessage(playerid, -1, msg);
load:
Код:
cache_get_field_content(0, "LastLogin", PlayerData[playerid][LastLogin], Mysql_users, 126);
in mysql structure:
Код:
Name: LastLogin
Type: datetime
Mysql R38
Im using this script working created by me
Re: MySQL DATETIME -
Runn3R - 28.09.2014
Yeah but i'm already using UTC_TIMESTAMP() i just need to load the timestamp from the database and put it into the players chat.
Re: MySQL DATETIME -
TheNerka - 28.09.2014
Use my load code and structure and msg
Re: MySQL DATETIME -
Runn3R - 28.09.2014
I'll try this one. If somebody has a better solution please post it here. Thanks.
Re: MySQL DATETIME -
Runn3R - 28.09.2014
Found a way to do it with the UTC_TIMESTAMP()! Thanks anyways..
Re: MySQL DATETIME -
AroseKhanNiazi - 01.07.2016
Quote:
Originally Posted by Runn3R
Found a way to do it with the UTC_TIMESTAMP()! Thanks anyways..
|
Sorry for a 2 year old bump but it's better to bump it then making a new thread so how did you do it?
Saving and loading again is an option but; anyway I can just process a mysql query for UTC_TIMESTAMP(); and then use it to show in textdraw etc.
Re: MySQL DATETIME -
PrO.GameR - 01.07.2016
To turn a timestamp into readable date-time use ctime library:
http://forum.sa-mp.com/showthread.ph...ighlight=ctime
to turn it into a readable one thru the mysql query itself use something like this
PHP код:
DATE_FORMAT(FROM_UNIXTIME(`user.registration`), '%e %b %Y') AS 'date_formatted'
in your query (change parameters to suit your needs, this example was taken from stackoverflow)
If you want to save the timestamp itself for later use in your gamemode I guess first one is the way to go.
Re: MySQL DATETIME -
AroseKhanNiazi - 01.07.2016
Just tried something like that but it won't work.
Код:
mysql_format(ban_SQL, string, sizeof(string), "SELECT * FROM `Bans` WHERE `BanID`=%d LIMIT 1",BanID);
mysql_pquery(ban_SQL, string);
cache_get_field_content(0, "BanExpire",BanInfo[BanID][BanExpire] , ban_SQL,20);
if(BanInfo[BanID][BanPerma])
format(BanInfo[BanID][BanExpire],20,"~R~~H~Never");
else
format(BanInfo[BanID][BanExpire],20,"%s",string);
cache_get_field_content(0, "BanDate",BanInfo[BanID][BanDate] , ban_SQL,20);
This will return me empty string which will crash the server as i'm using this in a callremotefuction for a textdraw.
Re: MySQL DATETIME -
AroseKhanNiazi - 02.07.2016
Something that could help me here?