79 lines
3.1 KiB
C#
79 lines
3.1 KiB
C#
using GTANetworkAPI;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace reallife_gamemode.Server.Events
|
|
{
|
|
public class SaveData : Script
|
|
{
|
|
[RemoteEvent("OnSaveBlipData")]
|
|
public void OnSaveBlipData(Client player, string blipSprite, string blipName, string blipScale, string blipColor,
|
|
string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension)
|
|
{
|
|
float x = player.Position.X;
|
|
float y = player.Position.Y;
|
|
float z = player.Position.Z;
|
|
short sprite = short.Parse(blipSprite);
|
|
string name = blipName;
|
|
float scale = float.Parse(blipScale);
|
|
byte color = Convert.ToByte(blipColor);
|
|
byte alpha = Convert.ToByte(blipAlpha);
|
|
float drawDistance = float.Parse(blipDrawDistance);
|
|
bool shortRange = bool.Parse(blipShortRange);
|
|
float rotation = float.Parse(blipRotation);
|
|
byte dimension = Convert.ToByte(blipDimension);
|
|
|
|
NAPI.Blip.CreateBlip(uint.Parse(blipSprite), new Vector3(x,y,z), scale, color, name, alpha, drawDistance, shortRange, short.Parse(blipRotation), dimension);
|
|
|
|
using (var saveData = new Model.DatabaseContext())
|
|
{
|
|
var dataSet = new Server.Saves.SavedBlip
|
|
{
|
|
Sprite = sprite,
|
|
PositionX = x,
|
|
PositionY = y,
|
|
PositionZ = z,
|
|
Name = blipName,
|
|
Scale = scale,
|
|
Color = color,
|
|
Alpha = alpha,
|
|
DrawDistance = drawDistance,
|
|
ShortRange = shortRange,
|
|
Rotation = rotation,
|
|
Dimension = dimension,
|
|
Active = true
|
|
};
|
|
saveData.Blips.Add(dataSet);
|
|
saveData.SaveChanges();
|
|
}
|
|
}
|
|
|
|
public static void SaveVehicleData(VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
|
string vehicleNumberPlate, byte vehiclePrimaryColor, byte vehicleSecondaryColor, bool vehicleLocked, byte vehicleDimension)
|
|
{
|
|
using (var saveData = new Model.DatabaseContext())
|
|
{
|
|
var dataSet = new Server.Saves.SavedVehicle
|
|
{
|
|
Model = vehicleModel,
|
|
PositionX = vehiclePosition.X,
|
|
PositionY = vehiclePosition.Y,
|
|
PositionZ = vehiclePosition.Z,
|
|
Heading = vehicleHeading,
|
|
NumberPlate = vehicleNumberPlate,
|
|
PrimaryColor = vehiclePrimaryColor,
|
|
SecondaryColor = vehicleSecondaryColor,
|
|
Locked = vehicleLocked,
|
|
Engine = false,
|
|
Dimension = vehicleDimension,
|
|
Active = true
|
|
};
|
|
saveData.Vehicles.Add(dataSet);
|
|
saveData.SaveChanges();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|