How can i get that?
#1

I made a dialog which will show the vehicle keys player has,but i don't know how can i get that which vehicle id the player has clicked.i mean how will i check the vehicle id that a list item is containing on the response of dialog id 559
Код:
Here is the gamemode on which im working: https://sampforum.blast.hk/showthread.php?tid=423627
Код:
	if(dialogid == 558)
	{
		if(response)
		{
			new str[250], str2[250];
			for(new i = 0; i < MAX_RP_VEHICLES; i++)
			{
				if(VehicleInfo[i][KeyHolder] == CharacterInfo[playerid][active_character[playerid]][cID])
				{
					format(str2, sizeof(str2), "%s (%d)\n", VehicleInfo[i][vModel], VehicleInfo[i][vID]);
					strcat(str, str2);
				}
			}
			ShowPlayerDialog(playerid, 559, DIALOG_STYLE_LIST, ""COL_GREEN"JRP - Vehicle Keys", str, "Select", "");
		}
	}
Reply
#2

Hi!

I hope it's this what you want.
PHP код:
if(dialogid == 559)
{
    if(
response)
    {
        new 
count;
        for(new 
i;i<MAX_RP_VEHICLES;i++)
        {
            if(
listitem == count)
            {
                
//count = listitem <=> listitem = count
                //You can work either with count or listitem.
                
return 1;
            }
            
count ++;
        }
    }

Reply
#3

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hi!

I hope it's this what you want.
PHP код:
if(dialogid == 559)
{
    if(
response)
    {
        new 
count;
        for(new 
i;i<MAX_RP_VEHICLES;i++)
        {
            if(
listitem == count)
            {
                
//count = listitem <=> listitem = count
                //You can work either with count or listitem.
                
return 1;
            }
            
count ++;
        }
    }

Thanks but its not what im saying
Reply
#4

You would like to get the vehicle id, wouldn't you? Then you have to do it like this:
PHP код:
if(dialogid == 559)
{
    if(
response)
    {
        new 
count;
        for(new 
i;i<MAX_RP_VEHICLES;i++)
        {
            if(
listitem == count)
            {
                
printf("playerid %d clicked on the vehicle id %i",playerid,VehicleInfo[listitem][vID]);
                
//count = listitem <=> listitem = count
                //You can work either with count or listitem.
                
return 1;
            }
            
count ++;
        }
    }

Reply
#5

Quote:
Originally Posted by Mencent
Посмотреть сообщение
You would like to get the vehicle id, wouldn't you? Then you have to do it like this:
PHP код:
if(dialogid == 559)
{
    if(
response)
    {
        new 
count;
        for(new 
i;i<MAX_RP_VEHICLES;i++)
        {
            if(
listitem == count)
            {
                
printf("playerid %d clicked on the vehicle id %i",playerid,VehicleInfo[listitem][vID]);
                
//count = listitem <=> listitem = count
                //You can work either with count or listitem.
                
return 1;
            }
            
count ++;
        }
    }

It will return this by clicking listitem 1:
Код:
VehicleInfo[0][vID]
But i want it to return real car id
Reply
#6

Well, then you can take i.

PHP код:
if(dialogid == 559)
{
    if(
response)
    {
        new 
count;
        for(new 
i;i<MAX_RP_VEHICLES;i++)
        {
            if(
listitem == count)
            {
                
printf("playerid %d clicked on the vehicle id %i",playerid,i);
                
//count = listitem <=> listitem = count
                //You can work either with count or listitem.
                
return 1;
            }
            
count ++;
        }
    }

Reply
#7

Actually vID of each vehicle is loaded from mysql database,it can even be > 1000

Код:
mysql_fetch_field_row(b,"id");
VehicleInfo[i][vID] = strval(b);
Reply
#8

pawn Код:
if(dialogid == 559)
{
    if(response)
    {
        new count;
        for(new i = 0; i < MAX_RP_VEHICLES; i++)
        {
            if(VehicleInfo[i][KeyHolder] == CharacterInfo[playerid][active_character[playerid]][cID])
            {
                if(listitem == count)
                {
                    //VehicleInfo[i][vID] is your vehicleid...
                    printf("Player %d clicked on the vehicle id %i",playerid, VehicleInfo[i][vID]);
                   
                    return 1;
                }
                count++;
            }
        }
    }
}
Reply
#9

Code under OnDialogResponse:
PHP код:
    if(dialogid == 558)
    {
        if(
response)
        {
            new 
str[250], str2[250], count;
            for(new 
0MAX_RP_VEHICLESi++)
            {
                
count++;
                if(
VehicleInfo[i][KeyHolder] == CharacterInfo[playerid][active_character[playerid]][cID])
                {
                    
format(str2sizeof(str2), "%s (%d)\n"VehicleInfo[i][vModel], VehicleInfo[i][vID]);
                    
strcat(strstr2);
                }
            }
            
ShowPlayerDialog(playerid559DIALOG_STYLE_LIST""COL_GREEN"JRP - Vehicle Keys"str"Select""");
        }
    }
    if(
dialogid == 559)
    {
        if(
response)
        {
        }
    } 

Note: Im not showing all the vehicles,im showing the vehicles which the player owns.
Reply
#10

Did you even tested code i posted above?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)