MySQL DATETIME
#1

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:
Код:
2014-09-27 17:52:28
Loading:
Код:
PlayerInfo[playerid][LastActivity] = cache_get_field_content_int(0, "LastActivity");
Displays in chat:
Код:
'2014'
Thanks.
Reply
#2

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
Reply
#3

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.
Reply
#4

Use my load code and structure and msg
Reply
#5

I'll try this one. If somebody has a better solution please post it here. Thanks.
Reply
#6

Found a way to do it with the UTC_TIMESTAMP()! Thanks anyways..
Reply
#7

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.
Reply
#8

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.
Reply
#9

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.
Reply
#10

Something that could help me here?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)