ItsMods

Full Version: Event OnServerLoaded(), On MapLoaded();
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can You add events OnServerLoaded() and OnMapLoaded() ?
Thx.
already added
I think he means the events after loading the server/map
@iAegle Yes. And those are both added already
(04-07-2012, 21:00)iAegle Wrote: [ -> ]I think he means the events after loading the server/map
Yes I need this because server go crash when Server is no loaded and i whant GetClients from server.

(04-07-2012, 21:11)JariZ Wrote: [ -> ]@iAegle Yes. And those are both added already

OnServerLoad is not a OnServerLoaded

Test Code for unbelievers:

Code:
using System;
using System.Threading;
using Addon;

namespace Problem
{
    public class Problem : CPlugin
    {
        private int clients;

        public override void OnServerLoad()
        {
            Thread t = new Thread(GetNumOfCLients);
            t.Start();
        }

        private void GetNumOfCLients()
        {
            while (true)
            {
                clients = GetClients().Count;
                ServerPrint("Clients: " + clients + " on server");
                Thread.Sleep(5000);
            }
        }
    }
}

Use Thread.Sleep(), for my computer is 15sec to final load server.
Hello,

OnPreMapChange -> executed when map change is scheduled but not started yet
OnMapChange -> executed after the map changed
OnServerLoad -> executed when the server is loading

I recommend you to use a global variable, ex. bool ThreadStarted = false. Then you put OnMapChange
CSHARP Code
  1. If(ThreadStarted==false)
  2. {
  3. Thread t = new Thread(GetNumOfCLients);
  4. t.Start();
  5. ThreadStarted = true;
  6. }


Another way is that you put a Thread.Sleep(7000) or something above the while.