コード例 #1
0
        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;
                }
            }
        }