21.07.2017, 06:05
Una manera es utilizando una pvar, otra forma seria utilizando inputtext en ondialogresponse ya que inputtext en un dialogo tipo LIST devuelve el texto seleccionado
PHP код:
new ids[256]; //Creamos un array para almacenar las ids
new string[800], fullstr[800];
format(string,sizeof(string), "{FFFFFF}Categoria\n");
strcat(fullstr, string);
new bool:detectarcrepetida = true;
for (new x = 0; x < sizeof(Datamuebles); x++)
{
for (new xx = 0; xx < x; xx++)
{
if (strfind(Datamuebles[x][dmCategoria], Datamuebles[xx][dmCategoria]) == 0)
{
detectarcrepetida = false;
break;
}
}
if (detectarcrepetida == false)
{
detectarcrepetida = true;
continue;
}
format(ids,sizeof(ids),"%s%d ",ids,x); //Almacenamos las ids
format(string, sizeof(string), "%s:%d\n",Datamuebles[x][dmCategoria],x);
strcat(fullstr, string);
}
SetPVarString(playerid,"CATEGORIA_IDS",ids); //Las guardamos en una Pvar
ShowPlayerDialog(playerid, DIALOGO_MOBILIARIO_CATEGORIA, DIALOG_STYLE_TABLIST_HEADERS, "{979A38}Categorias - Mobiliario", fullstr, "Seleccionar", "Cancelar");
//Donde cargas los datos
new ids_string[256],ids[100];
GetPVarString(playerid,"CATEGORIA_IDS",ids_string,sizeof ids_string); //Recuperamos los datos de la pvar
sscanf(ids_string,"a<i>[100]",ids); //con sscanf recuperamos los datos en un array
printf("Categoria seleccionada: %d",ids[listitem]);