private void onMarkerEnter(ColShape colshape, NetHandle entity) { if (colshape.hasData(Constants.MarkerClass)) { MarkerInfo mInfo = colshape.getData(Constants.MarkerClass); Client player; int type = (int)API.getEntityType(entity); if (type == 6) { player = API.getPlayerFromHandle(entity); } else { return; } if (mInfo.local && mInfo.player != player) { return; } if (mInfo.Job == Jobs.JOB_JOBGRYZ_ONE) { if (mInfo.HasData("JobGryzAction")) { Box myBox; switch ((int)mInfo.GetData("JobGryzAction")) { case 1: var BoxTypes = GryzBoxes.Where(i => i.Player == null).GroupBy(d => d.Type).Select(y => y.First()).Distinct().ToList(); // Смотрим какие типы ящиков остались if (BoxTypes.Count == 0) { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~В данный момент товар для отгрузки отсутсвует."); return; } var rnd = new Random(); int BoxType = BoxTypes[rnd.Next(0, BoxTypes.Count)].Type; // Выбираем тип груза и склада куда его отнести myBox = GryzBoxes.Where(i => i.Type == BoxType && i.Player == null).FirstOrDefault(); // Ищем ящик который ни кому не принадлежит if (myBox != null) { myBox.Player = player; PlayerInfo pInfo = API.getEntityData(player.handle, Constants.PlayerAccount); pInfo.FreezePlayer(); API.playPlayerAnimation(player, (int)(AnimationFlags.StopOnLastFrame | AnimationFlags.OnlyAnimateUpperBody | AnimationFlags.AllowPlayerControl), "anim@heists@load_box", "lift_box"); lifeRP_GM.mainClass.Stream(1500, () => { NetHandle BoxObject = myBox.Object; API.attachEntityToEntity(BoxObject, player, "60309", new Vector3(), new Vector3(-70, 2, 0)); API.sendChatMessageToPlayer(player, string.Format("~y~[Server] ~b~Отнесите ящик на {0}-й склад", BoxType)); pInfo.UnFreezePlayer(); }); #region "Маркеры складов" switch (BoxType) { case 1: MarkerInfo minfo1 = new MarkerInfo(player, 0, new Vector3(-772.8375f, -2605.233f, 13.45), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 0, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo1.SetData("JobGryzAction", 0); //склад 1 minfo1.SetData("JobGryzSklad", 1); break; case 2: MarkerInfo minfo2 = new MarkerInfo(player, 0, new Vector3(-770.2049, -2600.777, 13.28), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 0, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo2.SetData("JobGryzAction", 0); //склад 2 minfo2.SetData("JobGryzSklad", 2); break; case 3: MarkerInfo minfo3 = new MarkerInfo(player, 0, new Vector3(-767.5933, -2596.403, 13.28), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 0, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo3.SetData("JobGryzAction", 0); //склад 3 minfo3.SetData("JobGryzSklad", 3); break; case 4: MarkerInfo minfo4 = new MarkerInfo(player, 0, new Vector3(-764.9606, -2592.063, 13.28), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 0, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo4.SetData("JobGryzAction", 0); //склад 4 minfo4.SetData("JobGryzSklad", 4); break; case 5: MarkerInfo minfo5 = new MarkerInfo(player, 0, new Vector3(-762.4879, -2587.585, 13.28), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 0, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo5.SetData("JobGryzAction", 0); //склад 5 minfo5.SetData("JobGryzSklad", 5); break; case 6: MarkerInfo minfo6 = new MarkerInfo(player, 0, new Vector3(-759.9476, -2583.071, 13.28), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 0, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo6.SetData("JobGryzAction", 0); //склад 6 minfo6.SetData("JobGryzSklad", 6); break; case 7: MarkerInfo minfo7 = new MarkerInfo(player, 0, new Vector3(-757.3046, -2578.625, 13.28), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 0, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo7.SetData("JobGryzAction", 0); //склад 7 minfo7.SetData("JobGryzSklad", 7); break; case 8: MarkerInfo minfo8 = new MarkerInfo(player, 0, new Vector3(-754.7167, -2574.311, 13.28), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 0, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo8.SetData("JobGryzAction", 0); //склад 8 minfo8.SetData("JobGryzSklad", 8); break; case 9: MarkerInfo minfo9 = new MarkerInfo(player, 0, new Vector3(-752.1079, -2569.722, 13.28), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 0, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo9.SetData("JobGryzAction", 0); //склад 9 minfo9.SetData("JobGryzSklad", 9); break; case 10: MarkerInfo minfo10 = new MarkerInfo(player, 0, new Vector3(-749.6968, -2565.644, 13.28), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 0, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo10.SetData("JobGryzAction", 0); //склад 10 minfo10.SetData("JobGryzSklad", 10); break; } #endregion } else { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~В данный момент товар для отгрузки отсутсвует."); } break; case 0: if (mInfo.HasData("JobGryzSklad")) { myBox = GryzBoxes.Where(i => i.Player == player).FirstOrDefault(); if (myBox != null) { if ((int)mInfo.GetData("JobGryzSklad") == myBox.Type) { MarkerInfo minfo10 = new MarkerInfo(player, 1, new Vector3(-774.0269, -2653.793, 12.83), new Vector3(), new Vector3(), new Vector3(1f, 1f, 1), 100, 255, 255, 0, 1, 1, Jobs.JOB_JOBGRYZ_ONE); minfo10.SetData("JobGryzAction", 1); API.playPlayerAnimation(player, (int)(AnimationFlags.OnlyAnimateUpperBody | AnimationFlags.AllowPlayerControl), "anim@heists@load_box", "load_box_2"); PlayerInfo pInfo = API.getEntityData(player.handle, Constants.PlayerAccount); pInfo.FreezePlayer(); lifeRP_GM.mainClass.Stream(1600, () => { API.detachEntity(myBox.Object); API.setEntityPosition(myBox.Object, new Vector3(55.31, -1259.78, -10.0)); API.deleteEntity(myBox.Object); GryzBoxes.Remove(myBox); API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Вы положили ящик на склад"); pInfo.UnFreezePlayer(); API.stopPlayerAnimation(player); pInfo.jobMoney = pInfo.jobMoney + Money; }); } } } break; } } else if (mInfo.HasData("JobGryzZone")) { // Работник в зоне, не трогаем, пусть работает. } else { API.triggerClientEvent(player, "JobGryzStart"); } } } else { API.deleteColShape(colshape); } }
/// <summary> /// Выход из маркера /// </summary> private void onMarkerExit(ColShape colshape, NetHandle entity) { if (colshape.hasData(Constants.MarkerClass)) { MarkerInfo mInfo = colshape.getData(Constants.MarkerClass); Client player; int type = (int)API.getEntityType(entity); if (type == 6) { player = API.getPlayerFromHandle(entity); } else { return; } if (mInfo.local && mInfo.player != player) { return; } if (mInfo.Job == Jobs.JOB_JOBGRYZ_ONE) { if (mInfo.HasData("JobGryzAction")) { switch ((int)mInfo.GetData("JobGryzAction")) { case 0: mInfo.DeleteMarker(); break; case 1: mInfo.DeleteMarker(); break; } } else if (mInfo.HasData("JobGryzZone")) // Работник пытается украсть ящик. { PlayerInfo pInfo = API.getEntityData(player.handle, Constants.PlayerAccount); if (pInfo.Job == (int)Jobs.JOB_JOBGRYZ_ONE) { pInfo.Job = (int)Jobs.NULL; API.sendNativeToPlayer(player, Hash.DO_SCREEN_FADE_OUT, 200); API.delay(200, true, () => { var myBox = GryzBoxes.Where(i => i.Player == player).FirstOrDefault(); if (myBox != null) { //Удаляем украденный ящик API.detachEntity(myBox.Object); API.setEntityPosition(myBox.Object, new Vector3(55.31, -1259.78, -10.0)); API.deleteEntity(myBox.Object); GryzBoxes.Remove(myBox); API.stopPlayerAnimation(player); API.sendChatMessageToPlayer(player, "~y~[Server] ~r~Вы пытались украсть груз."); API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Ваш рабочий день окончен."); API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Вы ни чего не получите за работу."); API.clearPlayerAccessory(player, 0); // удаляем аксесуары с головы pInfo.UpdateDress(); // меняем одежду на пользовательскую pInfo.jobMoney = 0; } else { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Вы покинули зону. Ваш рабочий день окончен."); API.clearPlayerAccessory(player, 0); // удаляем аксесуары с головы pInfo.UpdateDress(); // меняем одежду на пользовательскую pInfo.money = pInfo.money + pInfo.jobMoney; pInfo.jobMoney = 0; pInfo.UpdateBD(); } var Markers = pInfo.playerEntity.Where(x => x.Key == Constants.Marker); // Удаляем все пользовательские маркеры связанные с работой foreach (var Marker in Markers.ToArray()) { MarkerInfo bi = Marker.Value; if (bi.Job == Jobs.JOB_JOBGRYZ_ONE) { bi.DeleteMarker(); } } var Blips = pInfo.playerEntity.Where(x => x.Key == Constants.Blip); // Удаляем все пользовательские блипы связанные с работой foreach (var Blip in Blips.ToArray()) { BlipInfo bi = Blip.Value; if (bi.Job == Jobs.JOB_JOBGRYZ_ONE) { bi.DeleteBlip(); } } API.sendNativeToPlayer(player, Hash.DO_SCREEN_FADE_IN, 750); }); } } else { API.triggerClientEvent(player, "JobGryzOff"); } } } else { API.deleteColShape(colshape); } }
private void onMarkerEnter(ColShape colshape, NetHandle entity) { if (colshape.hasData(Constants.MarkerClass)) { MarkerInfo mInfo = colshape.getData(Constants.MarkerClass); Client player; int type = (int)API.getEntityType(entity); if (type == 6) { player = API.getPlayerFromHandle(entity); } else { return; } if (mInfo.local && mInfo.player != player) { return; } PlayerInfo pInfo = API.getEntityData(player.handle, Constants.PlayerAccount); if (mInfo.HasData("JOB_IMMIGRANT_SEARCH")) { var percent = ((pInfo.Bottles * 0.1 + pInfo.Paper + pInfo.Cabel) / 40) * 100; if (percent > 100) { API.sendChatMessageToPlayer(player, "~y~[Server] ~r~Рюкзак переполнен!"); API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Сдайте ваш инвентарь на завод!"); return; } API.setEntityRotation(player, new Vector3(0, 0, -90)); API.playPlayerAnimation(player, 0, "timetable@maid@cleaning_surface@idle_a", "idle_a"); byte bottles = (byte)SuperRandom.Next(1, 5); pInfo.Bottles += bottles; byte paper = (byte)SuperRandom.Next(0, 3); pInfo.Paper += paper; byte cabel = (byte)SuperRandom.Next(0, 3); pInfo.Cabel += cabel; lifeRP_GM.mainClass.Stream(4500, () => { API.triggerClientEvent(player, "SEND_BOMJ_DATA", pInfo.Bottles.ToString(), pInfo.Paper.ToString(), pInfo.Cabel.ToString()); API.sendChatMessageToPlayer(API.getPlayerFromHandle(entity), string.Format("~y~Вы нашли:\r\nБутылок - {0} шт.!\r\nБумаги - {1} кг.!\r\nЦветного металла - {2} кг.!", bottles, paper, cabel)); }); var binfo = mInfo.GetData("JOB_IMMIGRANT_SEARCH"); mInfo.DeleteMarker(); if (binfo != null) { binfo.DeleteBlip(); } } else if (mInfo.HasData("JOB_IMMIGRANT_CVETMET")) { if (pInfo.Job == (int)Jobs.NULL) { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~У вас нету рюкзака для продажи."); } else if (pInfo.Job == (int)Jobs.JOB_IMMIGRANT) { if (pInfo.Cabel != 0) { int CabelMoney = pInfo.Cabel * CabelCost; pInfo.money += CabelMoney; pInfo.Cabel = 0; pInfo.UpdateBD(); API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Вы продали цветной металл на: ~r~$" + CabelMoney.ToString()); API.triggerClientEvent(player, "SEND_BOMJ_DATA", pInfo.Bottles.ToString(), pInfo.Paper.ToString(), pInfo.Cabel.ToString()); if (pInfo.Bottles == 0 && pInfo.Cabel == 0 && pInfo.Paper == 0) { JobImmigrantYval(player); } } else { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~У вас нету цвет. металла!"); } } else { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Сначала завершите старую работу."); } return; } else if (mInfo.HasData("JOB_IMMIGRANT_STEKLO")) { if (pInfo.Job == (int)Jobs.NULL) { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~У вас нету рюкзака для продажи."); } else if (pInfo.Job == (int)Jobs.JOB_IMMIGRANT) { if (pInfo.Bottles != 0) { int BottlesMoney = pInfo.Bottles * BottleCost; pInfo.money += BottlesMoney; pInfo.Bottles = 0; pInfo.UpdateBD(); API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Вы продали бутылки на: ~r~$" + BottlesMoney.ToString()); API.triggerClientEvent(player, "SEND_BOMJ_DATA", pInfo.Bottles.ToString(), pInfo.Paper.ToString(), pInfo.Cabel.ToString()); if (pInfo.Bottles == 0 && pInfo.Cabel == 0 && pInfo.Paper == 0) { JobImmigrantYval(player); } } else { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~У вас нету бутылок!"); } } else { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Сначала завершите старую работу."); } return; } else if (mInfo.HasData("JOB_IMMIGRANT_BUMAGA")) { if (pInfo.Job == (int)Jobs.NULL) { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~У вас нету рюкзака для продажи."); } else if (pInfo.Job == (int)Jobs.JOB_IMMIGRANT) { if (pInfo.Paper != 0) { int PaperMoney = pInfo.Paper * PaperCost; pInfo.money += PaperMoney; pInfo.Paper = 0; pInfo.UpdateBD(); API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Вы продали бумагу на: ~r~$" + PaperMoney.ToString()); API.triggerClientEvent(player, "SEND_BOMJ_DATA", pInfo.Bottles.ToString(), pInfo.Paper.ToString(), pInfo.Cabel.ToString()); if (pInfo.Bottles == 0 && pInfo.Cabel == 0 && pInfo.Paper == 0) { JobImmigrantYval(player); } } else { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~У вас нету бумаги!"); } } else { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Сначала завершите старую работу."); } return; } else if (mInfo.HasData("JOB_IMMIGRANT")) { if (pInfo.Job == (int)Jobs.NULL) { for (byte i = 0; i < TrashCoords.Length; i++) { var mark = new MarkerInfo(player, 1, new Vector3(TrashCoords[i].X, TrashCoords[i].Y, TrashCoords[i].Z), new Vector3(1, 1, 1), new Vector3(35.5, 1, 1), new Vector3(1.5, 1.5, 1), 100, 236, 147, 89, 1, 1, Jobs.JOB_IMMIGRANT); var blip = new BlipInfo(player, new Vector3(TrashCoords[i].X, TrashCoords[i].Y, TrashCoords[i].Z), 1, 17, true, 0, "Мусорный ящик", Jobs.JOB_IMMIGRANT); mark.SetData("JOB_IMMIGRANT_SEARCH", blip); } new MarkerInfo(player, 1, new Vector3(1083.46, -1974.33, 30.0165), new Vector3(1, 1, 1), new Vector3(35.5, 1, 1), new Vector3(1.5, 1.5, 2), 100, 236, 147, 89, 1, 2, Jobs.JOB_IMMIGRANT).SetData("JOB_IMMIGRANT_CVETMET", 1); new MarkerInfo(player, 1, new Vector3(1137.99, -2046.25, 30.0165), new Vector3(1, 1, 1), new Vector3(35.5, 1, 1), new Vector3(1.5, 1.5, 2), 100, 236, 147, 89, 1, 2, Jobs.JOB_IMMIGRANT).SetData("JOB_IMMIGRANT_STEKLO", 1); new MarkerInfo(player, 1, new Vector3(1070.04, -1971.78, 30.0321), new Vector3(1, 1, 1), new Vector3(35.5, 1, 1), new Vector3(1.5, 1.5, 2), 100, 236, 147, 89, 1, 2, Jobs.JOB_IMMIGRANT).SetData("JOB_IMMIGRANT_BUMAGA", 1); new BlipInfo(player, new Vector3(1083.46, -1974.33, 30.0165), 440, 17, true, 0, "Пункт приема цветного металла", Jobs.JOB_IMMIGRANT); new BlipInfo(player, new Vector3(1137.99, -2046.25, 30.0165), 440, 17, true, 0, "Пункт приема стеклотары", Jobs.JOB_IMMIGRANT); new BlipInfo(player, new Vector3(1070.04, -1971.78, 30.0321), 440, 17, true, 0, "Пункт приема бумаги", Jobs.JOB_IMMIGRANT); new TLabelInfo(player, "Пункт приема цветного металла", new Vector3(1083.46, -1974.33, 31.0165), 25, 1, false, 0, Jobs.JOB_IMMIGRANT); new TLabelInfo(player, "Пункт приема стеклотары", new Vector3(1137.99, -2046.25, 31.0165), 25, 1, false, 0, Jobs.JOB_IMMIGRANT); new TLabelInfo(player, "Пункт приема бумаги", new Vector3(1070.04, -1971.78, 31.0321), 25, 1, false, 0, Jobs.JOB_IMMIGRANT); pInfo.PISUN = API.createObject(-2137120552, new Vector3(806.8278, -809.9581, 25.2029), new Vector3(0, 0, 0)); API.sendChatMessageToPlayer(player, "~y~[Server] ~g~Вы устроились на работу."); pInfo.Job = (int)Jobs.JOB_IMMIGRANT; API.attachEntityToEntity(pInfo.PISUN, player.handle, "SKEL_Spine2", new Vector3(0.15, -0.25, 0), new Vector3(-180, -90, -180)); new ServerWayPoint().CreateWayPoint(player, 1073, -1965); pInfo.Bottles += 1; pInfo.Paper += 1; pInfo.Cabel += 1; API.playPlayerAnimation(player, 0, "timetable@maid@cleaning_surface@idle_a", "idle_a"); API.triggerClientEvent(player, "OPEN_TEST_BAG"); lifeRP_GM.mainClass.Stream(4500, () => { API.sendChatMessageToPlayer(player, string.Format("~y~Вы нашли:\r\nБутылок - {0} шт.!\r\nБумаги - {1} кг.!\r\nЦветного металла - {2} кг.!", 1, 1, 1)); API.triggerClientEvent(player, "SEND_BOMJ_DATA", pInfo.Bottles.ToString(), pInfo.Paper.ToString(), pInfo.Cabel.ToString()); }); } else if (pInfo.Job == (int)Jobs.JOB_IMMIGRANT) { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Сдайте ваш инвентарь на завод!"); } else { API.sendChatMessageToPlayer(player, "~y~[Server] ~b~Сначала завершите старую работу."); } return; } } }