Initial Commit for user-backend, preparing several systems
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
|
||||
@@ -11,13 +12,34 @@ using GTANetworkAPI;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
class Disconnect : Script
|
||||
public class Disconnect : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
public void OnPlayerDisconnected(Client player)
|
||||
public void OnPlayerDisconnected(Client player, DisconnectionType type, string reason)
|
||||
{
|
||||
if (type == DisconnectionType.Left)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||
}
|
||||
if (type == DisconnectionType.Kicked)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
||||
}
|
||||
if (type == DisconnectionType.Timeout)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
||||
}
|
||||
/*
|
||||
using (var saveUser = new Model.DatabaseContext())
|
||||
{
|
||||
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();
|
||||
}*/
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ namespace reallife_gamemode.Server.Events
|
||||
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.TriggerEvent("draw");
|
||||
player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
38
Server/Events/ResourceStop.cs
Normal file
38
Server/Events/ResourceStop.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkMethods;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event ResourceStop (ResourceStop.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class ResourceStop : Script
|
||||
{
|
||||
[ServerEvent(Event.ResourceStop)]
|
||||
public void OnResourceStop()
|
||||
{
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
foreach(Client user in users)
|
||||
{
|
||||
using (var saveUsers = new Model.DatabaseContext())
|
||||
{
|
||||
var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name);
|
||||
|
||||
saveUser.PositionX = user.Position.X;
|
||||
saveUser.PositionY = user.Position.Y;
|
||||
saveUser.PositionZ = user.Position.Z;
|
||||
saveUsers.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user