Changed whole project structure (split client and server into separat projects)
This commit is contained in:
16
ReallifeGamemode.Server/Events/Chat.cs
Normal file
16
ReallifeGamemode.Server/Events/Chat.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class Chat : Script
|
||||
{
|
||||
[ServerEvent(Event.ChatMessage)]
|
||||
public void ChatEvent(Client player, string message)
|
||||
{
|
||||
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~{1})|(!{(.*)})", "");
|
||||
if (serverMsg.Trim().Length == 0) return;
|
||||
NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p => p.SendChatMessage($"{player.Name} sagt: {serverMsg}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
91
ReallifeGamemode.Server/Events/Connect.cs
Normal file
91
ReallifeGamemode.Server/Events/Connect.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Models;
|
||||
using reallife_gamemode.Server.Services;
|
||||
using reallife_gamemode.Server.Util;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
* @author VegaZ, xSprite
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
class Connect : Script
|
||||
{
|
||||
|
||||
|
||||
[ServerEvent(Event.PlayerConnected)]
|
||||
public void OnPlayerConnected(Client player)
|
||||
{
|
||||
player.SetData("isLoggedIn", false);
|
||||
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
||||
player.FreezePosition = true;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if(!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower()))
|
||||
{
|
||||
player.TriggerEvent("disableLogin");
|
||||
|
||||
string msg2 = "~m~*** " + player.Name + "[" + player.SocialClubName + "] (" + player.Address + ") hat versucht, sich einzuloggen, steht aber nicht auf der Whitelist.";
|
||||
ChatService.BroadcastAdmin(msg2, AdminLevel.ADMIN);
|
||||
|
||||
NAPI.Util.ConsoleOutput(player.Name + " tried to join without whitelist entry");
|
||||
|
||||
player.SendChatMessage("~m~Du stehst nicht auf der Whitelist");
|
||||
|
||||
player.Kick();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID:" + player.Handle.Value + "] (" + player.Address + ")";
|
||||
ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN);
|
||||
}
|
||||
|
||||
[RemoteEvent("IsPlayerBanned")]
|
||||
public void IsPlayerBanned(Client player)
|
||||
{
|
||||
using (var loginUser = new DatabaseContext())
|
||||
{
|
||||
var user = loginUser.Users.SingleOrDefault(b => b.Name == player.Name);
|
||||
if (user == null)
|
||||
{
|
||||
player.TriggerEvent("showLogin");
|
||||
return;
|
||||
}
|
||||
if (user.BanId != null)
|
||||
{
|
||||
var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
var bannedUser = loginUser.Bans.SingleOrDefault(u => u.Id == user.BanId);
|
||||
if (bannedUser.Applied == bannedUser.UntilDateTime)
|
||||
{
|
||||
player.SendChatMessage("!{#FF4040}Du wurdest permanent gebannt! [" + bannedUser.Reason + "]");
|
||||
player.Kick();
|
||||
}
|
||||
else
|
||||
{
|
||||
var timeStamp = bannedUser.UntilDateTime;
|
||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
|
||||
if(timeStamp > unixTimestamp)
|
||||
{
|
||||
player.SendChatMessage("Du bist noch bis zum !{#FF4040}" + dt.AddSeconds(timeStamp).ToLocalTime() + " Uhr ~s~gebannt. [" + bannedUser.Reason + "]");
|
||||
player.Kick();
|
||||
}
|
||||
else
|
||||
{
|
||||
user.BanId = null;
|
||||
loginUser.SaveChanges();
|
||||
player.TriggerEvent("showLogin");
|
||||
}
|
||||
}
|
||||
}
|
||||
else player.TriggerEvent("showLogin");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
109
ReallifeGamemode.Server/Events/Death.cs
Normal file
109
ReallifeGamemode.Server/Events/Death.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Factions.Medic;
|
||||
using reallife_gamemode.Server.Models;
|
||||
using reallife_gamemode.Server.Services;
|
||||
using reallife_gamemode.Server.Util;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Events Death (Death.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class Death : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
public void OnPlayerDeath(Client player, Client killer, uint reason)
|
||||
{
|
||||
if (!player.IsLoggedIn()) player.Kick();
|
||||
player.SetData("isDead", true);
|
||||
|
||||
if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
}
|
||||
|
||||
//var dutyMedics = 0;
|
||||
//var allPlayers = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
//foreach (Client medic in allPlayers)
|
||||
//{
|
||||
// if (medic.GetUser()?.FactionId == 2)
|
||||
// {
|
||||
// dutyMedics++;
|
||||
// }
|
||||
//}
|
||||
//player.TriggerEvent("medicInfo", dutyMedics);
|
||||
|
||||
//TODO: Zum Full Release entfernen
|
||||
NAPI.Chat.SendChatMessageToPlayer(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());
|
||||
|
||||
int? killerId;
|
||||
float killerPosX;
|
||||
float killerPosY;
|
||||
float killerPosZ;
|
||||
float killerHeading;
|
||||
|
||||
if (killer.IsNull)
|
||||
{
|
||||
killerId = null;
|
||||
killerPosX = -1;
|
||||
killerPosY = -1;
|
||||
killerPosZ = -1;
|
||||
killerHeading = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
killerId = killer.GetUser().Id;
|
||||
killerPosX = killer.Position.X;
|
||||
killerPosY = killer.Position.Y;
|
||||
killerPosZ = killer.Position.Z;
|
||||
killerHeading = killer.Heading;
|
||||
if(player != killer)
|
||||
{
|
||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + NAPI.Player.GetPlayerCurrentWeapon(killer) + ")";
|
||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||
}
|
||||
}
|
||||
//MEDIC AUFTRAG
|
||||
MedicTask reviveTask = new MedicTask()
|
||||
{
|
||||
Victim = player.Name,
|
||||
Position = player.Position,
|
||||
CauseOfDeath = reason.ToString(),
|
||||
Caller = null,
|
||||
Description = "Gestorben",
|
||||
Time = DateTime.Now,
|
||||
Type = 0,
|
||||
MedicName = "none"
|
||||
};
|
||||
Medic.AddTaskToList(reviveTask);
|
||||
|
||||
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
{
|
||||
var dead = new Logs.Death { VictimId = player.GetUser().Id, KillerId = killerId, KillerPositionX = killerPosX, KillerPositionY = killerPosY,
|
||||
KillerPositionZ = killerPosZ, KillerHeading = killerHeading, VictimPositionX = player.Position.X, VictimPositionY = player.Position.Y,
|
||||
VictimPositionZ = player.Position.Z, VictimHeading = player.Heading, CauseOfDeath = reason.ToString()};
|
||||
userDeath.DeathLogs.Add(dead);
|
||||
userDeath.SaveChanges();
|
||||
}
|
||||
}
|
||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||
public void RespawnPlayerAtHospital(Client player)
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
player.RemoveAllWeapons();
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
55
ReallifeGamemode.Server/Events/Disconnect.cs
Normal file
55
ReallifeGamemode.Server/Events/Disconnect.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Models;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class Disconnect : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
public void OnPlayerDisconnected(Client player, DisconnectionType type, string reason)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
|
||||
if (type == DisconnectionType.Left)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||
}
|
||||
if (type == DisconnectionType.Kicked)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
||||
}
|
||||
if (type == DisconnectionType.Timeout)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
||||
}
|
||||
|
||||
using (var saveUser = new DatabaseContext())
|
||||
{
|
||||
var user = player.GetUser(saveUser);
|
||||
Vector3 pos = player.Position;
|
||||
|
||||
if(!float.IsNaN(pos.X) && !float.IsNaN(pos.Y) && !float.IsNaN(pos.Z))
|
||||
{
|
||||
user.PositionX = pos.X;
|
||||
user.PositionY = pos.Y;
|
||||
user.PositionZ = pos.Z;
|
||||
saveUser.SaveChanges();
|
||||
}
|
||||
|
||||
user.Dead = player.HasData("isDead") ? player.GetData("isDead") : false;
|
||||
}
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs
Normal file
35
ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
|
||||
public class EnterVehicleAttempt : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||
public void OnPlayerEnterVehicleAttempt(Client player, Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
||||
{
|
||||
if (seat == 1) seat = 0;
|
||||
else if (seat == 0) seat = 1;
|
||||
}
|
||||
|
||||
if (seat != 0) return;
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
if(veh.FactionId != player.GetUser().FactionId)
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
ReallifeGamemode.Server/Events/Faction.cs
Normal file
67
ReallifeGamemode.Server/Events/Faction.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Models;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
class Faction : Script
|
||||
{
|
||||
[RemoteEvent("OnFactionRanksEdit")]
|
||||
public void OnFactionRanksEdit(Client player, string jsonData)
|
||||
{
|
||||
FactionRankHelper helper = JsonConvert.DeserializeObject<FactionRankHelper>(jsonData);
|
||||
using(var context = new DatabaseContext())
|
||||
{
|
||||
Entities.Faction f = context.Factions.FirstOrDefault(x => x.Id == helper.FactionId);
|
||||
if (f == null)
|
||||
{
|
||||
player.SendChatMessage("~r~[FEHLER]~s~ Bei der Bearbeitung der Ränge ist ein Fehler aufgetreten: Die Fraktion existiert nicht.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Rank> ranks = helper.Ranks;
|
||||
int length = ranks.Count;
|
||||
|
||||
List<FactionRank> factionRanks = context.FactionRanks.ToList().FindAll(fR => fR.FactionId == f.Id);
|
||||
|
||||
List<int> found = new List<int>();
|
||||
|
||||
for(int i = 0; i < ranks.Count; i++)
|
||||
{
|
||||
Rank newRank = ranks[i];
|
||||
if(newRank.Id == 0)
|
||||
{
|
||||
context.FactionRanks.Add(new FactionRank
|
||||
{
|
||||
RankName = newRank.Name,
|
||||
FactionId = f.Id,
|
||||
Order = length - i
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
FactionRank factionRank = factionRanks.Find(r => r.Id == newRank.Id);
|
||||
factionRank.RankName = newRank.Name;
|
||||
factionRank.Order = length - i;
|
||||
found.Add(factionRank.Id);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < factionRanks.Count; i++)
|
||||
{
|
||||
if(!found.Contains(factionRanks[i].Id))
|
||||
{
|
||||
context.FactionRanks.Remove(factionRanks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
player.SendChatMessage("~g~Die Ränge wurden erfolgreich gespeichert.");
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
260
ReallifeGamemode.Server/Events/Key.cs
Normal file
260
ReallifeGamemode.Server/Events/Key.cs
Normal file
@@ -0,0 +1,260 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using reallife_gamemode.Server.Classes;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Factions.Medic;
|
||||
using reallife_gamemode.Server.Inventory;
|
||||
using reallife_gamemode.Server.Managers;
|
||||
using reallife_gamemode.Server.Models;
|
||||
using reallife_gamemode.Server.Util;
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Key (Key.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class Key : Script
|
||||
{
|
||||
[RemoteEvent("keyPress:NUM2")]
|
||||
public void KeyPressNUM2(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (player.GetData("editmode") == true && player.GetUser().IsAdmin(AdminLevel.HEADADMIN) == true)
|
||||
{
|
||||
TempBlip tempBlip = NAPI.Data.GetWorldData("blipTemplate");
|
||||
SaveManager.OnSaveBlipData(player, tempBlip.Sprite.ToString(), tempBlip.Name, tempBlip.Scale.ToString(), tempBlip.Color.ToString(),
|
||||
tempBlip.Transparency.ToString(), 200.ToString(), tempBlip.ShortRange.ToString(), 0.ToString(), 0.ToString());
|
||||
player.SendNotification("~y~Blip~s~ erstellt!", false);
|
||||
}
|
||||
|
||||
GroundItem.PickUpGroundItem(player);
|
||||
}
|
||||
[RemoteEvent("keyPress:LEFT_ARROW")]
|
||||
public void KeyPressLeftArrow(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
List<Client> nearbyPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(3, player);
|
||||
|
||||
if (nearbyPlayers.Count > 1)
|
||||
{
|
||||
List<string> nearbyPlayerList = new List<string>();
|
||||
foreach (Client nearPlayer in nearbyPlayers)
|
||||
{
|
||||
if (nearPlayer.Name != player.Name)
|
||||
{
|
||||
nearbyPlayerList.Add(nearPlayer.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("showPlayerInteraction", JsonConvert.SerializeObject(nearbyPlayerList));
|
||||
}
|
||||
}
|
||||
[RemoteEvent("keyPress:RIGHT_ARROW")]
|
||||
public void KeyPressRightArrow(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
User user = player.GetUser();
|
||||
switch (user.FactionId)
|
||||
{
|
||||
//LSFD
|
||||
case 2:
|
||||
player.TriggerEvent("showFactionInteraction", user.FactionId, user.GetFaction().Name, user.FactionLeader, Medic.ReviveTasks.Count.ToString(), Medic.HealTasks.Count.ToString(), Medic.FireTasks.Count.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:E")]
|
||||
public void KeyPressE(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
var user = player.GetUser();
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5);
|
||||
if (nearest == null) return;
|
||||
if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId)
|
||||
{
|
||||
var nameTagColor = new Color(0, 0, 0);
|
||||
var factionId = user.FactionId;
|
||||
|
||||
if (player.GetData("duty") == false)
|
||||
{
|
||||
player.SetData("duty", true);
|
||||
player.SendNotification("Du bist nun ~g~im Dienst.");
|
||||
if (player.GetUser().FactionId == 2) //Fire Department
|
||||
{
|
||||
int medicCount = 0;
|
||||
foreach(Client c in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
if((c.GetUser()?.GetFaction().Id ?? 0) == 2)
|
||||
{
|
||||
medicCount++;
|
||||
}
|
||||
}
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", medicCount);
|
||||
}
|
||||
switch (factionId)
|
||||
{
|
||||
//LSPD
|
||||
case 1:
|
||||
nameTagColor = new Color(28, 134, 238);
|
||||
break;
|
||||
}
|
||||
player.NametagColor = nameTagColor;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> clothes = context.CharacterClothes.ToList().FindAll(u => u.UserId == user.Id && u.Duty == true);
|
||||
|
||||
foreach(var cloth in clothes)
|
||||
{
|
||||
if(cloth.SlotType == 0)
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cloth.ClothId != -1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.ClearAccessory(cloth.SlotId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetData("duty", false);
|
||||
player.SendNotification("Du bist nun ~r~außer Dienst.");
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false);
|
||||
player.NametagColor = new Color(255, 255, 255);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[RemoteEvent("keyPress:I")]
|
||||
public void KeyPressI(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
InventoryManager.GetUserItems(player);
|
||||
}
|
||||
[RemoteEvent("keyPress:J")]
|
||||
public void KeyPressJ(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
List<Client> players = NAPI.Pools.GetAllPlayers();
|
||||
List<ListPlayer> ListPlayers = new List<ListPlayer>();
|
||||
|
||||
foreach(Client listPlayer in players)
|
||||
{
|
||||
var lPlayer = new ListPlayer
|
||||
{
|
||||
Id = listPlayer.Handle.Value,
|
||||
Name = listPlayer.Name,
|
||||
Ping = listPlayer.Ping
|
||||
};
|
||||
|
||||
ListPlayers.Add(lPlayer);
|
||||
}
|
||||
player.TriggerEvent("fetchPlayerList", JsonConvert.SerializeObject(ListPlayers));
|
||||
}
|
||||
[RemoteEvent("keyPress:K")]
|
||||
public void KeyPressK(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
var user = player.GetUser();
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5);
|
||||
if (nearest == null) return;
|
||||
if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId)
|
||||
{
|
||||
List<string> hats = new List<string>();
|
||||
List<string> tops = new List<string>();
|
||||
List<string> legs = new List<string>();
|
||||
List<string> shoes = new List<string>();
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<DutyCloth> clothes = context.DutyClothes.ToList().FindAll(c => c.FactionId == user.FactionId && c.Gender == user.GetCharacter().Gender);
|
||||
foreach(var cloth in clothes)
|
||||
{
|
||||
if(cloth.SlotType == 1)
|
||||
{
|
||||
if (cloth.ClothId != -1)
|
||||
{
|
||||
hats.Add(cloth.ClothId.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
hats.Add("Keinen");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (cloth.SlotId)
|
||||
{
|
||||
case 11:
|
||||
tops.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
case 4:
|
||||
legs.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
case 6:
|
||||
shoes.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
[RemoteEvent("keyPress:L")]
|
||||
public void KeyPressL(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
DoorManager.ChangeDoorState(player);
|
||||
}
|
||||
[RemoteEvent("keyPress:N")]
|
||||
public void KeyPressN(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:X")]
|
||||
public void KeyPressX(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
ServerVehicle veh = player.Vehicle.GetServerVehicle();
|
||||
if(veh != null)
|
||||
{
|
||||
if(veh is FactionVehicle fV && fV.FactionId != player.GetUser()?.FactionId && (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if(veh is ShopVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("ToggleVehicleMenu");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
97
ReallifeGamemode.Server/Events/Login.cs
Normal file
97
ReallifeGamemode.Server/Events/Login.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Managers;
|
||||
using reallife_gamemode.Server.Models;
|
||||
using reallife_gamemode.Server.Util;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class Login : Script
|
||||
{
|
||||
[RemoteEvent("OnPlayerLogin")]
|
||||
public void OnPlayerLogin(Client player, string password)
|
||||
{
|
||||
using (var loginUser = new DatabaseContext())
|
||||
{
|
||||
var user = loginUser.Users.SingleOrDefault(b => b.Name == player.Name);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
player.TriggerEvent("loginFail", "Benutzer existiert nicht! Registriere dich zuerst!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("loginDeny", "Dieser Benutzer gehört dir nicht!");
|
||||
//TODO ?? Log einbauen für den bösen Bub.
|
||||
player.Kick();
|
||||
}
|
||||
if (user.Password != NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("loginFail", "Passwort inkorrekt!");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("loginSuccess");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetData("spec", true);
|
||||
player.SetData("duty", false);
|
||||
|
||||
if (user.IsAdmin(AdminLevel.HEADADMIN) == true)
|
||||
{
|
||||
player.SetData("editmode", false);
|
||||
}
|
||||
|
||||
var userBankAccount = loginUser.UserBankAccounts.SingleOrDefault(u => u.UserId == user.Id);
|
||||
userBankAccount.Balance = userBankAccount.Balance;
|
||||
|
||||
var userItems = loginUser.UserItems.ToList().FindAll(u => u.UserId == user.Id);
|
||||
player.SetData("items", userItems);
|
||||
|
||||
if (user.CharacterId == null)
|
||||
{
|
||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
player.TriggerEvent("toggleCreator");
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterCreator.ApplyCharacter(player);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
}
|
||||
if (user.Dead == true)
|
||||
{
|
||||
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
player.Health = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
player.Health = 0;
|
||||
}
|
||||
player.SetData("isDead", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
ReallifeGamemode.Server/Events/Register.cs
Normal file
67
ReallifeGamemode.Server/Events/Register.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Models;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Register (Register.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
class Register : Script
|
||||
{
|
||||
[RemoteEvent("OnPlayerRegister")]
|
||||
public void OnPlayerRegister(Client player, string password)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var checkedUser = dbContext.Users.SingleOrDefault(b => b.Name == player.Name);
|
||||
if (checkedUser == null)
|
||||
{
|
||||
var user = new Entities.User
|
||||
{
|
||||
Name = player.Name,
|
||||
SocialClubName = player.SocialClubName,
|
||||
Password = NAPI.Util.GetHashSha256(password),
|
||||
PositionX = Main.DEFAULT_SPAWN_POSITION.X,
|
||||
PositionY = Main.DEFAULT_SPAWN_POSITION.Y,
|
||||
PositionZ = Main.DEFAULT_SPAWN_POSITION.Z
|
||||
};
|
||||
|
||||
dbContext.Users.Add(user);
|
||||
dbContext.SaveChanges();
|
||||
var userBankAccount = new Entities.UserBankAccount
|
||||
{
|
||||
UserId = user.Id,
|
||||
Balance = 5000,
|
||||
Active = true
|
||||
};
|
||||
|
||||
dbContext.UserBankAccounts.Add(userBankAccount);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.TriggerEvent("registerSuccess");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetData("isDead", false);
|
||||
|
||||
var currentPlayerCreatorDimension = (uint) NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.TriggerEvent("toggleCreator");
|
||||
}
|
||||
|
||||
else if (player.SocialClubName == checkedUser.SocialClubName)
|
||||
{
|
||||
player.TriggerEvent("registerFail", "Dieser SocialClubAccount ist schon registriert!");
|
||||
}
|
||||
else if (checkedUser.Name == player.Name)
|
||||
{
|
||||
player.TriggerEvent("registerFail", "Benutzername existiert schon!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
39
ReallifeGamemode.Server/Events/ResourceStop.cs
Normal file
39
ReallifeGamemode.Server/Events/ResourceStop.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkMethods;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event ResourceStop (ResourceStop.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class ResourceStop : Script
|
||||
{
|
||||
[ServerEvent(Event.ResourceStop)]
|
||||
public void OnResourceStop()
|
||||
{
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
foreach(Client user in users)
|
||||
{
|
||||
using (var saveUsers = new DatabaseContext())
|
||||
{
|
||||
var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name);
|
||||
|
||||
saveUser.PositionX = user.Position.X;
|
||||
saveUser.PositionY = user.Position.Y;
|
||||
saveUser.PositionZ = user.Position.Z;
|
||||
saveUsers.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
ReallifeGamemode.Server/Events/Siren.cs
Normal file
26
ReallifeGamemode.Server/Events/Siren.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
class Siren : Script
|
||||
{
|
||||
private Dictionary<NetHandle, bool> _sirenStates = new Dictionary<NetHandle, bool>();
|
||||
|
||||
[RemoteEvent("keyPress:B:toggleSiren")]
|
||||
public void ToggleSirenEvent(Client player)
|
||||
{
|
||||
if (!player.IsInVehicle || player.VehicleSeat != -1) return;
|
||||
Vehicle pV = player.Vehicle;
|
||||
bool oldValue = _sirenStates.ContainsKey(pV.Handle) ? _sirenStates[pV.Handle] : false;
|
||||
bool newValue = !oldValue;
|
||||
|
||||
_sirenStates[pV.Handle] = newValue;
|
||||
pV.SetSharedData("sirenSound", newValue);
|
||||
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("toggleVehicleSiren", pV, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
154
ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs
Normal file
154
ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Models;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class UpdateCharacterCloth : Script
|
||||
{
|
||||
[RemoteEvent("updateDutyProp")]
|
||||
public void UpdateDutyProp(Client player, int componentId, int componentVariation)
|
||||
{
|
||||
if (componentId != -1)
|
||||
{
|
||||
player.SetAccessories(componentId, componentVariation, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.ClearAccessory(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("updateDutyCloth")]
|
||||
public void UpdateDutyCloth(Client player, int componentId, int componentVariation)
|
||||
{
|
||||
if (componentId == 11)
|
||||
{
|
||||
//TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL)
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
var character = player.GetUser().GetCharacter();
|
||||
|
||||
var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender);
|
||||
player.SetClothes(11, componentVariation, 0);
|
||||
if (combination != null)
|
||||
{
|
||||
player.SetClothes(3, combination.Torso, 0);
|
||||
player.SetClothes(8, combination.Undershirt, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(componentId, componentVariation, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("saveCharacterCloth")]
|
||||
public void SaveDutyCloth(Client client, string JSlotType, string JSlotId, string JClothId)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||
|
||||
User user = client.GetUser();
|
||||
user = context.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
|
||||
var character = client.GetUser().GetCharacter();
|
||||
|
||||
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
|
||||
if (charClothes == null)
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = (byte)slotType[x],
|
||||
SlotId = slotId[x],
|
||||
ClothId = clothId[x]
|
||||
};
|
||||
context.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
if (user.GetCharacter().Gender == false)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso
|
||||
};
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt
|
||||
};
|
||||
context.CharacterClothes.Add(newTorso);
|
||||
context.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]);
|
||||
loopCloth.ClothId = clothId[x];
|
||||
}
|
||||
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
|
||||
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
|
||||
|
||||
torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso;
|
||||
undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt;
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
LoadCharacterDefaults(client);
|
||||
}
|
||||
|
||||
[RemoteEvent("defaultCharacterCloth")]
|
||||
public static void LoadCharacterDefaults(Client player)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false);
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
player.ClearAccessory(6);
|
||||
player.ClearAccessory(7);
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
{
|
||||
if(cloth.SlotType == 1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
130
ReallifeGamemode.Server/Events/VehicleMenu.cs
Normal file
130
ReallifeGamemode.Server/Events/VehicleMenu.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class VehicleMenu : Script
|
||||
{
|
||||
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
||||
public void VehicleMenuToggleEngineEvent(Client player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
if (NAPI.Entity.GetEntityVelocity(v).Length() > 1)
|
||||
{
|
||||
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
bool state = VehicleStreaming.GetEngineState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (fV.FactionId != u.FactionId && !state)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
VehicleStreaming.SetEngineState(v, !state);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_LockCar")]
|
||||
public void VehicleMenuLockCarEvent(Client player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
bool state = VehicleStreaming.GetLockState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (fV.FactionId != u.FactionId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(sV is UserVehicle uV)
|
||||
{
|
||||
if(uV.UserId != u.Id && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
VehicleStreaming.SetLockStatus(v, !state);
|
||||
state = !state;
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.SendNotification(msg);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_ToggleSingleDoor")]
|
||||
public void VehicleMenuToggleSingleDoorEvent(Client player, int door)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
Vehicle veh = player.Vehicle;
|
||||
|
||||
DoorID doorId = (DoorID)door;
|
||||
|
||||
DoorState state = VehicleStreaming.GetDoorState(veh, doorId);
|
||||
|
||||
VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen);
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_OpenAllDoors")]
|
||||
public void VehicleMenuOpenAllDoorsEvent(Client player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_CloseAllDoors")]
|
||||
public void VehicleMenuCloseAllDoorsEvent(Client player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user