|
7 | 7 | using Newtonsoft.Json; |
8 | 8 | using Smod2.API; |
9 | 9 | using Smod2.Events; |
| 10 | +using Smod2.EventSystem.Events; |
10 | 11 |
|
11 | 12 | namespace jsmod2 |
12 | 13 | { |
@@ -85,6 +86,8 @@ static NetworkHandler() |
85 | 86 | handlers.Add(181,new SimpleHandler()); |
86 | 87 | handlers.Add(182,new HandlePlayerContain106GetScp106s()); |
87 | 88 | handlers.Add(183,new HandlePlayerSetRoleItems()); |
| 89 | + handlers.Add(184,new HandleTeamRespawnEventGetPlayers()); |
| 90 | + handlers.Add(185,new HandleTeamRespawnEventSetPlayers()); |
88 | 91 | } |
89 | 92 | public static void handleJsmod2(int id, String json,Dictionary<string,string> mapper,TcpClient client) |
90 | 93 | { |
@@ -202,6 +205,41 @@ public interface Handler |
202 | 205 | JsonSetting[] handle(object api,Dictionary<string,string> mapper); |
203 | 206 | } |
204 | 207 |
|
| 208 | +public class HandleTeamRespawnEventSetPlayers : Handler |
| 209 | +{ |
| 210 | + public JsonSetting[] handle(object api, Dictionary<string, string> mapper) |
| 211 | + { |
| 212 | + TeamRespawnEvent e = api as TeamRespawnEvent; |
| 213 | + string[] ids = Lib.getArray(mapper["players"]); |
| 214 | + List<Player> players = new List<Player>(); |
| 215 | + foreach (string id in ids) |
| 216 | + { |
| 217 | + players.Add(ProxyHandler.handler.apiMapping[id] as Player); |
| 218 | + } |
| 219 | + |
| 220 | + e.PlayerList = players; |
| 221 | + return null; |
| 222 | + } |
| 223 | +} |
| 224 | + |
| 225 | +public class HandleTeamRespawnEventGetPlayers : Handler |
| 226 | +{ |
| 227 | + public JsonSetting[] handle(object api, Dictionary<string, string> mapper) |
| 228 | + { |
| 229 | + TeamRespawnEvent e = api as TeamRespawnEvent; |
| 230 | + List<Player> players = e.PlayerList; |
| 231 | + JsonSetting[] settings = new JsonSetting[players.Count]; |
| 232 | + for (int i = 0; i < settings.Length; i++) |
| 233 | + { |
| 234 | + settings[i] = new JsonSetting(Lib.getInt(mapper["id"]),null, |
| 235 | + new IdMapping().appendId(Lib.ID,Guid.NewGuid().ToString(),players[i]).appendId(Lib.PLAYER_SCPDATA_ID,Guid.NewGuid().ToString(),players[i].Scp079Data).appendId(Lib.PLAYER_TEAM_ROLE_ID,Guid.NewGuid().ToString(),players[i].TeamRole) |
| 236 | + ); |
| 237 | + } |
| 238 | + |
| 239 | + return settings; |
| 240 | + } |
| 241 | +} |
| 242 | + |
205 | 243 | public class HandlePlayerContain106GetScp106s : Handler |
206 | 244 | { |
207 | 245 | public JsonSetting[] handle(object api, Dictionary<string, string> mapper) |
|
0 commit comments