Author Topic: List  (Read 1160 times)

Tom

How do I create a working list in  a Gui like the one in the admin menu only not with players?

Well what do you want it to be with? I'm guessing different food type's for your script?

Tom

I'm guessing different food type's for your script?

Yep, oh yeah it also needs to be multi collum.

Multi-collum I have no idea how to do but look at script's with simple GUI's such as Mr.Pickles Cash mod GUI or other's.

Create a GuiScrollControl for scrolling, and within it create a GuiTextListControl, and name it something, for example, ListThing.
Add things to the list using ListThing.Addrow(id, text, index);
Clear the list by using ListThing.Clear();
Clear the selection using ListThing.clearSelection();
Find out what is currently selected by using either ListThing.getValue() to get the selection's text, or ListThing.getSelectedId() to get the selection's ID.
Use ListThing.removeRow(index) or ListThing.removeRow(id) to remove a row with the specified index or id.

As for multi-column, I'm not sure / too lazy to figure out :cookieMonster:


Set something like TabColumns (pixel distance from left for each column e.g. "0 50" for a 50px wide and (width of control - 50) wide column) in the GuiTextListCtrl and add rows such as "Space Guy" TAB "130" for a name in the first column and the BL_ID in the second.

Set something like TabColumns (pixel distance from left for each column e.g. "0 50" for a 50px wide and (width of control - 50) wide column) in the GuiTextListCtrl and add rows such as "Space Guy" TAB "130" for a name in the first column and the BL_ID in the second.
Oh wow, it's that simple?

As Headcrab said, make a GuiScrollCtrl and place a GuiTextListCtrl within it.
You can then use this code (where foodGui is the name of the GuiControl) to fill the list:

Code: [Select]
function foodGui::onWake(%this)
{
   ListThing.clear();

   for(%i = 1; %i < $foodcount; %i++)
      ListThing.addRow(%i, $food[%i] TAB $foodcost[%i] TAB $foodheal[%i]);
}

You seperate columns using TAB or \t, and set the starting position of each column of the GuiTextListCtrl in the columns field.

Ah, it's columns. I thought it was TabColumns.

Tom

I need more help, its not getting the text from the boxes.

Code: [Select]
function makenewfood(%client)
{
%name = txtnewFoodName.getValue();
%cost = newFoodCost.getValue();
%heal = newFoodHeal.getValue();
commandtoserver('newfood',%name,%cost,%heal);
}


You probably forgot to name the boxes, or you put the name in the wrong area, or you did something wrong. The getValue() method doesn't just break randomly.

You might want to put an echo(%name SPC %cost SPC %heal) in there to see if it is actually getting the values, but the servercmdnewfood isn't picking them up right.

Tom

You might want to put an echo(%name SPC %cost SPC %heal) in there to see if it is actually getting the values, but the servercmdnewfood isn't picking them up right.

I'm pretty sure its the getvaule, I tested the name one with commandtoserver('messagesent',%name);

No no, Its you.

Trust me.

Tom

Looking at other GUIs it looks like you need to have txt in front of textboxs names, becasue that fixed it