Example #1
0
        public void Remove()
        {
            var ped = API.GetPlayerPed(-1);

            API.SetEnableHandcuffs(ped, false);
            API.DisablePlayerFiring(ped, false);
            API.ClearPedTasksImmediately(ped);

            var decors = new EntityDecorModule()
            {
                Id = ped
            };

            decors.Set("Player.IsHandcuffed", false);
        }
Example #2
0
        public void PutOn()
        {
            var ped = API.GetPlayerPed(-1);

            API.SetEnableHandcuffs(ped, true);
            API.SetCurrentPedWeapon(ped, (uint)API.GetHashKey("WEAPON_UNARMED"), true);
            API.DisablePlayerFiring(ped, true);

            var decors = new EntityDecorModule()
            {
                Id = ped
            };

            decors.Set("Player.IsHandcuffed", true);
        }
Example #3
0
        public static void Join(int session)
        {
            var entity = Cache.Entity;
            var decors = new EntityDecorModule
            {
                Id     = entity.Id,
                Entity = entity
            };

            decors.Set("Session", session);

            Reload(session);

            EventSystem.GetModule().Send("event:global", "session:reload", API.GetPlayerServerId(API.PlayerId()),
                                         session);

            LastSession = session;
        }
Example #4
0
        public override void Begin()
        {
            EventSystem.Attach("session:reload", new EventCallback(metadata =>
            {
                var entity  = API.GetPlayerPed(API.GetPlayerFromServerId(metadata.Find <int>(0)));
                var session = metadata.Find <int>(1);
                var decors  = new EntityDecorModule
                {
                    Id = entity,
                };

                decors.Set("Session", session);

                Session.Reload();

                return(this);
            }));
        }
Example #5
0
        private async Task OnTick()
        {
            var player = Cache.Player;

            if (player?.Entity != null)
            {
                var entity = Cache.Entity;

                if (API.IsPedSittingInAnyVehicle(entity.Id) && Game.IsControlJustPressed(0, Control.InteractionMenu) &&
                    !Game.IsControlPressed(0, Control.Sprint))
                {
                    OpenVehicleMenu();
                }

                if (API.IsPedInAnyVehicle(entity.Id, false))
                {
                    var decors = new EntityDecorModule
                    {
                        Id = API.GetVehiclePedIsIn(entity.Id, false)
                    };

                    if (!SeatShuffle)
                    {
                        if (API.GetPedInVehicleSeat(API.GetVehiclePedIsIn(entity.Id, false), 0) == entity.Id)
                        {
                            if (API.GetIsTaskActive(entity.Id, 165))
                            {
                                API.SetPedIntoVehicle(entity.Id, API.GetVehiclePedIsIn(entity.Id, false), 0);
                            }
                        }
                    }

                    var vehicleOff = decors.GetBoolean("Vehicle.Engine.Off");

                    if (vehicleOff)
                    {
                        API.SetVehicleEngineOn(decors.Id, false, true, false);
                    }
                }
            }

            await Task.FromResult(0);
        }
Example #6
0
        public static void Reload(int session = 0)
        {
            var entity = Cache.Entity;

            if (session == 0)
            {
                var decors = new EntityDecorModule
                {
                    Id     = entity.Id,
                    Entity = entity
                };

                session = decors.GetInteger("Session");
            }

            for (var i = 0; i < AtlasPlugin.MaximumPlayers; i++)
            {
                var ped = API.GetPlayerPed(i);

                if (!API.DoesEntityExist(ped) || ped == API.GetPlayerPed(-1))
                {
                    continue;
                }

                var decors = new EntityDecorModule
                {
                    Id = ped
                };

                Modify(ped, session == decors.GetInteger("Session"));
            }

            var voice = VoiceChat.GetModule();

            voice.Channel = session;
            voice.Commit();
        }
Example #7
0
        private void OpenVehicleMenu()
        {
            new Menu("Fordonsmeny")
            {
                Items = new List <MenuItem>
                {
                    new MenuItem("engine_toggle", "Sätt på/av motor"),
                    new MenuItem("swap_seats", "Ändra säte"),
                    new MenuItem("doors", "Dörrar"),
                    new MenuItem("windows", "Veva upp/ner rutor")
                },
                Callback = async(menu, item, operation) =>
                {
                    var entity = Cache.Entity;

                    if (operation.Type != MenuOperationType.Select)
                    {
                        return;
                    }
                    if (!API.IsPedSittingInAnyVehicle(entity.Id))
                    {
                        return;
                    }

                    var vehicleId = API.GetVehiclePedIsIn(entity.Id, false);
                    var decors    = new EntityDecorModule
                    {
                        Id = vehicleId
                    };

                    if (item.Seed == "windows")
                    {
                        var windowIndex = 0;

                        for (var i = 0; i < 3; i++)
                        {
                            if (API.GetPedInVehicleSeat(vehicleId, i) != entity.Id)
                            {
                                continue;
                            }

                            windowIndex = i;

                            break;
                        }

                        var rolledDown = decors.GetBoolean("Vehicle.Windows.RolledDown");

                        if (!rolledDown)
                        {
                            API.RollDownWindow(vehicleId, windowIndex);
                        }
                        else
                        {
                            API.RollUpWindow(vehicleId, windowIndex);
                        }

                        decors.Set("Vehicle.Windows.RolledDown", !rolledDown);
                    }
                    else if (item.Seed == "swap_seats")
                    {
                        SeatShuffle = true;

                        await BaseScript.Delay(5000);

                        SeatShuffle = false;
                    }
                    else if (item.Seed == "engine_toggle")
                    {
                        var toggle = !API.IsVehicleEngineOn(vehicleId);

                        API.SetVehicleEngineOn(vehicleId, toggle, false, false);

                        decors.Set("Vehicle.Engine.Off", !toggle);
                    }
                    else if (item.Seed == "doors")
                    {
                        menu.Hide();

                        OpenDoorMenu(vehicleId);
                    }
                }
            }.Commit();
        }
Example #8
0
        private void OpenInteractionMenu()
        {
            new Menu($"{Label} | Interaktionsmeny")
            {
                Items = new List <MenuItem>
                {
                    new MenuItem("handcuff", "Sätt på handbojor"),
                    new MenuItem("remove_handcuffs", "Ta bort handbojor"),
                    new MenuItem("drag", "Dra närmsta person"),
                    new MenuItem("bill", "Skriv en böter")
                },
                Callback = (menu, item, operation) =>
                {
                    if (operation.Type != MenuOperationType.Select)
                    {
                        return;
                    }

                    if (item.Seed == "handcuff")
                    {
                        var player = GetClosestPlayer(1.5f, self =>
                        {
                            var decors = new EntityDecorModule
                            {
                                Id = API.GetPlayerPed(self)
                            };

                            return(!decors.GetBoolean("Player.IsHandcuffed"));
                        });

                        if (player != -1)
                        {
                            var user = new AtlasUser
                            {
                                Handle = API.GetPlayerServerId(player)
                            };

                            user.Send("handcuff:toggle", true);
                        }
                        else
                        {
                            Cache.Player.ShowNotification("Det finns ingen i närheten som du kan handboja!");
                        }
                    }
                    else if (item.Seed == "remove_handcuffs")
                    {
                        var player = GetClosestPlayer(1.5f, self =>
                        {
                            var decors = new EntityDecorModule
                            {
                                Id = API.GetPlayerPed(self)
                            };

                            return(decors.GetBoolean("Player.IsHandcuffed"));
                        });

                        if (player != -1)
                        {
                            var user = new AtlasUser
                            {
                                Handle = API.GetPlayerServerId(player)
                            };

                            user.Send("handcuff:toggle", false);
                        }
                        else
                        {
                            Cache.Player.ShowNotification("Det finns ingen i närheten som har handbojor på sig!");
                        }
                    }
                    else if (item.Seed == "drag")
                    {
                        var player = GetClosestPlayer(2f, self =>
                        {
                            var decors = new EntityDecorModule
                            {
                                Id = API.GetPlayerPed(self)
                            };

                            return(decors.GetBoolean("Player.IsHandcuffed"));
                        });

                        if (player != -1)
                        {
                            var user = new AtlasUser
                            {
                                Handle = API.GetPlayerServerId(player)
                            };

                            user.Send("handcuff:drag:toggle", API.GetPlayerServerId(API.PlayerId()));
                        }
                        else
                        {
                            Cache.Player.ShowNotification("Det finns ingen i närheten som har handbojor på sig!");
                        }
                    }
                    else if (item.Seed == "bill")
                    {
                        var character = Cache.Character;

                        BillingManager.GetModule().CreateBill(new BillSender
                        {
                            Business   = Label,
                            Individual = character.Fullname
                        }, new BillReceiver
                        {
                            Type = BillReceiverType.Individual,
                            Name = ""
                        });
                    }
                }
            }.Commit();
        }