Feature/save system
This commit is contained in:
@@ -37,10 +37,17 @@ namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
var user = saveUser.Users.SingleOrDefault(u => u.Name == player.Name);
|
||||
|
||||
user.PositionX = player.Position.X;
|
||||
user.PositionY = player.Position.Y;
|
||||
user.PositionZ = player.Position.Z;
|
||||
saveUser.SaveChanges();
|
||||
if(user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
user.PositionX = player.Position.X;
|
||||
user.PositionY = player.Position.Y;
|
||||
user.PositionZ = player.Position.Z;
|
||||
saveUser.SaveChanges();
|
||||
}
|
||||
}
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace reallife_gamemode.Server.Events
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetData("spec", true);
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,30 @@ namespace reallife_gamemode.Server.Events
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user