за неграмотность прощаю, но я нихуя не понял если честно
[RemoteEvent("server.craft.create")]
public static void Event_WCraft(ExtPlayer player, int frac, int cat, int index)
{
try
{
var memberFractionData = player.GetFractionMemberData();
if (memberFractionData == null)
return;
List<List<string>> list = null;
bool org = false;
if (FractionTypes[frac] == FractionsType.None || FractionTypes[frac] == FractionsType.Gov)
{
if (FractionTypes[frac] == FractionsType.None)
{
var organizationData = player.GetOrganizationData();
if (organizationData != null)
{
org = true;
list = organizationsGuns.ToList();
string familySelected = list[cat][index];
if (!organizationData.Schemes.ContainsKey(familySelected) || !organizationData.Schemes[familySelected])
{
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, LangFunc.GetText(LangType.Ru, DataName.FamilyDoesntSel, familySelected), 3000);
return;
}
}
else
{
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, LangFunc.GetText(LangType.Ru, DataName.CantCraftWeapon), 3000);
return;
}
}
else
{
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, LangFunc.GetText(LangType.Ru, DataName.CantCraftWeapon), 3000);
return;
}
}
else if (FractionTypes[frac] == FractionsType.Gangs) list = gangGuns.ToList();
else if (FractionTypes[frac] == FractionsType.Mafia) list = mafiaGuns.ToList();
else if (FractionTypes[frac] == FractionsType.Nongov) list = nongovGuns.ToList();
else if (FractionTypes[frac] == FractionsType.Bikers) list = bikersGuns.ToList();
if (list.Count < 1 || list.Count < cat + 1 || list[cat].Count < index + 1) return;
ItemStruct mItem = Chars.Repository.isItem(player, "inventory", ItemId.Material);
int count = (mItem == null) ? 0 : mItem.Item.Count;
string selected = list[cat][index];
if (frac == (int) Models.Fractions.PRISON)
{
switch (selected)
{
case "PistolMk2":
case "StunGun":
case "CombatPistol":
if (memberFractionData.Rank <= 1)
{
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"Крафт {selected} для MerryWeather доступен со 2 ранга.", 3000);
return;
}
break;
case "HeavyPistol":
case "Pistol50":
if (memberFractionData.Rank <= 2)
{
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"Крафт {selected} для MerryWeather доступен со 3 ранга.", 3000);
return;
}
break;
case "SMG":
case "CombatPDW":
case "SawnOffShotgun":
if (memberFractionData.Rank <= 3)
{
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"Крафт {selected} для MerryWeather доступен с 4 ранга.", 3000);
return;
}
break;
case "PumpShotgunMk2":
case "BullpupShotgun":
case "AdvancedRifle":
case "CarbineRifle":
case "SMGMk2":
if (memberFractionData.Rank <= 4)
{
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"Крафт {selected} для MerryWeather доступен с 5 ранга.", 3000);
return;
}
break;
case "AssaultRifleMk2":
case "CarbineRifleMk2":
if (memberFractionData.Rank <= 5)
{
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"Крафт {selected} для MerryWeather доступен с 6 ранга.", 3000);
return;
}
break;
case "APPistol":
case "AssaultShotgun":
case "SweeperShotgun":
case "AssaultSMG":
case "BullpupRifle":
if (memberFractionData.Rank <= 7)
{
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, $"Крафт {selected} для MerryWeather доступен с 8 ранга.", 3000);
return;
}
break;
default:
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, LangFunc.GetText(LangType.Ru, DataName.CraftError), 3000);
return;
}
}
if (count < matsForGun[ WeaponRepository.GetHash(selected)])
{
Notify.Send(player, NotifyType.Error, NotifyPosition.BottomCenter, LangFunc.GetText(LangType.Ru, DataName.NoMats), 3000);
return;
}
ItemId wType = (ItemId)Enum.Parse(typeof(ItemId), selected);
if ( WeaponRepository.GiveWeapon(player, wType, WeaponRepository.GetSerial(true, frac, org)) == -1) return;
Chars.Repository.RemoveIndex(player, mItem.Location, mItem.Index, matsForGun[ WeaponRepository.GetHash(selected)]);
Notify.Send(player, NotifyType.Info, NotifyPosition.BottomCenter, $"Вы скрафтили {selected} за {matsForGun[ WeaponRepository.GetHash(selected)]} матов", 3000);
}
catch (Exception e)
{
Log.Write($"Event_WCraft Exception: {e.ToString()}");
}
}