Author Topic: Guis in v9 and player list.  (Read 1315 times)

Tom

1: How do GUIS and clientside scripts work in v9?
2: How do I make  a player list for a gui, I know it involves the client requesting the server for the  players and then putting them on the list, but how do I do that?

1: How do GUIS and clientside scripts work in v9?
I want to know the same thing.

Instead of putting a server.cs inside the zip you make a client.cs file. You can execute other files from there but the client.cs is the only file automatically executed, very similar to how server-side mods work.


Tom

Thanks, now I just need to figure out a clientside playerlist.

For a clientsided player list you would need a GuiTextListCtrl, preferably in a GuiScrollCtrl.

Now if you have it, lets say:
  • List's name is TL
  • GUI's name is PLGui
  • The list has 2 columns set, 1 for name and 1 for BL_ID.

Clientsided code:
Code: [Select]
function PLGui::OnWake(%this) //If we show the GUI.
{
TL.clear(); //Clear the list for updating
commandToServer('RequestPlayers'); //We send a command to the server that we need the players sent to us.
}

function clientCmdAddPlayer(%id,%name,%bl_id) //A clientCmd is the opposite of a serverCmd.
{
TL.addRow(%id,%name TAB %bl_id); //This adds a row, TAB is "\t" or " ", in TextLists it means next column. First argument is the row ID, do not confuse this with the row index.
}

This would request the players onWake and define the clientCmd to add players.

Now the serversided code:
Code: [Select]
function serverCmdRequestPlayers(%c) //This is the serversided request cmd.
{
%count=clientGroup.getCount(); //Get the clientGroup's count.
for(%i=0;%i<%count;%i++) //Loop through them all.
{
%obj=%c.getObject(%i); //Get the current object we are looping through.
commandToClient(%c,'AddPlayer',%obj,%obj.name,%obj.bl_id); //Command the client to do clientCmdAddPlayer.
}
}

Notes:
  • This is untested.
  • You might want to change function names.

I took my time in commenting this well, so I hope you won't just copy/paste, but learn from it.

Good luck ;D

Tom

Is it possible to have a serverside mod with a clientside GUI?

What I was saying requires a serversided mod.

So the answer is yes.

Tom

But with both a server.cs and a client.cs its not execing.