List dialog item
#1

I have a dealership command and instead of showing Tahoma in the list it is shown as {.

This is the piece of code for that list
Код:
			if(listitem == 0)
			{
				new stringzz[10000],stringy[10000];
				for(new xf = 0; xf < MAX_PERSONAL_CARS; xf++)
				{
					if(Stock[xf][vType] == 1)
					{
						format(stringy, sizeof(stringy), "{ffffff}%s ( %d{33cc33}${ffffff} ) ( {00FFFF}%d {ffffff}cars in stock)\n", Stock[xf][vName], Stock[xf][vPrice], Stock[xf][vStock]);
						strcat(stringzz,stringy);
					}
				}
				ShowPlayerDialog(playerid, DIALOG_CARBUY2, DIALOG_STYLE_LIST, "Buy a car", stringzz, "Select", "Close");
			}
And this is a screenshot of the problem


Does anyone know what the problem is ?
Reply
#2

Код:
new stringzz[10000],stringy[10000];
Is a big no!!! There are limits to the size.

https://sampwiki.blast.hk/wiki/Limits
Reply
#3

new stringzz[10000],stringy[10000]; is not good!
Reply
#4

Show "DIALOG_CARBUY2"
Reply
#5

Quote:
Originally Posted by Bolex_
Посмотреть сообщение
Show "DIALOG_CARBUY2"
Код:
	if(dialogid == DIALOG_CARBUY2)
	{
		if(response)
		{
			new num = listitem + 1;
			BuyCar[playerid] = num;
			if(GetPlayerCash(playerid) >= Stock[num][vPrice])
			{
				if(Stock[num][vStock] > 0)
				{
					InsertCar(playerid,1,num);
				}
				else
				{
					new stringg[MAX_STRING];
					format(stringg,sizeof(stringg),"Aceasta masina nu mai este disponibila in Dealership. Stoc epuizat.\nYou can't buy this vehicle from the dealership. Out of stock.");
					ShowPlayerDialog(playerid, DIALOG_NOSTOCK, DIALOG_STYLE_MSGBOX, "Out of stock", stringg, "Close","");
				}
			}
			else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to purchase this vehicle.");
			
		}
		return 1;
	}
Reply
#6

DIALOG_CARBUY2 is not relevant.

Your issue is with your string size. You're out of space.
Reply
#7

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
DIALOG_CARBUY2 is not relevant.

Your issue is with your string size. You're out of space.
i am already over the limit by a lot, how can i make it so i don't hit the string limit but i still can show all the info ?
Reply
#8

A limit is a limit. Your size isn't actually 10,000. You could probably prevent this from happening by losing the colors but if you don't want to there's another method I think could work for you.

What could you do is split the info onto 2 separate dialogs.

Here's an example:

PHP код:
#define MAX_PAGE_SHOW 30
new PlayerCarBuyPage[MAX_PLAYERS];
new 
CarBuySelector[MAX_PLAYERS][MAX_PAGE_SHOW+3]; 
Put those at the top of your script.

PHP код:
stock ShowVehicleBuy(playeridpage)
{
    new 
        
str[1250],
        
counter 0
    

    
    
PlayerCarBuyPage[playerid] = page;
    
    if(
page == 1)
        
str "{FFFF00}List 1\n"
        
    else
        
format(strsizeof(str), "%s{FFFF00}<< List %d\n"strpage-1);
        
    
    for(new 
0MAX_PERSONAL_CARSi++)
    {
        if(
Stock[i][vType] == 1)
        {
            
counter++; 
        }
    }
    
    new 
        
bool:toSecondPage false,
        
countfind 0
    

    
    for(new 
page*MAX_PAGE_SHOWcounteri++)
    {
        
countfind++; 
        
        if(
countfind == MAX_PAGE_SHOW+1)
        {
            
toSecondPage true;
            break;
        }
        else
        {
            
format(strsizeof(str), "%s{ffffff}%s ( %d{33cc33}${ffffff} ) ( {00FFFF}%d {ffffff}cars in stock)\n"strStock[xf][vName], Stock[xf][vPrice], Stock[xf][vStock]);
            
CarBuySelector[playerid][countfind-1] = i
        }
    }
    if(
toSecondPage)
        
format(strsizeof(str), "%s{FFFF00}List %d >>\n"str, (page+1)+1);
        
    
ShowPlayerDialog(playeridDIALOG_CARBUY2DIALOG_STYLE_LIST"Buy a car"str"Select""Cancel");
    return 
1;

What this does is every 30 items it breaks off and you could go to another page where the next 30 will be there and so on and so on.

To use the listed item, do this with your dialog response.

PHP код:
case DIALOG_CARBUY2:
        {
            if(
response)
            {
                if(
listitem == 0)
                {
                    if(
PlayerCarBuyPage[playerid] == 1)
                        
ShowVehicleBuy(playerid1); 
                        
                    else
                        
ShowVehicleBuy(playeridPlayerCarBuyPage[playerid]-1);
                        
                    return 
1;
                }
                
                if(
listitem == MAX_PAGE_SHOW+1)
                {
                    return 
ShowVehicleBuy(playeridPlayerCarBuyPage[playerid]+1); 
                }
                
                
//To use the selected item:
                
new idx CarBuySelector[playerid][listitem-1]; 
            }
        } 
Let me know if there are any errors. I wrote this up real quick.
Reply
#9

Have you considered using the TABLIST_HEADER style?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)