Author Topic: Player list.  (Read 1699 times)

How do you make a player list, i copy && pasted one from the Admin Gui it makes mine work but then the admin gui one stops working, help....

Try using the F2 list instead of Admin GUI.

Add-Ons/Client/MrP_PlayerListGUI_Client.cs
Code: [Select]
exec("./MrP_PlayerListGUI.gui"); //Or copy paste the code in the GUI file here
function MrP_PlayerListGui::OnWake(%this)
{
 commandtoserver('getMrPPlayerList');
}

function clientcmdUpdateGUI(%obj,%action,%arg1,%arg2)
{
switch$(%action)
{
case "listClear": %obj.clear();
case "listRow": %obj.addRow(%arg1, %arg2);
case "textSet": %obj.setText(%arg1);
}
}

Add-Ons/MrP_PlayerListGUI_Server.cs
Code: [Select]
function servercmdgetMrPPlayerList(%client)
{
 commandtoclient(%client,'updateGUI',"MrP_PlayerList","listClear");
 for(%i=0;%i<ClientGroup.getCount();%i--)
 {
  %cl=ClientGroup.getObject(%i);
  %tag = (%cl.isAdmin ? "[A]" : "");
  %tag = (%cl.isSuperAdmin ? "[S]" : %tag);
  %tag = (%cl.getRawIP() $= "local" ? "[H]" : %tag);
  commandtoclient(%client,'updateGUI',"MrP_PlayerList","listRow",%i,%cl.name TAB %tag);
 }
}

Clients will have to download the GUI and client file before using it. The GUI will not update if a client leaves or becomes admin while it is open. I'm not sure whether the [H] tag works, most likely you will show up as (SuperAdmin).

The GUI should contain a copy of the admin player list, but with the list itself renamed to "MrP_PlayerList" and the GUI called "MrP_PlayerListGui". You will need to add your own toggle command.

Space. You could use findLocalClient(); instead.

Quote from: MrPickle
When i open up the GUI it says: Set::getObject index out of range on ClientGroup. Index = -1, Size = 1

Whoops. I originally intended it to go in reverse order, on who joined, but realised my method was wrong and badly reverted it. Replace "%i--" with "%i++".

Quote from: MrPickle
Thanks Space.

Quote from: MrPickle
How do you get the selected person?

Code: [Select]
commandtoserver('selectperson',MrP_PlayerList.getSelectedID());

function servercmdSelectPerson(%client,%id)
{
 messageall('',%client.name @ " selected " @ ClientGroup.getObject(%id));
}

I think that's the code...

Quote from: MrPickle
Dosen't work, It's echoing False.

What is echoing false? There's no echos there!

Quote from: MrPickle
I added an Echo to see if it was selecting anything

Client- or server-side? Is the bug with the servercmd or the selecting on the list?

Also, did you name the list itself "MrP_PlayerList" or accidentally one of the bitmaps/scroll things/etc?

Quote from: MrPickle
function AdminCashGui::GrantCash(){
   commandtoserver('GrantCash',AdminCashGuiList.getSelectedId(),GrantCash.getValue());
   echo(AdminCashGuiList.getSelectedI d());
}


Thats what i put

Have you actually selected anything on the list yet i.e. clicked the MrPickle [H] option before the button?