04-07-2012, 19:35
04-07-2012, 20:08
04-07-2012, 20:55
already added
04-07-2012, 21:00
I think he means the events after loading the server/map
04-07-2012, 21:28
(04-07-2012, 21:00)iAegle Wrote: [ -> ]I think he means the events after loading the server/mapYes 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.
04-08-2012, 10:39
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
Another way is that you put a Thread.Sleep(7000) or something above the while.
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
- If(ThreadStarted==false)
- {
- t.Start();
- ThreadStarted = true;
- }
Another way is that you put a Thread.Sleep(7000) or something above the while.