Advertisement
mau_tito

MessageOff

Sep 15th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. /* ** Mensage Off **
  2.  
  3. Criador : Maurício Moraes
  4. */
  5. #include a_samp
  6. #include a_mysql
  7. #include zcmd
  8. #include sscanf2
  9. #define DIALOG_MESSAGE (150)
  10. new Connect, NamePlayer[MAX_PLAYERS][MAX_PLAYER_NAME char], var[100];
  11.  
  12. public OnGameModeInit()
  13. {
  14. Connect = mysql_connect("localhost", "root", "tabela", "senha");
  15. if(!mysql_ping(Connect))
  16. {
  17. SendRconCommand("Exit");
  18. }
  19. return true;
  20. }
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24. GetPlayerName(playerid, NamePlayer[playerid], 80);
  25. format(var, 100, "SELECT * FROM `tabela` WHERE `nome` = '",NamePlayer[playerid],"'");
  26. mysql_function_query(Connect, var, false, #,#);
  27. new row, field;
  28. cache_get_data(row, field, Connect);
  29. if(row)
  30. {
  31. // nome 'Quem recebe' | Mandate 'Quem manda' | texto 'A mensagem'
  32. new Mandante[80], texto[300], Msg[400], tito[400];
  33. cache_get_field_content(0, "Mandate", Mandante);
  34. cache_get_field_content(0, "texto", texto);
  35. format(Msg, 100, "\n\nMessageOff de %s\n\n\n\n\n%s",texto);
  36. strcat(tito,Msg);
  37. ShowPlayerDialog(playerid, DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "MenssageOff", tito, "Ok", #);
  38. DeletarMensagem(playerid, Mandante, texto);
  39. }
  40. else
  41. {
  42. SendClientMessage(playerid, -1 , "MessageOff : Você não possui mensagens off !");
  43. }
  44. return true;
  45. }
  46.  
  47. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  48. {
  49. if(dialogid == DIALOG_MESSAGE)
  50. {
  51. format(var, 100, "SELECT * FROM `tabela` WHERE `nome` = '",NamePlayer[playerid],"'");
  52. mysql_function_query(Connect, var, false, #,#);
  53. new row, field;
  54. cache_get_data(row, field, Connect);
  55. if(row)
  56. {
  57. // nome 'Quem recebe' | Mandate 'Quem manda' | texto 'A mensagem'
  58. new Mandante[80], texto[300], Msg[400], tito[400];
  59. cache_get_field_content(0, "Mandate", Mandante);
  60. cache_get_field_content(0, "texto", texto);
  61. format(Msg, 100, "\n\nMessageOff de %s\n\n\n\n\n%s",texto);
  62. strcat(tito,Msg);
  63. ShowPlayerDialog(playerid, DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "MenssageOff", tito, "Ok", #);
  64. DeletarMensagem(playerid, Mandante, texto);
  65. }
  66. }
  67. return 1;
  68. }
  69.  
  70. forward DeletarMensagem(playerid, Mandante[], texto[]);
  71. public DeletarMensagem(playerid, Mandante[], texto[])
  72. {
  73. format(var, 100, "DELET * FROM `tabela` WHERE `nome`='%s' AND `Mandate`='%s' AND `texto`='%s'",NamePlayer[playerid], Mandante, texto);
  74. mysql_function_query(Connect, var, false, #, #);
  75. return 1;
  76. }
  77.  
  78. command(mandamsg, playerid, params[])
  79. {
  80. new conta[80],msg[400];
  81. if(sscanf(params , "s[80]s[400]",conta, msg))return SendClientMessage(playerid, -1, " : /mandarmsg [conta] [msg]");
  82. format(var, 100, "INSERT INTO `tabela` (`nome`,`Mandate`, `texto`) VALUES ( '%s', '%s', '%s')", conta,NamePlayer[playerid],msg);
  83. mysql_function_query(Connect, var , false, #, #);
  84. SendClientMessage(playerid, -1, "MessageOff : Enviado com sucesso!");
  85. return true;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement