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.