Merging into feature/inventory-system
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
@@ -7,7 +8,9 @@ namespace reallife_gamemode.Server.Events
|
||||
[ServerEvent(Event.ChatMessage)]
|
||||
public void ChatEvent(Client player, string message)
|
||||
{
|
||||
NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p => p.SendChatMessage($"{player.Name} sagt: {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}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,37 +21,34 @@ namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
class Connect : Script
|
||||
{
|
||||
private List<string> whitelistNames = new List<string>()
|
||||
{
|
||||
"VegasZ",
|
||||
"datgame_",
|
||||
"xSprite",
|
||||
"xPrike",
|
||||
"xNccPlay",
|
||||
};
|
||||
|
||||
|
||||
[ServerEvent(Event.PlayerConnected)]
|
||||
public void OnPlayerConnected(Client player)
|
||||
{
|
||||
if(!whitelistNames.Any(x => x == player.SocialClubName))
|
||||
{
|
||||
player.TriggerEvent("disableLogin");
|
||||
player.Kick();
|
||||
|
||||
string msg2 = "~m~*** " + player.Name + "[" + player.SocialClubName + "] (" + player.Address + ") hat versucht, sich einzuloggen, steht aber nicht auf der Whitelist.";
|
||||
ChatService.BroadcastAdmin(msg2, AdminLevel.ADMIN);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
player.SetData("isLoggedIn", false);
|
||||
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
||||
player.FreezePosition = true;
|
||||
string name = player.Name;
|
||||
List<Client> playerlist = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
string msg = "~m~*** " + player.Name + "[" + player.SocialClubName + "] [ID:" + player.Handle.Value + "] (" + player.Address + ")";
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace reallife_gamemode.Server.Events
|
||||
[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)
|
||||
|
||||
@@ -36,19 +36,17 @@ namespace reallife_gamemode.Server.Events
|
||||
using (var saveUser = new Model.DatabaseContext())
|
||||
{
|
||||
var user = player.GetUser(saveUser);
|
||||
Vector3 pos = player.Position;
|
||||
|
||||
if(user == null)
|
||||
if(!float.IsNaN(pos.X) && !float.IsNaN(pos.Y) && !float.IsNaN(pos.Z))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
user.PositionX = player.Position.X;
|
||||
user.PositionY = player.Position.Y;
|
||||
user.PositionZ = player.Position.Z;
|
||||
user.Dead = player.GetData("isDead");
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -13,13 +13,19 @@ namespace reallife_gamemode.Server.Events
|
||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||
public void OnPlayerEnterVehicleAttempt(Client player, Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
if (vehicle.HasData("factionId"))
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
||||
{
|
||||
if((vehicle.GetData("factionId") != player.GetUser().FactionId) && seat == 0)
|
||||
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)
|
||||
{
|
||||
//TODO REWORK
|
||||
player.SetIntoVehicle(vehicle, 1);
|
||||
player.WarpOutOfVehicle();
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,15 @@ namespace reallife_gamemode.Server.Events
|
||||
player.SendNotification("Du bist nun ~g~im Dienst.");
|
||||
if (player.GetUser().FactionId == 2) //Fire Department
|
||||
{
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", true);
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,10 @@ namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
Name = player.Name,
|
||||
SocialClubName = player.SocialClubName,
|
||||
Password = NAPI.Util.GetHashSha256(password)
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user