'''' ''' RS2 SERVER - VB.NET PORT ''' ''' Example Description: ''' Code gives a dynamic ability to execute methods on all connected ''' clients without sotring data in random class variables ''' Current servers call the method "process()" ''' which performs various inefficient checks for commands and messages ''' that need to be sent to all clients connected ''' eg ''' Global Messages: ''' If messageToAll.Length > 0 Then ''' Dim msgTo As Integer = 1 ''' Do ''' If Not (players(msgTo) Is Nothing) Then ''' players(msgTo).globalMessage = messageToAll ''' End If ''' msgTo += 1 ''' Loop While msgTo < maxPlayers ''' messageToAll = "" '''End If ''' ''' The previous code is fine however it checks messageToAll ''' Which is its own variable, this method means if you wanted to ''' tell all the clients that there was a dropped item you would need ''' another variable eg "bool:ItemDropped" which would be checked in the ''' process() method the same applies for doors and what not a seperate ''' variable is required ''' ''' This method uses a broadcast que to dynamically store multiple ''' methods that need to be called which can easily be added to ''' and looped through ''' ''' And here is the code ' Create the Queue which is a typed ArrayList Dim GlobalBroadcastQueue As New BroadcastList ' This will load all the methods available ''' This method contains the following ''' AddCommand("DropItem", New delegate_DropItem(AddressOf DropItem), Cmds) ''' Where the first param is the name of the method, the second is the method, ''' and the third is a list of commands LoadCmds() ' Here are some examples ' You specify the method you want called, and the parameters ' that method requires :) ' Note: I coded this so you called the method using ' a string representation of of the method name ' for one reason: Doing this a server admin could send ' something like ::exec AddItem(3423,22) which would ' call the AddItem(id,slot) method for every player ' and give them that item. AddItem could be replaced ' with any other method name without the developer ' me/you having to add any extra code ^_^ GlobalBroadcastQueue.Add(New Method("DropItem", 1, 1)) GlobalBroadcastQueue.Add(New Method("DoSomething", Nothing)) GlobalBroadcastQueue.Add(New Method("SendMessage", "Omfg message")) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Now this code would itself be placed in the PlayerHandler ' process() method Dim tMethod As Method ' We are going to go through all the methods that need to be executed While GlobalBroadcastQueue.Count > 0 tMethod = GlobalBroadcastQueue(0) ' Now we perform the method for every player For Each tPlayer As player In players tPlayer.CmdExec(tMethod.Name, tMethod.Params) Next 'Remove the call for the method from the queue GlobalBroadcastQueue.RemoveAt(0) End While Console.ReadLine() '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' The methods (just so you can see) Public Sub DropItem(ByVal itemid As Integer, ByVal slot As Integer) Console.WriteLine("DropItem: " & itemid & " " & slot) End Sub Public Sub DoSomething() Console.WriteLine("DoSomething") End Sub Public Sub SendMessage(ByVal message As String) Console.WriteLine("SendMessage: " & message) End Sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' OutPuts: ' DropItem: 1 1 ' DoSomething ' SendMessage: Omfg message