KrisnaPradnya

ChatSAMP

Jun 4th, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.30 KB | None | 0 0
  1. #define         function%0(%1)      forward%0(%1);public%0(%1)
  2.  
  3. SetTimer("CheckforMessages_Console",10000,true); //Put this timer on OnGameModeInIt();
  4.  
  5. function InsertText_Console(text[]) //You will use this function for the application chat. Example: In OnPlayerText(); or in a command like /n(ewbie) ...
  6. {
  7.     mysql_real_escape_string(text,szString,g_Handle,256);
  8.     format(szQueryInput,sizeof(szQueryInput), "INSERT INTO `chat_log` (Text) VALUES ('%s')", szString);
  9.     mysql_function_query(g_Handle, szQueryInput, false, "", "");
  10.     return 1;
  11. }
  12. function CheckforMessages_Console()
  13. {
  14.     format(string, sizeof(string), "SELECT * FROM `chat_log` WHERE `Status` = 1");
  15.     mysql_function_query(g_Handle, string, true, "CheckMessage", "");
  16.     return 1;
  17. }
  18. function CheckMessage() //This function will show on server, messages who was sent from console.
  19. {
  20.     new rows,fields,temp[128],Message[200];
  21.     cache_get_data(rows,fields);
  22.     if(rows) {
  23.         cache_get_row(0, 1, temp), format(Message,sizeof(temp),temp);
  24.         printf("%s",Message); //You can hide this.
  25.         SendClientMessageToAll(COLOR_WARNING,Message); //You can show the Message in another form.
  26.         mysql_format(g_Handle,string,sizeof(string),"UPDATE `chat_log` SET `Status` = 0 WHERE `Text`= '%s'",Message);
  27.         mysql_function_query(g_Handle,string,false,"","");
  28.     }
  29.     return 1;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment