Add VehicleShop, SaveManager, Edit LoadManager amm...

This commit is contained in:
VegaZ
2018-10-10 21:06:20 +02:00
parent 7d21f9c06e
commit e25af059a4
7 changed files with 250 additions and 28 deletions

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
using reallife_gamemode.Server.Entities;
using reallife_gamemode.Server.Extensions;
namespace reallife_gamemode.Server.Events
{
public class EnterVehicleAttempt : Script
{
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
public void OnPlayerEnterVehicleAttempt(Client player, Vehicle vehicle, sbyte seat)
{
if (vehicle.HasData("factionId"))
{
if((vehicle.GetData("factionId") != player.GetUser().FactionId) && seat == 0)
{
//TODO REWORK
player.SetIntoVehicle(vehicle, 1);
player.WarpOutOfVehicle();
player.SendChatMessage("Du hast kein Recht in dieses Fahrzeug als Fahrer einzusteigen.");
return;
}
}
}
}
}

View File

@@ -1,102 +0,0 @@
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, bool vehicleEngine, 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 = vehicleEngine,
Dimension = vehicleDimension,
Active = true
};
saveData.Vehicles.Add(dataSet);
saveData.SaveChanges();
}
}
public static void SaveFactionVehicleData(VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
string vehicleNumberPlate, byte vehiclePrimaryColor, byte vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, byte vehicleDimension, int? factionId)
{
using (var saveData = new Model.DatabaseContext())
{
var dataSet = new Entities.FactionVehicle
{
Model = vehicleModel,
FactionId = factionId,
PositionX = vehiclePosition.X,
PositionY = vehiclePosition.Y,
PositionZ = vehiclePosition.Z,
Heading = vehicleHeading,
NumberPlate = vehicleNumberPlate,
PrimaryColor = vehiclePrimaryColor,
SecondaryColor = vehicleSecondaryColor,
Locked = vehicleLocked,
Engine = vehicleEngine,
Dimension = vehicleDimension,
Active = true
};
saveData.FactionVehicles.Add(dataSet);
saveData.SaveChanges();
}
}
}
}