15.03.2019, 09:01
Hi guys, I have wrote this code, yesterday, and I think work, but I noticed only a problem
If u can take a look to the code, I saw when you select the player that you wan't unbann, after the dialog: "BANLIST",
the code will get you the dialog "SEL_BANNED_PLAYER" at MSGBOX, but if you response or not the code don't do nothing, how can i fix that?
I prefer a msgbox at style_list, for aesthetic and I think is more simple (maybe)
If u can take a look to the code, I saw when you select the player that you wan't unbann, after the dialog: "BANLIST",
the code will get you the dialog "SEL_BANNED_PLAYER" at MSGBOX, but if you response or not the code don't do nothing, how can i fix that?
I prefer a msgbox at style_list, for aesthetic and I think is more simple (maybe)
pawn Код:
enum lista
{
username[128],
admin[128],
data[64],
Motivo[128],
ip[32]
};
new Banlist[MAX_PLAYERS][lista];
CMD:banlist(playerid, params[])
{
new string[128], string2[128];
new Cache:result = mysql_query(g_SQL,"SELECT * FROM `bans` WHERE `id` > -1");
if(!cache_num_rows())
{
cache_delete(result);
SendClientMessage(playerid, 0xFF0000FF,"[ERRORE]: Nessun utente и stato bannato");
return 1;
}
for(new i,j = cache_num_rows(); i< j; i++)
{
cache_get_value_name(i,"username", Banlist[i][username], 128);
cache_get_value_name(i,"bannedby", Banlist[i][admin], 128);
cache_get_value_name(i,"banreason", Banlist[i][Motivo], 128);
cache_get_value_name(i,"date", Banlist[i][data], 64);
cache_get_value_name(i,"ip", Banlist[i][ip], 32);
format(string, sizeof(string), "%s%d\t%s\n", string, i, Banlist[i][username]);
}
format(string2, sizeof(string2), "Selezione\tNome player\n%s", string);
Dialog_Show(playerid, BANLIST, DIALOG_STYLE_TABLIST_HEADERS, "Lista utenti bannati", string2, "Seleziona", "Annulla");
cache_delete(result);
return 1;
}
Dialog:BANLIST(playerid, response, listitem, inputtext[])
{
if(response)
{
new str[512];
format(str, sizeof(str),
"{FFFF00}Il player и stato bannato\n\
{D93D3D}Vuoi sbannare il player selezionato?\n\
{D93D3D}IP: {FFFFFF}%s\n\
{D93D3D}Username: {FFFFFF}%s\n\
{D93D3D}Ban dato da: {FFFFFF}%s\n\
{D93D3D}Motivo: {FFFFFF}%s\n\
{D93D3D}Data: {FFFFFF}%s",
Banlist[listitem][ip], Banlist[listitem][username], Banlist[listitem][admin], Banlist[listitem][Motivo], Banlist[listitem][data]);
Dialog_Show(playerid, SEL_BANNED_PLAYER, DIALOG_STYLE_MSGBOX, "Info sul ban", str, "Si", "No");
return 1;
}
return 1;
}
Dialog:SEL_BANNED_PLAYER(playerid, response, listitem, inputtext[])
{
if(response)
{
UnbannSelectedPlayer(Banlist[listitem][username]);
new str[256];
format(str, sizeof(str), "{FFFF00}Hai appena sbannato %s.", Banlist[listitem][username]);
Dialog_Show(playerid, DIALOG_INFO_SSBAN, DIALOG_STYLE_MSGBOX, "Utente sbannato con successo", str, "Ok", "");
return 1;
}
else if(!response)
{
new str[256];
format(str, sizeof(str), "{D93D3D}[BAN]: L'utente %s\nRimarrа bannato", Banlist[listitem][username]);
Dialog_Show(playerid, DIALOG_INFO_SSBAN, DIALOG_STYLE_MSGBOX, "Utenti bannati", str, "Ok", "");
return 1;
}
return 1;
}
stock UnbannSelectedPlayer(playername)
{
new query[256];
mysql_format(g_SQL, query, sizeof(query), "DELETE * FROM `bans` WHERE `username` = '%s'",
playername ); //Banlist[listitem][username]
mysql_tquery(g_SQL, query);
return 1;
}