Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ** Mensage Off **
- Criador : Maurício Moraes
- */
- #include a_samp
- #include a_mysql
- #include zcmd
- #include sscanf2
- #define DIALOG_MESSAGE (150)
- new Connect, NamePlayer[MAX_PLAYERS][MAX_PLAYER_NAME char], var[100];
- public OnGameModeInit()
- {
- Connect = mysql_connect("localhost", "root", "tabela", "senha");
- if(!mysql_ping(Connect))
- {
- SendRconCommand("Exit");
- }
- return true;
- }
- public OnPlayerConnect(playerid)
- {
- GetPlayerName(playerid, NamePlayer[playerid], 80);
- format(var, 100, "SELECT * FROM `tabela` WHERE `nome` = '",NamePlayer[playerid],"'");
- mysql_function_query(Connect, var, false, #,#);
- new row, field;
- cache_get_data(row, field, Connect);
- if(row)
- {
- // nome 'Quem recebe' | Mandate 'Quem manda' | texto 'A mensagem'
- new Mandante[80], texto[300], Msg[400], tito[400];
- cache_get_field_content(0, "Mandate", Mandante);
- cache_get_field_content(0, "texto", texto);
- format(Msg, 100, "\n\nMessageOff de %s\n\n\n\n\n%s",texto);
- strcat(tito,Msg);
- ShowPlayerDialog(playerid, DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "MenssageOff", tito, "Ok", #);
- DeletarMensagem(playerid, Mandante, texto);
- }
- else
- {
- SendClientMessage(playerid, -1 , "MessageOff : Você não possui mensagens off !");
- }
- return true;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_MESSAGE)
- {
- format(var, 100, "SELECT * FROM `tabela` WHERE `nome` = '",NamePlayer[playerid],"'");
- mysql_function_query(Connect, var, false, #,#);
- new row, field;
- cache_get_data(row, field, Connect);
- if(row)
- {
- // nome 'Quem recebe' | Mandate 'Quem manda' | texto 'A mensagem'
- new Mandante[80], texto[300], Msg[400], tito[400];
- cache_get_field_content(0, "Mandate", Mandante);
- cache_get_field_content(0, "texto", texto);
- format(Msg, 100, "\n\nMessageOff de %s\n\n\n\n\n%s",texto);
- strcat(tito,Msg);
- ShowPlayerDialog(playerid, DIALOG_MESSAGE, DIALOG_STYLE_MSGBOX, "MenssageOff", tito, "Ok", #);
- DeletarMensagem(playerid, Mandante, texto);
- }
- }
- return 1;
- }
- forward DeletarMensagem(playerid, Mandante[], texto[]);
- public DeletarMensagem(playerid, Mandante[], texto[])
- {
- format(var, 100, "DELET * FROM `tabela` WHERE `nome`='%s' AND `Mandate`='%s' AND `texto`='%s'",NamePlayer[playerid], Mandante, texto);
- mysql_function_query(Connect, var, false, #, #);
- return 1;
- }
- command(mandamsg, playerid, params[])
- {
- new conta[80],msg[400];
- if(sscanf(params , "s[80]s[400]",conta, msg))return SendClientMessage(playerid, -1, " : /mandarmsg [conta] [msg]");
- format(var, 100, "INSERT INTO `tabela` (`nome`,`Mandate`, `texto`) VALUES ( '%s', '%s', '%s')", conta,NamePlayer[playerid],msg);
- mysql_function_query(Connect, var , false, #, #);
- SendClientMessage(playerid, -1, "MessageOff : Enviado com sucesso!");
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement