How to mysql text -
TheNerka - 26.09.2014
Hello how to script in mysql text? show in SendClientMessageToAll
example in mysql got PlayerName, Text, Date
random text show too. Mysql R38
ps: chat
Re: How to mysql text -
dusk - 26.09.2014
If I understand you correctly, you want to send messages to all players which are stored in your mysql database?
I'll assume your table structure is similiar to this:
Код:
CREATE TABLE IF NOT EXIST messages (
Id INT(11) AUTO_INCREMENT NOT NULL,
PlayerName VARCHAR(24) NOT NULL,
Text VARCHAR(128) NOT NULL,
Date INT(11) NOT NULL,
PRIMARY KEY(Id)
);
pawn Код:
// Somewhere where you want to send it
mysql_pquery(connection_handler, SELECT PlayerName,Text,(FROM_UNIXTIME(Date) AS Time) FROM messages ORDER BY RAND() LIMIT 1,"OnRandomMessageLoad","");
forward OnRandomMessageLoad();
public OnRandomMessageLoad()
{
new name[MAX_PLAYER_NAME],date[32],string[200],;
cache_get_field_content(0, "PlayerName", name);
cache_get_field_content(0, "Time", date);
cache_get_field_content(0, "Text", string);
format(string,sizeof(string),"[%s]%s said:%s ", date, name, string);
SendClientMessageToAll(0xFF0000FF, string);
}
Not that code should work...
Not that I made "Date" an integer, you should store a timestamp. You can get it with gettime() function.
Also, if you will be sending these messages frequently you might want to load them all into memory.
Re: How to mysql text -
TheNerka - 26.09.2014
no, i want if im chating in server, save to mysql and load to website
example im say /s hello (admin command sendclientmessagetoall)
this hello save to mysql and load to website
Re: How to mysql text -
Ox1gEN - 26.09.2014
Well, for that you need to create a table called logs and then just format a message and insert everything in there.
If I were you I wouldn't do it but instead write it into an ini file, because why over-writing stuff into mysql like chat-logs?
Re: How to mysql text -
TheNerka - 26.09.2014
or show only ads,
Код:
CMD:y(playerid,params[])
{
if(!strlen(params)) return SendClientMessage(playerid, COLOR_ORANGE, "[USE] /y [text]");
new zin[256],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(zin,sizeof(zin),"{FFF380}[ADS] %s {FFFF00}%s",name,params);
SendClientMessageToAll(0x00D900AA,zin);//green
return 1;
}
how to save in mysql?
in mysql Sendername, Text, date.
mysql r38