fix unknown weapon names (mk 2 weapons)
This commit is contained in:
@@ -110,6 +110,14 @@ namespace ReallifeGamemode.Server.Commands
|
||||
SaveManager.SaveAllOnSave();
|
||||
}
|
||||
|
||||
[Command("hash")]
|
||||
public void CmdHash(Client player, string toHash)
|
||||
{
|
||||
string msg = $"{toHash} => {NAPI.Util.GetHashKey(toHash)}";
|
||||
NAPI.Util.ConsoleOutput(msg);
|
||||
player.SendChatMessage(msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Support
|
||||
[Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)]
|
||||
@@ -989,7 +997,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
|
||||
[Command("giveweapon", "~m~Benutzung: ~s~/giveweapon [Spieler] [Waffe] [Munition]")]
|
||||
public void CmdAdminGiveweapon(Client player, string name, string weapon, int ammo)
|
||||
public void CmdAdminGiveweapon(Client player, string name, string hash, int ammo)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true)
|
||||
{
|
||||
@@ -1003,6 +1011,8 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
hash = hash.ToLower();
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(name);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
@@ -1010,17 +1020,23 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
WeaponHash wHash = NAPI.Util.WeaponNameToModel(weapon);
|
||||
if (!uint.TryParse(hash, out uint uHash))
|
||||
{
|
||||
if (hash.Contains("mk2") && !hash.Contains("_mk2")) hash = hash.Replace("mk2", "_mk2");
|
||||
uHash = NAPI.Util.GetHashKey($"weapon_{hash}");
|
||||
}
|
||||
|
||||
if (wHash == default)
|
||||
if(!WeaponManager.IsValidHash(uHash))
|
||||
{
|
||||
ChatService.Error(player, "Diese Waffe existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
target.GiveWeapon(wHash, ammo);
|
||||
target.SendChatMessage("~b~Du hast von " + player.Name + " eine/n " + wHash + " mit einer Munition von " + ammo + " erhalten.");
|
||||
player.SendChatMessage("~b~Du hast " + target.Name + " eine/n " + wHash + " mit einer Munition von " + ammo + " gegeben.");
|
||||
WeaponHash weaponHash = (WeaponHash)uHash;
|
||||
|
||||
target.GiveWeapon((WeaponHash)uHash, ammo);
|
||||
target.SendChatMessage("~b~Du hast von " + player.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " erhalten.");
|
||||
player.SendChatMessage("~b~Du hast " + target.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " gegeben.");
|
||||
}
|
||||
|
||||
[Command("arevive", "~m~Benutzung: ~s~/arevive [Spieler]")]
|
||||
@@ -1405,20 +1421,28 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
WeaponHash wHash = NAPI.Util.WeaponNameToModel(weapon);
|
||||
weapon = weapon.ToLower();
|
||||
|
||||
if (wHash == default)
|
||||
if (!uint.TryParse(weapon, out uint uHash))
|
||||
{
|
||||
if (weapon.Contains("mk2") && !weapon.Contains("_mk2")) weapon = weapon.Replace("mk2", "_mk2");
|
||||
uHash = NAPI.Util.GetHashKey($"weapon_{weapon}");
|
||||
}
|
||||
|
||||
if (!WeaponManager.IsValidHash(uHash))
|
||||
{
|
||||
ChatService.Error(player, "Diese Waffe existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
WeaponHash weaponHash = (WeaponHash)uHash;
|
||||
|
||||
var peopleInRange = NAPI.Player.GetPlayersInRadiusOfPlayer(radius, player);
|
||||
|
||||
foreach (var managedClient in peopleInRange)
|
||||
{
|
||||
if (!managedClient.IsLoggedIn()) return;
|
||||
managedClient.GiveWeapon(wHash, munition);
|
||||
managedClient.GiveWeapon(weaponHash, munition);
|
||||
managedClient.SendChatMessage("~b~Admin " + player.Name + " hat im Radius von " + radius + " eine/n " + weapon + " mit " + munition + " Munition vergeben.");
|
||||
}
|
||||
player.SendChatMessage("~b~Du hast " + peopleInRange.Count + " Spielern eine " + weapon + " mit " + munition + " Munition gegeben");
|
||||
|
||||
Reference in New Issue
Block a user