[+] Add Command for Admin /setweaponrack , /rmweaponrack and for Leader /setweaponrank
+ Add blip alpha channel for Players (set to 125) + Add blip color for Player with Wanted - Removed WeaponHash from DB entry FactionWeapons (Deprecated)
This commit is contained in:
@@ -10,7 +10,7 @@ export default function playerBlips() {
|
||||
if (entity.type === "player") {
|
||||
let color = parseInt(entity.getVariable("blipColor"));
|
||||
if (entity.blip == 0) entity.createBlip(1);
|
||||
|
||||
entity.blip.alpha = 125;
|
||||
entity.setBlipColor(isNaN(color) ? 0 : color);
|
||||
mp.game.invoke(Natives.SET_BLIP_CATEGORY, entity.blip, 7);
|
||||
mp.game.invoke(Natives.SHOW_HEADING_INDICATOR_ON_BLIP, entity.blip, true);
|
||||
|
||||
@@ -2600,9 +2600,142 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
}
|
||||
|
||||
[Command("setweaponrack", "~m~Benutzung: ~s~/setweaponrack [Fraktion ID] [Waffen Model] [SlotID (1-4)]")]
|
||||
public void CmdAdminSetWeaponrack(Client player, int factionID,string weaponModel,int slotId)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Entities.Faction f = dbContext.Factions.FirstOrDefault(x => x.Id == factionID);
|
||||
if (f == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist~s~)");
|
||||
return;
|
||||
}
|
||||
if (weaponModel != "Schutzweste")
|
||||
{
|
||||
if (!uint.TryParse(weaponModel, out uint weapon))
|
||||
{
|
||||
if (weaponModel.Contains("mk2") && !weaponModel.Contains("_mk2")) weaponModel = weaponModel.Replace("mk2", "_mk2");
|
||||
weapon = NAPI.Util.GetHashKey($"weapon_{weaponModel}");
|
||||
}
|
||||
|
||||
if (!WeaponManager.IsValidHash(weapon))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Diese Waffe existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
Entities.FactionWeapon fw = dbContext.FactionWeapons.FirstOrDefault(w => w.FactionId == factionID && w.WeaponModel == weaponModel);
|
||||
if (fw == null)
|
||||
{
|
||||
var newWeapon = new Entities.FactionWeapon
|
||||
{
|
||||
WeaponModel = weaponModel,
|
||||
SlotID = slotId,
|
||||
Rank = 12,
|
||||
FactionId = factionID
|
||||
};
|
||||
dbContext.FactionWeapons.Add(newWeapon);
|
||||
dbContext.SaveChanges();
|
||||
ChatService.SendMessage(player, "Neuer Waffeneintrag für die Fraktion " + f.Name + ": " + weaponModel + ", SlotId: " + slotId);
|
||||
return;
|
||||
}
|
||||
|
||||
fw.SlotID = slotId;
|
||||
dbContext.SaveChanges();
|
||||
ChatService.SendMessage(player, "Waffeneintrag bearbeitet für die Fraktion " + f.Name + ": " + weaponModel + ", SlotId: " + slotId);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Entities.FactionWeapon fw2 = dbContext.FactionWeapons.FirstOrDefault(w => w.FactionId == factionID && w.WeaponModel == weaponModel);
|
||||
if (fw2 == null)
|
||||
{
|
||||
var schutzweste = new Entities.FactionWeapon
|
||||
{
|
||||
WeaponModel = weaponModel,
|
||||
SlotID = slotId,
|
||||
Rank = 12,
|
||||
FactionId = factionID
|
||||
};
|
||||
dbContext.FactionWeapons.Add(schutzweste);
|
||||
dbContext.SaveChanges();
|
||||
ChatService.SendMessage(player, "Neuer Waffeneintrag für die Fraktion " + f.Name + ": " + weaponModel + ", SlotId: " + slotId);
|
||||
return;
|
||||
}
|
||||
|
||||
fw2.SlotID = slotId;
|
||||
dbContext.SaveChanges();
|
||||
ChatService.SendMessage(player, "Waffeneintrag bearbeitet für die Fraktion " + f.Name + ": " + weaponModel + ", SlotId: " + slotId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Command("rmweaponrack", "~m~Benutzung: ~s~/rmweaponrack [Fraktion ID] [Waffen Model]")]
|
||||
public void CmdAdminRmWeaponrack(Client player, int factionID, string weaponModel)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Entities.Faction f = dbContext.Factions.FirstOrDefault(x => x.Id == factionID);
|
||||
if (f == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist~s~)");
|
||||
return;
|
||||
}
|
||||
if (weaponModel != "Schutzweste")
|
||||
{
|
||||
if (!uint.TryParse(weaponModel, out uint weapon))
|
||||
{
|
||||
if (weaponModel.Contains("mk2") && !weaponModel.Contains("_mk2")) weaponModel = weaponModel.Replace("mk2", "_mk2");
|
||||
weapon = NAPI.Util.GetHashKey($"weapon_{weaponModel}");
|
||||
}
|
||||
|
||||
if (!WeaponManager.IsValidHash(weapon))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Diese Waffe existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
Entities.FactionWeapon fw = dbContext.FactionWeapons.FirstOrDefault(w => w.FactionId == factionID && w.WeaponModel == weaponModel);
|
||||
if (fw != null)
|
||||
{
|
||||
dbContext.FactionWeapons.Remove(fw);
|
||||
ChatService.SendMessage(player, "Waffe entsorgt für die Fraktion " + f.Name + ": " + weaponModel);
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
ChatService.ErrorMessage(player, "Diese Waffe befindet sich nicht im Waffenlager");
|
||||
return;
|
||||
}
|
||||
Entities.FactionWeapon fw2 = dbContext.FactionWeapons.FirstOrDefault(w => w.FactionId == factionID && w.WeaponModel == weaponModel);
|
||||
if (fw2 != null)
|
||||
{
|
||||
dbContext.FactionWeapons.Remove(fw2);
|
||||
ChatService.SendMessage(player, "Schutzweste entsorgt für die Fraktion " + f.Name + ": " + weaponModel);
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
ChatService.ErrorMessage(player, "Es befindet sich keine Schutzweste im Waffenlager");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region ALevel1338
|
||||
#region ALevel1338
|
||||
[Command("whitelist", "~m~Benutzung: ~s~/whitelist [Add / Remove] [Socialclub Name]")]
|
||||
public void CmdAdminWhitelist(Client player, string option, string scName)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
@@ -131,8 +132,48 @@ namespace ReallifeGamemode.Server.Commands
|
||||
if (p.GetUser()?.FactionLeader ?? false) ChatService.SendMessage(p, broadcastMsg);
|
||||
});
|
||||
}
|
||||
|
||||
[Command("setweaponrank", "~m~Benutzung: ~s~/setweaponrank [Waffen Name] [Rank]")]
|
||||
public void CmdFactionWeaponRank(Client player, string weaponModel, int rank)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
if (rank > 12 || rank < 1)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Gebe einen gültigen Rang ein");
|
||||
return;
|
||||
}
|
||||
|
||||
User user = player.GetUser();
|
||||
WeaponPoint nearestWeapon = PositionManager.WeaponPoints.Find(w => w.Position.DistanceTo(player.Position) <= 1.5 && w.FactionId == user.FactionId);
|
||||
if (nearestWeapon == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du bist nicht in der nähe vom Waffenspind");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
Entities.FactionWeapon fw2 = context.FactionWeapons.FirstOrDefault(w => w.FactionId == user.FactionId && w.WeaponModel == weaponModel);
|
||||
|
||||
if (fw2 != null)
|
||||
{
|
||||
fw2.Rank = rank;
|
||||
context.SaveChanges();
|
||||
ChatService.SendMessage(player, "Du hast die " + weaponModel + " als Rang " + rank + " Waffe eingestellt.");
|
||||
return;
|
||||
}
|
||||
ChatService.ErrorMessage(player, "Diese Waffe ist nicht im Waffenlager");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
#region Sanitäter Commands
|
||||
#region Sanitäter Commands
|
||||
|
||||
[Command("revive", "~m~Benutzung: ~s~/revive")]
|
||||
public void CmdFactionMedicRevive(Client player)
|
||||
|
||||
@@ -17,7 +17,6 @@ namespace ReallifeGamemode.Server.Entities
|
||||
public int FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
public int WeaponHash { get; set; }
|
||||
public string WeaponModel { get; set; }
|
||||
public int SlotID { get; set; }
|
||||
public int Rank { get; set; }
|
||||
|
||||
@@ -206,6 +206,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.SendNotification("Du bist nun ~r~außer Dienst.");
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false);
|
||||
player.NametagColor = new Color(255, 255, 255);
|
||||
player.SetSharedData("blipColor", 4);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
}
|
||||
}
|
||||
@@ -216,6 +217,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
List<string> secondarys = new List<string>();
|
||||
List<string> melees = new List<string>();
|
||||
List<string> specials = new List<string>();
|
||||
primarys.Add("Keine");
|
||||
secondarys.Add("Keine");
|
||||
melees.Add("Keine");
|
||||
specials.Add("Keine");
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<FactionWeapon> weapons = context.FactionWeapons.ToList().FindAll(w => w.FactionId == user.FactionId);
|
||||
@@ -226,49 +231,20 @@ namespace ReallifeGamemode.Server.Events
|
||||
switch (weapon.SlotID)
|
||||
{
|
||||
case 1:
|
||||
if (weapon.WeaponHash != -1)
|
||||
{
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
primarys.Add(weapon.WeaponModel.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
primarys.Add("Keine");
|
||||
}
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
primarys.Add(weapon.WeaponModel.ToString());
|
||||
break;
|
||||
case 2:
|
||||
if (weapon.WeaponHash != -1)
|
||||
{
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
secondarys.Add(weapon.WeaponModel.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
secondarys.Add("Keine");
|
||||
}
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
secondarys.Add(weapon.WeaponModel.ToString());
|
||||
break;
|
||||
case 3:
|
||||
if (weapon.WeaponHash != -1)
|
||||
{
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
melees.Add(weapon.WeaponModel.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
melees.Add("Keine");
|
||||
}
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
melees.Add(weapon.WeaponModel.ToString());
|
||||
break;
|
||||
case 4:
|
||||
if (weapon.WeaponHash != -1)
|
||||
{
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
specials.Add(weapon.WeaponModel.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
specials.Add("Keine");
|
||||
specials.Add("Schutzweste");
|
||||
}
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
specials.Add(weapon.WeaponModel.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -276,18 +252,17 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
player.TriggerEvent("showWeaponMenu", primarys.ToArray(), secondarys.ToArray(), melees.ToArray(), specials.ToArray());
|
||||
}
|
||||
if(nearestJailReleasePoint != null)
|
||||
if (nearestJailReleasePoint != null)
|
||||
{
|
||||
List<string> criminals = new List<string>();
|
||||
criminals.Add("Keiner");
|
||||
foreach (Client target in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
User c = target.GetUser();
|
||||
|
||||
if (c.JailTime > 0)
|
||||
{
|
||||
if (c.JailTime > 0)
|
||||
{
|
||||
criminals.Add(c.Name.ToString());
|
||||
}
|
||||
criminals.Add(c.Name);
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("showJailMenu", JsonConvert.SerializeObject(criminals.ToArray()));
|
||||
|
||||
@@ -6,7 +6,9 @@ using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
@@ -18,9 +20,9 @@ namespace ReallifeGamemode.Server.Events
|
||||
[RemoteEvent("updateWeaponSelection")]
|
||||
public void UpdateWeaponSelection(Client client, string weaponModel, int slot)
|
||||
{
|
||||
if(weaponModel == "Schutzweste")
|
||||
if(weaponModel == "Keine")
|
||||
{
|
||||
client.Armor = 100;
|
||||
client.RemoveAllWeapons();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,7 +48,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
client.Armor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,19 +62,38 @@ namespace ReallifeGamemode.Server.Events
|
||||
public void SaveWeaponSelection(Client client, string primaryModel, string secondaryModel, string meleeModel, string specialModel)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
WeaponHash primary = NAPI.Util.WeaponNameToModel(primaryModel);
|
||||
WeaponHash secondary = NAPI.Util.WeaponNameToModel(secondaryModel);
|
||||
WeaponHash melee = NAPI.Util.WeaponNameToModel(meleeModel);
|
||||
if (!uint.TryParse(primaryModel, out uint primary))
|
||||
{
|
||||
if (primaryModel.Contains("mk2") && !primaryModel.Contains("_mk2")) primaryModel = primaryModel.Replace("mk2", "_mk2");
|
||||
primary = NAPI.Util.GetHashKey($"weapon_{primaryModel}");
|
||||
}
|
||||
if (!uint.TryParse(secondaryModel, out uint secondary))
|
||||
{
|
||||
if (secondaryModel.Contains("mk2") && !secondaryModel.Contains("_mk2")) secondaryModel = secondaryModel.Replace("mk2", "_mk2");
|
||||
secondary = NAPI.Util.GetHashKey($"weapon_{secondaryModel}");
|
||||
}
|
||||
if (!uint.TryParse(meleeModel, out uint melee))
|
||||
{
|
||||
if (meleeModel.Contains("mk2") && !meleeModel.Contains("_mk2")) meleeModel = meleeModel.Replace("mk2", "_mk2");
|
||||
melee = NAPI.Util.GetHashKey($"weapon_{meleeModel}");
|
||||
}
|
||||
|
||||
|
||||
client.GiveWeapon(primary, 150);
|
||||
client.GiveWeapon(secondary, 600);
|
||||
client.GiveWeapon(melee, 1);
|
||||
client.GiveWeapon((WeaponHash)primary, 150);
|
||||
client.GiveWeapon((WeaponHash)secondary, 600);
|
||||
client.GiveWeapon((WeaponHash)melee, 1);
|
||||
if(specialModel != "Schutzweste")
|
||||
{
|
||||
WeaponHash special = NAPI.Util.WeaponNameToModel(specialModel);
|
||||
client.GiveWeapon(special, 50);
|
||||
client.Armor = 0;
|
||||
if (!uint.TryParse(specialModel, out uint special))
|
||||
{
|
||||
if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2");
|
||||
special = NAPI.Util.GetHashKey($"weapon_{specialModel}");
|
||||
}
|
||||
client.GiveWeapon((WeaponHash)special, 50);
|
||||
return;
|
||||
}
|
||||
client.Armor = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
dbUser.Wanteds = newWanteds;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
user.Client.SetSharedData("blipColor", 64);
|
||||
ChatService.SendMessage(user.Client, "Du hast ein Verbrechen begangen: " + reason + "." + (cop != null ? " Gemeldet von: " + cop.Name + "." : ""));
|
||||
ChatService.SendMessage(user.Client, "Fahnundgslevel: " + newWanteds);
|
||||
|
||||
|
||||
@@ -402,8 +402,6 @@ namespace ReallifeGamemode.Migrations
|
||||
|
||||
b.Property<int>("slotID");
|
||||
|
||||
b.Property<int>("weaponHash");
|
||||
|
||||
b.Property<string>("weaponModel");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace ReallifeGamemode.Migrations
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
FactionId = table.Column<int>(nullable: false),
|
||||
WeaponHash = table.Column<int>(nullable: false),
|
||||
WeaponModel = table.Column<string>(nullable: true),
|
||||
SlotID = table.Column<int>(nullable: false),
|
||||
Rank = table.Column<int>(nullable: false)
|
||||
|
||||
1234
ReallifeGamemode.Server/Migrations/20190721184931_FactionWeaponsRemovedHash.Designer.cs
generated
Normal file
1234
ReallifeGamemode.Server/Migrations/20190721184931_FactionWeaponsRemovedHash.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace ReallifeGamemode.Migrations
|
||||
{
|
||||
public partial class FactionWeaponsRemovedHash : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "WeaponHash",
|
||||
table: "FactionWeapons");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "WeaponHash",
|
||||
table: "FactionWeapons",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,8 +400,6 @@ namespace ReallifeGamemode.Migrations
|
||||
|
||||
b.Property<int>("SlotID");
|
||||
|
||||
b.Property<int>("WeaponHash");
|
||||
|
||||
b.Property<string>("WeaponModel");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace ReallifeGamemode.Server.Wanted
|
||||
User user = client.GetUser();
|
||||
if (user.JailTime > 0)
|
||||
{
|
||||
client.SetSharedData("blipColor", 4);
|
||||
client.RemoveAllWeapons();
|
||||
client.Health = 100;
|
||||
client.Armor = 0;
|
||||
|
||||
Reference in New Issue
Block a user