2023-07-28 03:24:00 +03:00
|
|
|
|
using BattleBitAPI;
|
2023-08-11 12:34:11 +03:00
|
|
|
|
using BattleBitAPI.Common;
|
2023-03-03 23:00:54 +03:00
|
|
|
|
using BattleBitAPI.Server;
|
2023-08-18 01:43:23 +03:00
|
|
|
|
using System.Linq.Expressions;
|
2023-08-17 18:39:20 +03:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Numerics;
|
2023-08-11 14:44:54 +03:00
|
|
|
|
using System.Threading.Channels;
|
2023-08-11 19:14:47 +03:00
|
|
|
|
using System.Xml;
|
2023-03-03 15:15:17 +03:00
|
|
|
|
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2023-08-11 11:04:47 +03:00
|
|
|
|
var listener = new ServerListener<MyPlayer, MyGameServer>();
|
2023-08-18 01:43:23 +03:00
|
|
|
|
listener.OnCreatingGameServerInstance += OnCreatingGameServerInstance;
|
|
|
|
|
listener.OnCreatingPlayerInstance += OnCreatingPlayerInstance;
|
2023-08-11 13:05:13 +03:00
|
|
|
|
listener.Start(29294);
|
2023-08-11 14:44:54 +03:00
|
|
|
|
|
2023-07-28 03:24:00 +03:00
|
|
|
|
Thread.Sleep(-1);
|
2023-03-03 15:15:17 +03:00
|
|
|
|
}
|
2023-08-14 12:43:58 +03:00
|
|
|
|
|
2023-08-18 01:43:23 +03:00
|
|
|
|
private static MyPlayer OnCreatingPlayerInstance()
|
2023-08-17 18:39:20 +03:00
|
|
|
|
{
|
2023-08-18 01:43:23 +03:00
|
|
|
|
return new MyPlayer("asdasd");
|
2023-08-17 18:39:20 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-18 01:43:23 +03:00
|
|
|
|
private static MyGameServer OnCreatingGameServerInstance()
|
2023-08-17 18:39:20 +03:00
|
|
|
|
{
|
2023-08-18 01:43:23 +03:00
|
|
|
|
return new MyGameServer("mysecretDBpass");
|
2023-08-17 18:39:20 +03:00
|
|
|
|
}
|
2023-07-28 03:24:00 +03:00
|
|
|
|
}
|
2023-08-11 14:44:54 +03:00
|
|
|
|
class MyPlayer : Player<MyPlayer>
|
2023-07-28 03:24:00 +03:00
|
|
|
|
{
|
2023-08-18 01:43:23 +03:00
|
|
|
|
private string mydb;
|
|
|
|
|
public MyPlayer(string mydb)
|
|
|
|
|
{
|
|
|
|
|
this.mydb = mydb;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-17 18:39:20 +03:00
|
|
|
|
public override async Task OnSpawned()
|
2023-08-14 17:13:31 +03:00
|
|
|
|
{
|
|
|
|
|
}
|
2023-08-11 13:05:13 +03:00
|
|
|
|
}
|
2023-08-11 11:04:47 +03:00
|
|
|
|
class MyGameServer : GameServer<MyPlayer>
|
|
|
|
|
{
|
2023-08-18 01:43:23 +03:00
|
|
|
|
private string myDbConnection;
|
|
|
|
|
public MyGameServer(string mySecretDBConnection)
|
|
|
|
|
{
|
|
|
|
|
this.myDbConnection = mySecretDBConnection;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-14 12:43:58 +03:00
|
|
|
|
public override async Task OnConnected()
|
2023-08-11 14:44:54 +03:00
|
|
|
|
{
|
2023-08-14 12:43:58 +03:00
|
|
|
|
ForceStartGame();
|
2023-08-17 18:39:20 +03:00
|
|
|
|
ServerSettings.PlayerCollision = true;
|
|
|
|
|
}
|
|
|
|
|
public override async Task OnTick()
|
|
|
|
|
{
|
2023-08-18 00:56:39 +03:00
|
|
|
|
}
|
|
|
|
|
public override async Task<OnPlayerSpawnArguments> OnPlayerSpawning(MyPlayer player, OnPlayerSpawnArguments request)
|
|
|
|
|
{
|
2023-08-18 01:43:23 +03:00
|
|
|
|
request.Wearings.Eye = "Eye_Zombie_01";
|
|
|
|
|
request.Wearings.Face = "Face_Zombie_01";
|
|
|
|
|
request.Wearings.Face = "Hair_Zombie_01";
|
|
|
|
|
request.Wearings.Skin = "Zombie_01";
|
|
|
|
|
request.Wearings.Uniform = "ANY_NU_Uniform_Zombie_01";
|
|
|
|
|
request.Wearings.Head = "ANV2_Universal_Zombie_Helmet_00_A_Z";
|
2023-08-18 00:56:39 +03:00
|
|
|
|
request.Wearings.Belt = "ANV2_Universal_All_Belt_Null";
|
|
|
|
|
request.Wearings.Backbag = "ANV2_Universal_All_Backpack_Null";
|
|
|
|
|
request.Wearings.Chest = "ANV2_Universal_All_Armor_Null";
|
|
|
|
|
|
|
|
|
|
return request;
|
2023-08-11 14:44:54 +03:00
|
|
|
|
}
|
2023-08-14 16:21:30 +03:00
|
|
|
|
|
|
|
|
|
public override async Task OnPlayerConnected(MyPlayer player)
|
|
|
|
|
{
|
2023-08-14 17:13:31 +03:00
|
|
|
|
await Console.Out.WriteLineAsync("Connected: " + player);
|
2023-08-18 01:43:23 +03:00
|
|
|
|
player.Modifications.CanSpectate = true;
|
|
|
|
|
player.Modifications.CanDeploy = false;
|
2023-08-17 18:39:20 +03:00
|
|
|
|
|
2023-08-14 16:21:30 +03:00
|
|
|
|
}
|
|
|
|
|
public override async Task OnPlayerSpawned(MyPlayer player)
|
|
|
|
|
{
|
|
|
|
|
await Console.Out.WriteLineAsync("Spawned: " + player);
|
|
|
|
|
}
|
|
|
|
|
public override async Task OnAPlayerDownedAnotherPlayer(OnPlayerKillArguments<MyPlayer> args)
|
|
|
|
|
{
|
|
|
|
|
await Console.Out.WriteLineAsync("Downed: " + args.Victim);
|
|
|
|
|
}
|
|
|
|
|
public override async Task OnPlayerGivenUp(MyPlayer player)
|
|
|
|
|
{
|
|
|
|
|
await Console.Out.WriteLineAsync("Giveup: " + player);
|
|
|
|
|
}
|
|
|
|
|
public override async Task OnPlayerDied(MyPlayer player)
|
|
|
|
|
{
|
|
|
|
|
await Console.Out.WriteLineAsync("Died: " + player);
|
|
|
|
|
}
|
|
|
|
|
public override async Task OnAPlayerRevivedAnotherPlayer(MyPlayer from, MyPlayer to)
|
|
|
|
|
{
|
2023-08-14 17:13:31 +03:00
|
|
|
|
await Console.Out.WriteLineAsync(from + " revived " + to);
|
2023-08-14 16:21:30 +03:00
|
|
|
|
}
|
|
|
|
|
public override async Task OnPlayerDisconnected(MyPlayer player)
|
2023-08-11 22:48:28 +03:00
|
|
|
|
{
|
2023-08-14 16:21:30 +03:00
|
|
|
|
await Console.Out.WriteLineAsync("Disconnected: " + player);
|
2023-08-11 22:48:28 +03:00
|
|
|
|
}
|
2023-08-11 11:04:47 +03:00
|
|
|
|
}
|