PDA

View Full Version : Dialog Cmd problem


NitroZeth
07/08/2017, 07:24 AM
Hello all , i get this error in my command Banlist
CMD:banlist(playerid, params[])
{
if(PlayerInfo[playerid][Level] >= 4)
{
new ID, Query[256],string[135], DBResult: result;
format(Query, sizeof(Query), "SELECT * FROM BANNED");
result = db_query(bans, Query);
ID = db_num_rows(result);
db_free_result(result);
format(string, sizeof(string), "%s\t Ban List\n\n{FC4949}Banned Accounts:{FFFFFF} %d\n{FC4949}Permanent Bans: {FFFFFF}%d\n", string,ID,ID);
ShowPlayerDialog( playerid, DIALOG_BANLIST, DIALOG_STYLE_INPUT, "Ban List",string, "Search", "Close" );
CMDMessageToAdmins(playerid,"BANLIST");
string = "\0", Query = "\0";
}
return 1;
}
The Dialog close when i put a name in the Cmd

Kane
07/08/2017, 07:26 AM
format(Query, sizeof(Query), "SELECT * FROM BANNED");
result = db_query(bans, Query);


There's no reason to use format if you're not actually formatting anything.

And what's the error?

BrnX
07/08/2017, 07:28 AM
(( test message,sorry

NitroZeth
07/08/2017, 07:30 AM
When I put the name of a player, the command is closed, rather it closes the window of the command you understand?

Kane
07/08/2017, 07:39 AM
http://wiki.sa-mp.com/wiki/OnDialogResponse

You need to define DIALOG_BANLIST and make it do something in there.

I get what you're trying to do but I think it's not going to work. Here's an ideal way of doing it:


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_BANLIST)
{
if (response)
{
if(strlen(inputtext) < 3) return SendClientMessage(playerid, -1, "You specified an invalid account name.");

new
query[128], string[128], DBResult: result;

format (query, sizeof(query), "SELECT * FROM BANNED Where Name = '%e'", inputtext);
result = db_query(bans, query);
}
}
}


Et cetera, et cetera. Grab the data and store it in a string and show it if the ban exists.

NitroZeth
07/08/2017, 12:07 PM
When i put that code
Pawno stops working xd