Small question about dialog listitem variable.
#1

Hello guys i have a little question about listitem in Dialogs.

I wanna show my owned cars in a dialog list to manage it (change colors etc..) it shows fine in a list
but how i can pass a variable to detect the vehicleid selected on the dialog when i reach OnDialogResponse?

This is the command that i made to show my cars in a list.

PHP Code:
CMD:misvehiculos(playeridparam[])
{
    if(!
GetPlayerVehiclesCount(playerid)) return Message(playeridCOLOR_MSG_AVISOS"No tienes vehнculos.");
    new 
sEncontrar[64];
    for(new 
0MAX_VEHICLESi++)
    {
        if(
cInfo[i][ownerID] == pInfo[playerid][pID])
        {
            
format(sEncontrarsizeof(sEncontrar), "%s [M: %d] "VehicleNames[cInfo[i][model]-400], cInfo[i][matricula]);
          
        }
    }
    
ShowPlayerDialog(playerid515DIALOG_STYLE_LIST"GPS de Vehнculos"sEncontrar"Aceptar""Cancelar");
    return 
1;

Thanks in advance.
All help will be rep!
Reply
#2

Use pVars.

Use SetPVarInt to store selected vehicleid, then GetPVarInt to retrieve it.

After you made everything, just delete it with DeletePVar.
Reply
#3

Quote:
Originally Posted by SymonClash
View Post
Use pVars.

Use SetPVarInt to store selected vehicleid, then GetPVarInt to retrieve it.

After you made everything, just delete it with DeletePVar.
Thanks for you reply, but how i can do it? for example what happen if i have more than 1 car and i select the second one, how i can store it? im really confused.
Reply
#4

DynamicGui Include, very usefull thing - https://pastebin.com/fPgZvzqb

Code:
CMD:misvehiculos(playerid, param[]) 
{ 
    if(!GetPlayerVehiclesCount(playerid)) return Message(playerid, COLOR_MSG_AVISOS, "No tienes vehнculos."); 
    DynamicGui_Init(playerid);

    new sEncontrar[64]; 
    for(new i = 0; i < MAX_VEHICLES; i++) 
    { 
        if(cInfo[i][ownerID] == pInfo[playerid][pID]) 
        { 
            DynamicGui_AddRow(playerid, i);	
            format(sEncontrar, sizeof(sEncontrar), "%s [M: %d] ", VehicleNames[cInfo[i][model]-400], cInfo[i][matricula]); 
           
        } 
    } 

    ShowPlayerDialog(playerid, 515, DIALOG_STYLE_LIST, "GPS de Vehнculos", sEncontrar, "Aceptar", "Cancelar"); 
    return 1; 
}
Now you can get it inside ondialogresponse, example:

Code:
new vehicleid = DynamicGui_GetValue(playerid, listitem)
Reply
#5

Quote:
Originally Posted by raydx
View Post
DynamicGui Include, very usefull thing - https://pastebin.com/fPgZvzqb

Code:
CMD:misvehiculos(playerid, param[]) 
{ 
    if(!GetPlayerVehiclesCount(playerid)) return Message(playerid, COLOR_MSG_AVISOS, "No tienes vehнculos."); 
    DynamicGui_Init(playerid);

    new sEncontrar[64]; 
    for(new i = 0; i < MAX_VEHICLES; i++) 
    { 
        if(cInfo[i][ownerID] == pInfo[playerid][pID]) 
        { 
            DynamicGui_AddRow(playerid, i);	
            format(sEncontrar, sizeof(sEncontrar), "%s [M: %d] ", VehicleNames[cInfo[i][model]-400], cInfo[i][matricula]); 
           
        } 
    } 

    ShowPlayerDialog(playerid, 515, DIALOG_STYLE_LIST, "GPS de Vehнculos", sEncontrar, "Aceptar", "Cancelar"); 
    return 1; 
}
Now you can get it inside ondialogresponse, example:

Code:
new vehicleid = DynamicGui_GetValue(playerid, listitem)
Ill test it! thanks for the reply.
Reply
#6

Not work bro im getting problems with that include alot mismatch arguments.
Reply
#7

I find the solution, this topic can be closed, thanks all for the help all be repped!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)