Author Topic: How do I make an HUD from GUI element(s)?  (Read 2345 times)

Basically the admin GUI, you have to type in the players name or part of their name to do something to them. How do I make a list of players that ou select a player from?
I'm ok with server-sided code.
Sorry for typos, typed on my phone.  :cookieMonster:
« Last Edit: June 25, 2013, 03:27:19 PM by Subpixel »


Just pull the names from the player list.

Code: [Select]
for(%i = 0; %i < NPL_List.rowCount(); %i++)
{
    %row = NPL_List.getRowText(%i);

    %admin = getField(%row,0);
    %name = getField(%row,1);
    %score = getField(%row,2);
    %bl_id = getField(%row,3);
    %trust = getField(%row,4);

    %objid = NPL_List.getRowId(%i);

    //do stuff
}

for(%i = 0; %i < NPL_List.rowCount(); %i++)
{
    %row = NPL_List.getRowText(%i);

    %admin = getField(%row,0);
    %name = getField(%row,0);
    %score = getField(%row,0);
    %bl_id = getField(%row,0);
    %trust = getField(%row,0);

    %objid = NPL_List.getRowId(%i);

    //do stuff
}
Umm... 0 0 0 0 0 :/

Umm... 0 0 0 0 0 :/
I fixed that before your post ..lol

I fixed that before your post ..lol
But then by quote wouldn't say 0 0 0 0 0.

But then by quote wouldn't say 0 0 0 0 0.
I still fixed it before you hit "post"

Code: [Select]
for(%i = 0; %i < NPL_List.rowCount(); %i++)
{
    %row = NPL_List.getRowText(%i);

    %admin = getField(%row,0);
    %name = getField(%row,1);
    %score = getField(%row,2);
    %bl_id = getField(%row,3);
    %trust = getField(%row,4);

    %objid = NPL_List.getRowId(%i);

    //do stuff
}
I still don't understand.

I still don't understand.
You would replace //do stuff with your code that adds the player to your list. You got all the information like his admin status, his name, his bl_id, score and your trust to him above.

You would replace //do stuff with your code that adds the player to your list. You got all the information like his admin status, his name, his bl_id, score and your trust to him above.
The list is called ZapkCRPG_playersList, how would I make it so when you select a player it sets $ZapkCRPGa_playerName or something?
I'm pretty new to GUIs, sorry.

I don't understand what do to for //do stuff

Nevermind, I figured it out.
My code:
Quote
function ZapkCRPG_GetPlayers()
{
   ZapkCRPG_playersList.clear();
   for(%i = 0; %i < NPL_List.rowCount(); %i++)
   {
      %row = NPL_List.getRowText(%i);
   
      $ZapkCRPG_playersList::name[%i] = getField(%row,1);
   
      %objid = NPL_List.getRowId(%i);
   
      ZapkCRPG_playersList.addRow(%i,$ZapkCRPG_playersList::name[%i]);
   }
   ZapkCRPG_playersList.sort(0);
}

function ZapkCRPG_playersList::onSelect(%client,%i,%text)
{
   $ZapkCRPG_playersList::selectedPlayer = $ZapkCRPG_playersList::name[%i];
   echo("ZapkCRPG selected player: " @ $ZapkCRPG_playersList::selectedPlayer);
}

If there's a better way to do it, let me know. Thanks!
« Last Edit: June 24, 2013, 07:28:39 PM by Subpixel »

If there's a better way to do it, let me know. Thanks!
Here's a better way: don't post code in quote tags.

Here's a better way: don't post code in quote tags.
Sorry.
Also, new question, how do I make an HUD? As in, add things to PlayGui (unless there is another way).

Sorry.
Also, new question, how do I make an HUD? As in, add things to PlayGui (unless there is another way).

PlayGUI.add(gui control);
PlayGUI.remove(gui control);