21.09.2014, 17:52
SAMP Live Chat
IntroductionWith this program you can send a message to your server, and everyone who are online will see the message.
How it works:
Below i'll post a PAWN Code for your server. This will include few lines: SELECT/UPDATE/INSERT functions, an timer(who will check the table every time after 10 seconds), 3 functions and two global strings.
What you must to know:
Now 4-5 days, i posted this program, but after 2-3 hours the topic was deleted for unknown reason. I guess the reason was "with this program he stole database information from users", so, now i will post source code only, and with that, you can check what you want.
Without the PAWN Code in your server, this will never work fine.
PAWN Code is created with last MySQL version. You can downgrade all mysql query to your version with no problem.
When you connect this program to a database, will automatically create table `chat_log`, don't create manually the table!
Screenshots:


PAWN Code:
pawn Code:
new szQueryInput[512]; // If you want to save memory.
new szString[230];
SetTimer("CheckforMessages_Console",10000,true); //Put this timer on OnGameModeInIt();
function InsertText_Console(text[]) //You will use this function for the application chat. Example: In OnPlayerText(); or in a command like /n(ewbie) ...
{
mysql_real_escape_string(text,szString,g_Handle,256);
format(szQueryInput,sizeof(szQueryInput), "INSERT INTO `chat_log` (Text) VALUES ('%s')", szString);
mysql_function_query(g_Handle, szQueryInput, false, "", "");
return 1;
}
function CheckforMessages_Console()
{
format(string, sizeof(string), "SELECT * FROM `chat_log` WHERE `Status` = 1");
mysql_function_query(g_Handle, string, true, "CheckMessage", "");
return 1;
}
function CheckMessage() //This function will show on server, messages who was sent from console.
{
new rows,fields,temp[128],Message[200];
cache_get_data(rows,fields);
if(rows) {
cache_get_row(0, 1, temp), format(Message,sizeof(temp),temp);
printf("%s",Message); //You can hide this.
SendClientMessageToAll(COLOR_WARNING,Message); //You can show the Message in another form.
mysql_format(g_Handle,string,sizeof(string),"UPDATE `chat_log` SET `Status` = 0 WHERE `Text`= '%s'",Message);
mysql_function_query(g_Handle,string,false,"","");
}
return 1;
}
pawn Code:
#define function%0(%1) forward%0(%1);public%0(%1)
#1 Direct Link. Password is: sampchatsource .
#VirusTotal Result: Click here.
# If this topic will be deleted again, can the moderator send the reason via PM? Because i created one message to all staff, and one to a moderator who was online, and no-one responds.
# If you find problems about this program, leave a message here!
# I'm waiting your opinion/question!