85 lines
3.8 KiB
C#
85 lines
3.8 KiB
C#
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<GotoPoint> GotoPointList = new List<GotoPoint>();
|
|
public static List<Vehicle> FactionVehicleList = new List<Vehicle>();
|
|
public static List<Vehicle> ShopVehicleList = new List<Vehicle>();
|
|
public static List<Vehicle> UserVehicleList = new List<Vehicle>();
|
|
|
|
|
|
[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 (Entities.GotoPoint g in loadData.GotoPoints)
|
|
{
|
|
if (g.Active == true)
|
|
{
|
|
GotoPointList.Add(g);
|
|
}
|
|
}
|
|
foreach (Saves.SavedVehicle v in loadData.Vehicles)
|
|
{
|
|
if (v.Active == true)
|
|
{
|
|
NAPI.Vehicle.CreateVehicle((uint)v.Model, new Vector3(v.PositionX, v.PositionY, v.PositionZ), v.Heading, (v.PrimaryColor),
|
|
v.SecondaryColor, v.NumberPlate, v.Alpha, v.Locked, v.Engine = false, v.Dimension);
|
|
}
|
|
}
|
|
foreach (FactionVehicle v in loadData.FactionVehicles)
|
|
{
|
|
if (v.Active == true)
|
|
{
|
|
Vehicle current = NAPI.Vehicle.CreateVehicle((uint)v.Model, new Vector3(v.PositionX, v.PositionY, v.PositionZ), v.Heading, (v.PrimaryColor),
|
|
v.SecondaryColor, v.NumberPlate, v.Alpha, v.Locked, v.Engine = false, v.Dimension);
|
|
current.SetData("factionId", v.FactionId);
|
|
FactionVehicleList.Add(current);
|
|
}
|
|
}
|
|
foreach (ShopVehicle v in loadData.ShopVehicles)
|
|
{
|
|
if (v.Active == true)
|
|
{
|
|
Vehicle current = NAPI.Vehicle.CreateVehicle((uint)v.Model, new Vector3(v.PositionX, v.PositionY, v.PositionZ), v.Heading, (v.PrimaryColor),
|
|
v.SecondaryColor, v.NumberPlate, v.Alpha, false, false, v.Dimension);
|
|
ShopVehicleList.Add(current);
|
|
current.Health = -4000;
|
|
var tLabel = NAPI.TextLabel.CreateTextLabel(v.ModelName + " | " + v.Price + "~g~$", new Vector3(v.PositionX, v.PositionY, v.PositionZ + 1.5), 10, 1, 0, new Color(255, 255, 255), false, v.Dimension);
|
|
current.SetData("shopVehicleId", v.Id);
|
|
}
|
|
}
|
|
foreach (UserVehicle v in loadData.UserVehicles)
|
|
{
|
|
Vehicle current = NAPI.Vehicle.CreateVehicle((uint)v.Model, new Vector3(v.PositionX, v.PositionY, v.PositionZ), v.Heading, (v.PrimaryColor),
|
|
v.SecondaryColor, v.NumberPlate, v.Alpha, false, false, v.Dimension);
|
|
current.SetData("ownerId", v.UserId);
|
|
UserVehicleList.Add(current);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|