-
Notifications
You must be signed in to change notification settings - Fork 0
/
NETHost.cs
101 lines (85 loc) · 3.08 KB
/
NETHost.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using GameServer;
using UnityEngine;
namespace vehiclemod
{
public static class NETHost
{
public static void NETSIT(int CarID, int SitID)
{
if (!Check()) return;
Packet packet = packet = new Packet((int)ClientPackets.CUSTOM);
packet.Write(1111);
packet.Write(CarID);
packet.Write(SitID);
Send(packet);
}
public static void NetDeleteCar(int id)
{
if (!Check()) return;
Packet packet = packet = new Packet((int)ClientPackets.CUSTOM);
packet.Write(0100);
packet.Write(id);
Send(packet);
}
public static void NetSendDriver(int ID, bool drived)
{
if (!Check()) return;
Packet packet = packet = new Packet((int)ClientPackets.CUSTOM);
packet.Write(1010);
packet.Write(ID);
packet.Write(drived);
Send(packet);
}
public static void NetCar(int CarID, Vector3 Position, Quaternion Rotation)
{
if (!Check()) return;
Packet packet = packet = new Packet((int)ClientPackets.CUSTOM);
packet.Write(0000);
packet.Write(CarID);
packet.Write(Position);
packet.Write(Rotation);
Send(packet);
}
public static void NetSpawnCar(int i, string name, Vector3 Position, Quaternion Rotation)
{
if (!Check()) return;
Packet packet = packet = new Packet((int)ClientPackets.CUSTOM);
packet.Write(1000);
packet.Write(i);
packet.Write(name);
packet.Write(Position);
packet.Write(Rotation);
Send(packet);
}
public static void NetSound(int ID, bool state)
{
if (!Check()) return;
Packet packet = packet = new Packet((int)ClientPackets.CUSTOM);
packet.Write(1100);
packet.Write(ID);
packet.Write(state);
Send(packet);
}
public static void NetLight(int ID, bool state)
{
if (!Check()) return;
Packet packet = packet = new Packet((int)ClientPackets.CUSTOM);
packet.Write(1101);
packet.Write(ID);
packet.Write(state);
Send(packet);
}
private static void Send(Packet packet)
{
if (SkyCoop.API.m_ClientState == SkyCoop.API.SkyCoopClientState.HOST)
SkyCoop.API.SendDataToEveryone(packet, SkyCoop.API.m_MyClientID, true); //Send data to everyone. Host Sender
if (SkyCoop.API.m_ClientState == SkyCoop.API.SkyCoopClientState.CLIENT)
SkyCoop.API.SendToHost(packet); //Send data to HOST
}
private static bool Check()
{
if (SkyCoop.API.m_ClientState == SkyCoop.API.SkyCoopClientState.NONE || !main.hook) return false;
else return true;
}
}
}