[+] Weapon-Deal System
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
@@ -63,10 +68,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
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)primary, 50);
|
||||
client.GiveWeapon((WeaponHash)secondary, 150);
|
||||
client.GiveWeapon((WeaponHash)melee, 1);
|
||||
if(specialModel != "Schutzweste")
|
||||
{
|
||||
@@ -77,9 +82,29 @@ namespace ReallifeGamemode.Server.Events
|
||||
special = NAPI.Util.GetHashKey($"weapon_{specialModel}");
|
||||
}
|
||||
client.GiveWeapon((WeaponHash)special, 50);
|
||||
return;
|
||||
}
|
||||
client.Armor = 100;
|
||||
else
|
||||
{
|
||||
client.Armor = 50;
|
||||
}
|
||||
|
||||
using(var context = new DatabaseContext())
|
||||
{
|
||||
User user = client.GetUser();
|
||||
FactionWeapon slot1 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == primaryModel).FirstOrDefault();
|
||||
if (slot1 != null)
|
||||
slot1.Ammount -= 1;
|
||||
FactionWeapon slot2 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == secondaryModel).FirstOrDefault();
|
||||
if (slot2 != null)
|
||||
slot2.Ammount -= 1;
|
||||
FactionWeapon slot3 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == meleeModel).FirstOrDefault();
|
||||
if (slot3 != null)
|
||||
slot3.Ammount -= 1;
|
||||
FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault();
|
||||
if (slot4 != null)
|
||||
slot4.Ammount -= 1;
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user