private void UpdateMoneyDecor() { if (Game.PlayerPed != null) { EntityDecoration.Set(Game.PlayerPed, PNAME_MONEY, MONEY); } }
public SpawnerHost() { IsHost = false; EntityDecoration.RegisterProperty(SPAWN_DESPAWN_DECOR, DecorationType.Bool); Tick += OnTick; }
static VehicleExtensions() { EntityDecoration.RegisterProperty(Decorator_SpotlightIsOn, DecorationType.Bool); EntityDecoration.RegisterProperty(Decorator_SpotlightDirX, DecorationType.Float); EntityDecoration.RegisterProperty(Decorator_SpotlightDirY, DecorationType.Float); EntityDecoration.RegisterProperty(Decorator_SpotlightDirZ, DecorationType.Float); }
private void UpdateLevelDecor() { if (Game.PlayerPed != null) { EntityDecoration.Set(Game.PlayerPed, PNAME_LEVEL, LVL); } }
public ZombieSpawner() { zombies = new List <Ped>(); ZombieGroup = World.AddRelationshipGroup("zombies"); EntityDecoration.RegisterProperty(ZOMBIE_DECOR, DecorationType.Bool); Tick += OnTick; }
public OrganizationsHolder() { EntityDecoration.RegisterProperty(Decors.ORGANIZATION_TYPE, DecorationType.Int); EntityDecoration.RegisterProperty(Decors.ORGANIZATION_CEO, DecorationType.Bool); Tick += OnTick; Tick += OnScaleformTick; }
public RandomLockedCars(Client client) : base(client) { client.RegisterEventHandler("baseevents:enteringVehicle", new Action <int, int, string>((veh, seat, name) => { AttemptEnterVehicle(new Vehicle(veh)); })); EntityDecoration.RegisterProperty("Vehicle.RobAttempts", DecorationType.Int); EntityDecoration.RegisterProperty("Vehicle.HasBeenAlerted", DecorationType.Bool); }
public Money() { MONEY = Storage.GetInt(Storage.MONEY); EventHandlers[Events.MONEY_ADD] += new Action <int>(AddMoney); EventHandlers[Events.MONEY_REMOVE] += new Action <int>(RemoveMoney); EventHandlers[Events.DISPLAY_DRAW] += new Action <bool>(draw => drawText = draw); EntityDecoration.RegisterProperty(PNAME_MONEY, DecorationType.Int); Tick += OnTick; }
public static int GetPlayerMoney(Player player) { Ped playerPed = player.Character; if (playerPed == null || !EntityDecoration.ExistOn(playerPed, PNAME_MONEY)) { return(0); } else { return(EntityDecoration.Get <int>(playerPed, PNAME_MONEY)); } }
public Level() { XP = Storage.GetInt(Storage.XP); if (XP == 0) { XP = 1; } LVL = (int)Math.Ceiling((double)XP / 50); EventHandlers[Events.XP_ADD] += new Action <int>(AddXP); EventHandlers[Events.DISPLAY_DRAW] += new Action <bool>(draw => drawText = draw); EntityDecoration.RegisterProperty(PNAME_LEVEL, DecorationType.Int); Tick += OnTick; }
public SeatbeltHandler(Client client) : base(client) { EntityDecoration.RegisterProperty("seatbeltEject", DecorationType.Bool); EntityDecoration.RegisterProperty("ejectSpeed", DecorationType.Float); client.RegisterEventHandler("baseevents:enteringVehicle", new Action <int, int, string>((veh, seat, name) => { new CitizenFX.Core.Vehicle(veh).SetDecor("seatbeltEject", false); })); client.RegisterEventHandler("baseevents:enteredVehicle", new Action <int, int, string>((veh, seat, name) => { client.RegisterTickHandler(OnTick); client.RegisterTickHandler(CrashCheckTick); })); client.RegisterEventHandler("baseevents:leftVehicle", new Action <int, int, string>((veh, seat, name) => { hasSeatbeltOn = false; client.DeregisterTickHandler(OnTick); client.DeregisterTickHandler(CrashCheckTick); })); }
public VehicleHandler(Client client) : base(client) { client.RegisterEventHandler("Vehicle.SetBoughtVehID", new Action <int>(SetBoughtVehId)); client.RegisterEventHandler("Vehicle.SpawnGarageVehicle", new Action <string, int, string>(OnSpawnRequest)); client.RegisterEventHandler("Vehicle.ReceiveExternalVehID", new Action <int>(SetVehicleVehId)); client.RegisterTickHandler(SaveVehicleTick); EntityDecoration.RegisterProperty("Vehicle.ID", DecorationType.Int); /*CommandRegister.RegisterCommand("testadd", cmd => * { * var closeVeh = GTAHelpers.GetClosestVehicle(); * Magicallity.Client.Client.Instance.TriggerServerEvent("Vehicle.CreateExternalVehicle", VehicleDataPacker.PackVehicleData(closeVeh)); * }); * CommandRegister.RegisterCommand("getvehid", cmd => * { * Log.ToChat(GTAHelpers.GetClosestVehicle().GetDecor<int>("Vehicle.ID").ToString()); * });*/ CommandRegister.RegisterCommand("givekeys", OnGiveKeysCommand); CommandRegister.RegisterCommand("giveveh|givevehicle", OnGiveVehCommand); }
private async Task OnTick() { Ped playerPed; Vehicle veh; if ((playerPed = LocalPlayer.Character) != null && (veh = playerPed.CurrentVehicle) != null) { if (!EntityDecoration.HasDecor(veh, VEH_FUEL_DECOR)) { veh.FuelLevel = Utils.GetRandomFloat(VEH_FUEL_MAX); EntityDecoration.Set(veh, VEH_FUEL_DECOR, veh.FuelLevel); } else { if (veh.GetPedOnSeat(VehicleSeat.Driver) == playerPed && !veh.IsInAir) { float newFuelLevel = EntityDecoration.Get <float>(veh, VEH_FUEL_DECOR) - veh.Speed * 0.01f; if (newFuelLevel < 0f) { newFuelLevel = 0f; } EntityDecoration.Set(veh, VEH_FUEL_DECOR, newFuelLevel); } veh.FuelLevel = EntityDecoration.Get <float>(veh, VEH_FUEL_DECOR); if (veh.FuelLevel == 0f) { Screen.DisplayHelpTextThisFrame("No Fuel left"); } else if (veh.FuelLevel < VEH_FUEL_WARNING_THRESHOLD) { Screen.DisplayHelpTextThisFrame("Low Fuel Level"); } } } await Task.FromResult(0); }
public FuelManager(Client client) : base(client) { EntityDecoration.RegisterProperty("Vehicle.Fuel", DecorationType.Float); client.RegisterEventHandler("baseevents:enteredVehicle", new Action <int, int, string>(async(veh, seat, name) => { var vehicle = Cache.PlayerPed.CurrentVehicle; vehicleFuel = -1; if (vehicle.HasDecor("Vehicle.ID")) { client.TriggerServerEvent("Vehicle.RequestFuelLevel", vehicle.GetDecor <int>("Vehicle.ID")); } await BaseScript.Delay(1000); client.RegisterTickHandler(FuelTick); })); client.RegisterEventHandler("baseevents:leftVehicle", new Action <int, int, string>((veh, seat, name) => { vehicleFuel = -1; client.DeregisterTickHandler(FuelTick); })); client.RegisterEventHandler("Vehicle.RecieveFuelLevel", new Action <float>(fuel => { Log.Verbose($"Recieved a fuel level of {fuel}%"); vehicleFuel = fuel; })); client.RegisterTickHandler(CheckForPumps); client.Get <InteractionUI>().RegisterInteractionMenuItem(new MenuItemStandard { Title = "Refuel vehicle", OnActivate = item => PumpRefuel() }, () => isNearFuelPump && !Game.PlayerPed.IsInVehicle(), 500); CommandRegister.RegisterCommand("refuel", OnRefuelCommand); }
/// <summary> /// 初始化 /// </summary> public MissionPedController() { EntityDecoration.RegisterProperty(DecorIsMissionPed, DecorationType.Bool); EntityDecoration.RegisterProperty(DecorMissionInfoIndex, DecorationType.Int); EntityDecoration.RegisterProperty(DecorMissionPedInfoIndex, DecorationType.Int); }
public TriggeredPeds() { EntityDecoration.RegisterProperty(Decors.TRIGGERED_AMOUNT, DecorationType.Int); Tick += OnTick; }
public BetterPolice() { EntityDecoration.RegisterProperty(Decors.COP_WEAPONIZED, DecorationType.Bool); Tick += OnTick; }
public VehicleStoreMenu(Client client) : base(client) { try { client.RegisterTickHandler(OnTick); client.RegisterEventHandler("Vehicle.Store.SpawnBoughtVehicle", new Action <string, string, string, string>(SpawnBoughtVehicle)); client.RegisterEventHandler("Player.CheckForInteraction", new Action(OnInteraction)); markerLocations.ForEach(o => MarkerHandler.AddMarker(new Marker(o, MarkerType.HorizontalCircleFat, System.Drawing.Color.FromArgb(100, 204, 204, 0), 3))); EntityDecoration.RegisterProperty("Vehicle.IsPreviewVehicle", DecorationType.Bool); StoreMenus.ToList().ForEach(async o => { var menuCategories = new Dictionary <string, List <VehicleModel> >(); var storeMenuItems = new List <MenuItem>(); o.Value.ForEach(vehData => { if (!menuCategories.ContainsKey(vehData.vehicleCategory)) { menuCategories.Add(vehData.vehicleCategory, new List <VehicleModel>()); } menuCategories[vehData.vehicleCategory].Add(vehData); }); foreach (var i in menuCategories) { var vehicleList = i.Value.OrderBy(a => a.displayName).ToList(); var categoryItems = new List <MenuItem>(); var vehicleCategoryMenu = new MenuModel { headerTitle = i.Key, menuItems = categoryItems }; await vehicleList.ForEachAsync(async veh => { categoryItems.Add(new MenuItemStandard { Title = $"{veh.displayName}", OnActivate = async state => { isBuying = true; InteractionUI.Observer.CloseMenu(true); if (!loadedModels.ContainsKey(veh.modelName)) { loadedModels[veh.modelName] = new Model(Game.GenerateHash(veh.modelName)); } var vehModel = loadedModels[veh.modelName]; //if (!Cache.PlayerPed.IsInVehicle() || previewVehicle == null) { Log.ToChat("[Store]", "Purchasing vehicle...", ConstantColours.Green); while (!vehModel.IsLoaded) { await vehModel.Request(0); } deletePreviewVehicle(); var spawnLocation = vehiclePreviewLocation[o.Key].First(b => b.DistanceToSquared(Game.PlayerPed.Position) < 250.0f); previewVehicle = new CitizenFX.Core.Vehicle(API.CreateVehicle((uint)vehModel.Hash, spawnLocation.X, spawnLocation.Y, spawnLocation.Z, 0.0f, false, false)) { IsPositionFrozen = true, LockStatus = VehicleLockStatus.StickPlayerInside, IsDriveable = false, IsInvincible = true }; // No network previewVehicle.SetDecor("Vehicle.IsPreviewVehicle", true); Game.PlayerPed.Task.WarpIntoVehicle(previewVehicle, VehicleSeat.Driver); await BaseScript.Delay(1000); } var vehData = VehicleDataPacker.PackVehicleData(previewVehicle); if (vehData == null) { Log.ToChat("[Store]", "There was an error purchasing this vehicle. Please try again", ConstantColours.Store); isBuying = false; return; } var vehDataModel = JsonConvert.DeserializeObject <VehicleDataModel>(vehData); if (vehDataModel.Model != 0 && vehModel.Hash == Cache.PlayerPed.CurrentVehicle.Model.Hash) { Magicallity.Client.Client.Instance.TriggerServerEvent("Vehicle.Store.BuyVehicle", veh.modelName, veh.price, o.Key, vehData); } else { Log.ToChat("[Store]", "There was an error purchasing this vehicle. Please try again", ConstantColours.Store); } isBuying = false; }, OnSelect = state => { var modelLoaded = loadedModels.ContainsKey(veh.modelName); if (currentLoadingCategory != veh.vehicleCategory || !modelLoaded) { requestModelsForVehicleType(o.Key, vehicleCategoryMenu, veh.vehicleCategory); } if (!modelLoaded) { return; } var vehModel = loadedModels[veh.modelName]; deletePreviewVehicle(); var spawnLocation = vehiclePreviewLocation[o.Key].First(b => b.DistanceToSquared(Game.PlayerPed.Position) < 250.0f); previewVehicle = new CitizenFX.Core.Vehicle(API.CreateVehicle((uint)vehModel.Hash, spawnLocation.X, spawnLocation.Y, spawnLocation.Z, 0.0f, false, false)) { IsPositionFrozen = true, LockStatus = VehicleLockStatus.StickPlayerInside, IsDriveable = false, IsInvincible = true }; // No network previewVehicle.SetDecor("Vehicle.IsPreviewVehicle", true); Game.PlayerPed.Task.WarpIntoVehicle(previewVehicle, VehicleSeat.Driver); }, Detail = veh.price == 0 ? $"Free" : $"(${veh.price})", }); await BaseScript.Delay(0); }); storeMenuItems.Add(new MenuItemSubMenu { Title = i.Key, SubMenu = vehicleCategoryMenu, OnActivate = item => { deletePreviewVehicle(); requestModelsForVehicleType(o.Key, vehicleCategoryMenu, i.Key); vehicleCategoryMenu.menuItems[vehicleCategoryMenu.SelectedIndex].OnSelect(new MenuItemStandard()); } }); await BaseScript.Delay(0); } var menuThing = new MenuModel { headerTitle = o.Key.AddSpacesToCamelCase(), menuItems = storeMenuItems }; storeMenus[o.Key] = menuThing; client.Get <InteractionUI>().RegisterInteractionMenuItem(new MenuItemSubMenu { Title = o.Key.AddSpacesToCamelCase(), SubMenu = menuThing }, () => vehiclePreviewLocation.ContainsKey(o.Key) && vehiclePreviewLocation[o.Key].Any(loc => loc.DistanceToSquared(Game.PlayerPed.Position) < 250.0f), 510); }); vehiclePreviewLocation.ToList().ForEach(loc => { BlipHandler.AddBlip(loc.Key.AddSpacesToCamelCase(), loc.Value, new BlipOptions { Sprite = (BlipSprite)326 }); }); } catch (Exception e) { Log.Error(e); } }
public VehFuelHandler() { EntityDecoration.RegisterProperty(VEH_FUEL_DECOR, DecorationType.Float); Tick += OnTick; }