Tabsize strings. -
KaleOtter - 10.01.2011
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?
Re: Tabsize strings. -
woot - 10.01.2011
Use \t\t for Buffalo and Sultan.
Re: Tabsize strings. -
Babul - 10.01.2011
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..
Re: Tabsize strings. -
KaleOtter - 10.01.2011
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
Re: Tabsize strings. -
KaleOtter - 10.01.2011
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 :
Re: Tabsize strings. -
Babul - 10.01.2011
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:
Re: Tabsize strings. -
ғαιιοцт - 10.01.2011
Can't you use simething like %10s so that it will automaticly make the string 10 characters long? (it fills the rest with spaces)
Re: Tabsize strings. -
Babul - 11.01.2011
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
Re: Tabsize strings. -
Jefff - 11.01.2011
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");
}
Re: Tabsize strings. -
KaleOtter - 11.01.2011
Jefff nicely done. It works for me. Thank youall for helping me out with this problem.