Dialog problems -
HidroDF - 31.08.2016
Hello, I'm creating a Vehicle System. I have a command that shows (in a dialog) all the cars the user owns.
But I'm having troubles. I can't detect which car is selecting the user, because onDialogResponse uses listitem. And the CarID is not the same as listitem.
Код:
CMD:vehs(playerid, params[])
{
new string[240];
new stats[30];
for(new i=1;i<MAX_VEHICLES;i++)
{
if(strmatch(VehicleSystem[i][Owner],PlayerName(playerid)))
{
if (VehicleSystem[i][Stats] == 0)
{
stats = "Spawned";
}
else if (VehicleSystem[i][Stats] == 1)
{
stats = "Saved";
}
GetVehicleName(i);
format(string,sizeof(string), "%s%s (%d) - %s - %s\n", string, VehicleSystem[i][Name],VehicleSystem[i][CarID],VehicleSystem[i][Plate], stats);
}
}
ShowPlayerDialog(playerid, DIALOG_CARS, DIALOG_STYLE_LIST, "{FFFFFF}Mis coches", string, "Change", "Exit");
return 1;
}
This shows the dialog list type. Then:
Код:
if (dialogid == DIALOG_CARS)
{
if(response)
{
new sel[300];
format(sel,sizeof(sel),"{FFFFFF}You have selected the CARID: {40D3FF}%d.", what_i_can_do_here?);
ShowPlayerDialog(playerid, DIALOG_ALERT, DIALOG_STYLE_MSGBOX, "Message", sel, "", "Continue");
SaveStateCar(carid);
}
}
Thanks!
Re: Dialog problems -
Kaliber - 31.08.2016
In the string "inputtext" is the string he clicked to.
So if there is "Infernus (0) - bla - bla"
You need this number in brackets...so write a string splitter to get the id:
So you do this:
PHP код:
if (dialogid == DIALOG_CARS)
{
if(response)
{
new sel[300],tmp[5],id;
strmid(tmp,inputtext,strfind(inputtext,"(")+1,strfind(inputtext,")"),sizeof(tmp));
id = strval(tmp);
format(sel,sizeof(sel),"{FFFFFF}You have selected the CARID: {40D3FF}%d.",id);
ShowPlayerDialog(playerid, DIALOG_ALERT, DIALOG_STYLE_MSGBOX, "Message", sel, "", "Continue");
SaveStateCar(carid);
}
}
Greekz
Respuesta: Dialog problems -
HidroDF - 31.08.2016
Thanks, I've solved the problem using another way. I'll show you how I've solved it:
Код:
new ListSelection[MAX_PLAYERS][MAX_VEHICLES];
if (dialogid == DIALOG_CARS)
{
if(response)
{
new sel[300];
format(sel,sizeof(sel),"{FFFFFF}You have selected: {40D3FF}%d.", ListaSeleccion[playerid][listitem]);
ShowPlayerDialog(playerid, DIALOG_ALERT, DIALOG_STYLE_MSGBOX, "Message", sel, "Exit", "");
}
}
// On command /vehicles:
format(string,sizeof(string), "%s%s (%d) - %s - %s\n", string, VehicleSystem[i][Name],VehicleSystem[i][CarID],VehicleSystem[i][Matricula], stats);
for(new e=0;e<5;e++)
{
ListSelection[playerid][e] = VehicleSystem[i][CarID];
}
Re: Dialog problems -
Kaliber - 31.08.2016
Your Way is much worser...
Dude..look at this space wasting:
PHP код:
new ListSelection[MAX_PLAYERS][MAX_VEHICLES];
This means in worst case: 500*2000*4 = 4.000.000 Bytes = 3.906,25 KBytes = 3,9MB
Just for that...omfg its just wasted >.<
If you use my method you have 0 Bytes