Tabsize strings.
#1

Ewaah,

When I just \t it will set a tab in my string.
Here an example what i want.

Код:
Bullafo           $1000
Sultan            $2000
Mountain Bike     $3000

But it looks like :

Bullafo           $1000
Sultan            $2000
Mountain Bike            $3000
And I understand why it looks like that, but isn't there something that I can put instead of the normal \t , so it will look like my first example?
Reply
#2

Use \t\t for Buffalo and Sultan.
Reply
#3

if you want 3 tabs, youll get maybe 24 letters free to use (assuming that a tab is 8 chars using a non proportional font). by subtracting the carname from the "free to use" letters, you get the spaces you want to tabulate. divide those spaces by the tabsize to get the amount of tabs to use...
-create a variable like
Код:
new MaxLetters=24;
new TabSize=8;
new Tabs[][]={"","\t","\t\t","\t\t\t"};
-subtract the carnames' stringlenght from the max-stringlenght
Код:
// instead of "Sultan", use yor VehicleName[] array, h/e its called)
new MissingChars=MaxLetters-strlen("Sultan");
new MissingTabs=MissingChars/TabSize;
for the "Sultan" (lenght 6) you get 18 remaining letters. divide those 18 by 8 (tabsize), youll get 2.
this 2 points to the array MissingTabs[2] (its a "\t\t")..
finally, format the string:
Код:
//you know what to do..
format(string,sizeof(string),"%s%s",VehicleName[VehicleID-400],Tabs[MissingTabs]);
iam using the trick with this settings, the tabsize=8 wont fit each time, since that font is proportional. a space " " or dot "." is smaller than a "X" etc..
Reply
#4

Thanks babul, I will see if I can make something like that, the good thing is that I already used GetVehicleName So it won't be that much work.
Thanks
Reply
#5

It works but there is only one problem, and I cannot find the cause of that.
But I will show you my onplayerdialog part.
Код:
new HouseCarTwoWheels[11][2] = {
{509,580},
{481,380},
{510,650},
{462,4500},
{581,20000},
{522,56000},
{461,26000},
{463,25000},
{586,30000},
{468,15000},
{471,8000}
};

// ondialog >>
	        if(listitem == 0)
	        {
	            new CarList[1056];
	        	for(new All = 0; All < sizeof(HouseCarTwoWheels); All++)
	        	{
					format(carname,sizeof(carname),GetVehicleName[HouseCarTwoWheels[All][0]-400]);
					MissingChars=MaxLetters-strlen(carname);
					MissingTabs=MissingChars/TabSize;
	        	    if(pS[Bank] >= strval(HouseCarTwoWheels[All][1]))
	        	    {
						format(CarList,sizeof(CarList),"%s{FFFFFF}%s%s ${00FF00}%d\n",CarList,carname,Tabs[MissingTabs],HouseCarTwoWheels[All][1]);
					}
					else
					{
						format(CarList,sizeof(CarList),"%s{FFFFFF}%s%s ${FF0000}%d\n",CarList,carname,Tabs[MissingTabs],HouseCarTwoWheels[All][1]);
					}
	        	}
				return ShowPlayerDialog(playerid,HouseDialog+4,DIALOG_STYLE_LIST,"{A80000}Upgrade your house car. Choose a vehicle.",CarList,"Buy","Back");
	        }
screen :
Reply
#6

iam experimenting with the values for TabSize and MaxLetters, try to decrease TabSize to 5 or increase MaxLetters to 30. small changes can have a huge influence on how the dialog will look like...
sadly, you cannot chose the font in dialogs, nor specify a position for the text D:
Reply
#7

Can't you use simething like %10s so that it will automaticly make the string 10 characters long? (it fills the rest with spaces)
Reply
#8

usually, i do that like format(string,10,...); or with your suggested method. i failedІ... as soon i find a solution for that, ill post it here... hm. maybe colored _ underscores with the color {000000} will do the trick for "identation". ill try that after a /snooze
Reply
#9

Maybe not pr0 but works ;d ;p
pawn Код:
if(listitem == 0)
{
    new CarList[1056];
    for(new All = 0; All < sizeof(HouseCarTwoWheels); All++)
    {
        format(carname,sizeof(carname),GetVehicleName[HouseCarTwoWheels[All][0]-400]);
        new len = strlen(carname);
        MissingChars=MaxLetters-len;
        MissingTabs=MissingChars/TabSize;
        if(6 < len < 9) MissingTabs--;
        if(pS[Bank] >= HouseCarTwoWheels[All][1])
        {
            format(CarList,sizeof(CarList),"%s{FFFFFF}%s%s ${00FF00}%d\n",CarList,carname,Tabs[MissingTabs],HouseCarTwoWheels[All][1]);
        }
        else
        {
            format(CarList,sizeof(CarList),"%s{FFFFFF}%s%s ${FF0000}%d\n",CarList,carname,Tabs[MissingTabs],HouseCarTwoWheels[All][1]);
        }
    }
    return ShowPlayerDialog(playerid,HouseDialog+4,DIALOG_STYLE_LIST,"{A80000}Upgrade your house car. Choose a vehicle.",CarList,"Buy","Back");
}
Reply
#10

Jefff nicely done. It works for me. Thank youall for helping me out with this problem.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)