using System; using System.Collections.Generic; using System.Text; using GTANetworkAPI; using reallife_gamemode.Model; using reallife_gamemode.Server.Entities; /** * @overview Life of German Reallife - Managers LoadManager (LoadManager.cs) * @author VegaZ * @copyright (c) 2008 - 2018 Life of German */ namespace reallife_gamemode.Server.Managers { public class LoadManager : Script { public static List GotoPointList = new List(); public static List FactionVehicleList = new List(); public static List ShopVehicleList = new List(); public static List UserVehicleList = new List(); [ServerEvent(Event.ResourceStart)] public void OnResourceStart() { using (var loadData = new DatabaseContext()) { foreach (Saves.SavedBlip b in loadData.Blips) { if(b.Active == true) { NAPI.Blip.CreateBlip((uint) b.Sprite, new Vector3(b.PositionX, b.PositionY, b.PositionZ), b.Scale, b.Color, b.Name, b.Alpha, b.DrawDistance, b.ShortRange, (short) b.Rotation, b.Dimension); } } foreach (GotoPoint g in loadData.GotoPoints) { if (g.Active == true) { GotoPointList.Add(g); } } foreach(ServerVehicle veh in loadData.ServerVehicles) { if (!veh.Active) continue; Vehicle current = veh.Spawn(); if (veh is Saves.SavedVehicle savedV) { NAPI.Vehicle.CreateVehicle((uint)savedV.Model, new Vector3(savedV.PositionX, savedV.PositionY, savedV.PositionZ), savedV.Heading, savedV.PrimaryColor, savedV.SecondaryColor, savedV.NumberPlate, 255, savedV.Locked); } if (veh is FactionVehicle factionV) { current.SetData("factionId", factionV.FactionId); FactionVehicleList.Add(current); } if (veh is ShopVehicle shopV) { string displayName = NAPI.Vehicle.GetVehicleDisplayName(shopV.Model); ShopVehicleList.Add(current); NAPI.Vehicle.SetVehicleEngineHealth(current, 0); var tLabel = NAPI.TextLabel.CreateTextLabel(displayName + " | " + shopV.Price + "~g~$", new Vector3(shopV.PositionX, shopV.PositionY, shopV.PositionZ + 1.5), 10, 1, 0, new Color(255, 255, 255), false); current.SetData("shopVehicleId", shopV.Id); tLabel.AttachTo(current, "chassis", new Vector3(0, 0, 1.5), new Vector3(0, 0, 0)); } if (veh is UserVehicle userV) { UserVehicleList.Add(current); } } } } } }