13.11.2016, 06:04
Instead of relying on the client's response, you should try and keep everything server-sided if possible.
For example:
And I repeat, that is purely an example. You should make something that fits your own needs.
For example:
PHP Code:
#define DIALOG_TEST 1
#define MAX_LIST_ITEMS 25 // The maximum amount of list items
#define MAX_LIST_ITEM_TEXT 60 // The maximum length a list item text can be
new
ListItem[MAX_PLAYERS][MAX_LIST_ITEMS][MAX_LIST_ITEM_TEXT],
Player_ListItem[MAX_PLAYERS] = {0, ...}
;
#define AddListItem(%0,%1) format(ListItem[(%0)][Player_ListItem[(%0)]++], sizeof(ListItem[][]), (%1))
#define ClearListItems(%0); for(new litem = 0; litem != sizeof(ListItem[]); litem++) ListItem[(%0)][litem][0] = EOS; Player_ListItem[(%0)] = 0;
public OnPlayerSpawn(playerid)
{
AddListItem(playerid, "1. Briefcase");
AddListItem(playerid, "2. Torn Letter");
AddListItem(playerid, "3. Cyanide Pills");
AddListItem(playerid, "4. Toolbox");
ShowListDialog(playerid, DIALOG_TEST, .caption = "Items List");
return 1;
}
ShowListDialog(playerid, dialogid, caption[] = "Dialog")
{
new dialog_str[MAX_LIST_ITEMS * MAX_LIST_ITEM_TEXT];
for(new i = 0; i < sizeof(ListItem[]); i++)
{
if(ListItem[playerid][i][0] == EOS) break;
format(dialog_str, sizeof(dialog_str), "%s\n%s", dialog_str, ListItem[playerid][i]);
}
return ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, caption, dialog_str, "Select", "Exit");
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
{
switch(dialogid)
{
case DIALOG_TEST:
{
printf("%s | %s", inputtext, ListItem[playerid][listitem]);
if(strcmp(inputtext, ListItem[playerid][listitem], true) != 0)
{
// inputtext does not match the list item text they selected
//Kick(playerid);
return 0;
}
ClearListItems(playerid); // Reset the player's list items text
return 1;
}
}
}
return 0;
}