86 lines
2.6 KiB
C#
86 lines
2.6 KiB
C#
using GTANetworkAPI;
|
|
|
|
namespace ReallifeGamemode.Server.Events
|
|
{
|
|
public class UpdateCharacterWeapon : Script
|
|
{
|
|
[RemoteEvent("updateWeaponSelection")]
|
|
public void UpdateWeaponSelection(Client client, string weaponModel, int slot)
|
|
{
|
|
if(weaponModel == "Keine")
|
|
{
|
|
client.RemoveAllWeapons();
|
|
return;
|
|
}
|
|
|
|
WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(weaponModel);
|
|
|
|
if (slot == 1)
|
|
{
|
|
client.RemoveAllWeapons();
|
|
client.GiveWeapon(weaponHash, 0);
|
|
}
|
|
if (slot == 2)
|
|
{
|
|
client.RemoveAllWeapons();
|
|
client.GiveWeapon(weaponHash, 0);
|
|
}
|
|
if (slot == 3)
|
|
{
|
|
client.RemoveAllWeapons();
|
|
client.GiveWeapon(weaponHash, 0);
|
|
}
|
|
if (slot == 4)
|
|
{
|
|
client.RemoveAllWeapons();
|
|
client.GiveWeapon(weaponHash, 0);
|
|
}
|
|
}
|
|
|
|
[RemoteEvent("cancelWeaponSelection")]
|
|
public void CancelWeaponSelection(Client client)
|
|
{
|
|
client.RemoveAllWeapons();
|
|
}
|
|
|
|
|
|
[RemoteEvent("saveWeaponSelection")]
|
|
public void SaveWeaponSelection(Client client, string primaryModel, string secondaryModel, string meleeModel, string specialModel)
|
|
{
|
|
client.RemoveAllWeapons();
|
|
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((WeaponHash)primary, 150);
|
|
client.GiveWeapon((WeaponHash)secondary, 600);
|
|
client.GiveWeapon((WeaponHash)melee, 1);
|
|
if(specialModel != "Schutzweste")
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|