[+] Jail System
- add Escape
- add Jail In
- add Jail Timer
[+] Wanted System
- add Escape Timer
This commit is contained in:
@@ -87,6 +87,7 @@ namespace ReallifeGamemode.Server.Entities
|
|||||||
|
|
||||||
public int Wage { get; set; }
|
public int Wage { get; set; }
|
||||||
|
|
||||||
|
public int JailTime { get; set; }
|
||||||
|
|
||||||
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using GTANetworkAPI;
|
|||||||
using ReallifeGamemode.Server.Models;
|
using ReallifeGamemode.Server.Models;
|
||||||
using ReallifeGamemode.Server.Services;
|
using ReallifeGamemode.Server.Services;
|
||||||
using ReallifeGamemode.Server.Util;
|
using ReallifeGamemode.Server.Util;
|
||||||
|
using ReallifeGamemode.Server.Wanted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||||
@@ -42,6 +43,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
player.TriggerEvent("SERVER:Login_ShowBrowser");
|
player.TriggerEvent("SERVER:Login_ShowBrowser");
|
||||||
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID:" + player.Handle.Value + "] (" + player.Address + ")";
|
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID:" + player.Handle.Value + "] (" + player.Address + ")";
|
||||||
ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN);
|
ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsPlayerBanned(Client player)
|
private bool IsPlayerBanned(Client player)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using ReallifeGamemode.Server.Factions.Medic;
|
|||||||
using ReallifeGamemode.Server.Models;
|
using ReallifeGamemode.Server.Models;
|
||||||
using ReallifeGamemode.Server.Services;
|
using ReallifeGamemode.Server.Services;
|
||||||
using ReallifeGamemode.Server.Util;
|
using ReallifeGamemode.Server.Util;
|
||||||
|
using ReallifeGamemode.Server.Wanted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Events Death (Death.cs)
|
* @overview Life of German Reallife - Events Death (Death.cs)
|
||||||
@@ -73,6 +74,11 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//JailTime.cs
|
||||||
|
Jail.Check_PutBehindBars(player);
|
||||||
|
|
||||||
|
|
||||||
//MEDIC AUFTRAG
|
//MEDIC AUFTRAG
|
||||||
MedicTask reviveTask = new MedicTask()
|
MedicTask reviveTask = new MedicTask()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using ReallifeGamemode.Server.Managers;
|
|||||||
using ReallifeGamemode.Server.Models;
|
using ReallifeGamemode.Server.Models;
|
||||||
using ReallifeGamemode.Server.Services;
|
using ReallifeGamemode.Server.Services;
|
||||||
using ReallifeGamemode.Server.Util;
|
using ReallifeGamemode.Server.Util;
|
||||||
|
using ReallifeGamemode.Server.Wanted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||||
@@ -83,8 +84,17 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
{
|
{
|
||||||
CharacterCreator.ApplyCharacter(player);
|
CharacterCreator.ApplyCharacter(player);
|
||||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||||
|
if(user.JailTime == 0)
|
||||||
|
{
|
||||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Jail.Check_PutBehindBars(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||||
if (user.Dead == true)
|
if (user.Dead == true)
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ namespace ReallifeGamemode.Server.Finance
|
|||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
client.GetUser().GetBankAccount(dbContext).Balance += paycheck.Amount;
|
client.GetUser().GetBankAccount(dbContext).Balance += paycheck.Amount;
|
||||||
|
client.GetUser(dbContext).Wage = 0;
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
if (paycheck.Amount > 0)
|
if (paycheck.Amount > 0)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace ReallifeGamemode.Server
|
|||||||
NAPI.Data.SetWorldData("blipTemplate", tempBlip);
|
NAPI.Data.SetWorldData("blipTemplate", tempBlip);
|
||||||
|
|
||||||
WantedEscapeTimer.WantedTimer();
|
WantedEscapeTimer.WantedTimer();
|
||||||
|
Jail.JailTimer();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1161
ReallifeGamemode.Server/Migrations/20190715192123_JailTime.Designer.cs
generated
Normal file
1161
ReallifeGamemode.Server/Migrations/20190715192123_JailTime.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Migrations
|
||||||
|
{
|
||||||
|
public partial class JailTime : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "JailTime",
|
||||||
|
table: "Users",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "JailTime",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
169
ReallifeGamemode.Server/Wanted/Jail.cs
Normal file
169
ReallifeGamemode.Server/Wanted/Jail.cs
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using GTANetworkAPI;
|
||||||
|
using ReallifeGamemode.Server.Entities;
|
||||||
|
using ReallifeGamemode.Server.Extensions;
|
||||||
|
using ReallifeGamemode.Server.Models;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Wanted
|
||||||
|
{
|
||||||
|
public class Jail
|
||||||
|
{
|
||||||
|
public static Dictionary<int, int> jailtime { get; set; } = new Dictionary<int, int>(); //time in seconds
|
||||||
|
|
||||||
|
|
||||||
|
public static void Check_PutBehindBars(Client client)
|
||||||
|
{
|
||||||
|
User user = client.GetUser();
|
||||||
|
if (user.JailTime > 0)
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
int rndInt = rnd.Next(1, 3);
|
||||||
|
if (rndInt == 1)
|
||||||
|
client.Position = new Vector3(458.9842, -997.2126, 24.91485); //send client to jail
|
||||||
|
if (rndInt == 2)
|
||||||
|
client.Position = new Vector3(459.696, -994.3766, 24.91486); //send client to jail
|
||||||
|
if (rndInt == 3)
|
||||||
|
client.Position = new Vector3(458.3372, -1001.258, 24.91485); //send client to jail
|
||||||
|
|
||||||
|
jailtime[user.Id] = user.JailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (user.Wanteds <= 0)
|
||||||
|
return;
|
||||||
|
foreach (var copClient in NAPI.Pools.GetAllPlayers())
|
||||||
|
{
|
||||||
|
User cop = copClient.GetUser();
|
||||||
|
if (cop?.FactionId == 1 || cop?.FactionId == 3)
|
||||||
|
{
|
||||||
|
if (cop.GetData<bool>("duty") && copClient.Position.DistanceTo2D(copClient.Position) <= 200)
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
int rndInt = rnd.Next(1, 3);
|
||||||
|
if (rndInt == 1)
|
||||||
|
client.Position = new Vector3(458.9842, -997.2126, 24.91485); //send client to jail
|
||||||
|
if (rndInt == 2)
|
||||||
|
client.Position = new Vector3(459.696, -994.3766, 24.91486); //send client to jail
|
||||||
|
if (rndInt == 3)
|
||||||
|
client.Position = new Vector3(458.3372, -1001.258, 24.91485); //send client to jail
|
||||||
|
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
client.GetUser(dbContext).JailTime = user.Wanteds * 54; // 54 sec for each wanted star -> in total 45min for 50 Wanteds
|
||||||
|
client.GetUser(dbContext).Wanteds = 0;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
jailtime[user.Id] = user.Wanteds * 54; // 54 sec for each wanted star -> in total 45min for 50 Wanteds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void JailTimer()
|
||||||
|
{
|
||||||
|
System.Timers.Timer timer = new System.Timers.Timer(60000);
|
||||||
|
System.Timers.Timer brakeOut = new System.Timers.Timer(10000);
|
||||||
|
System.Timers.Timer jailIn = new System.Timers.Timer(2500);
|
||||||
|
timer.Start();
|
||||||
|
brakeOut.Start();
|
||||||
|
jailIn.Start();
|
||||||
|
timer.Elapsed += Timer_Elapsed;
|
||||||
|
brakeOut.Elapsed += brakeOut_Elapsed;
|
||||||
|
jailIn.Elapsed += jailIn_Elapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void jailIn_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||||
|
{
|
||||||
|
User user = player.GetUser();
|
||||||
|
if (jailtime.ContainsKey(user.Id))
|
||||||
|
return;
|
||||||
|
foreach(var copPlayer in NAPI.Pools.GetAllPlayers())
|
||||||
|
{
|
||||||
|
User cop = copPlayer.GetUser();
|
||||||
|
if (player.Position.DistanceTo2D(new Vector3(458.9842, -997.2126, 24.91485)) <= 7)
|
||||||
|
{
|
||||||
|
if (player.Position.DistanceTo2D(copPlayer.Position) < 5)
|
||||||
|
{
|
||||||
|
Check_PutBehindBars(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void brakeOut_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||||
|
{
|
||||||
|
User user = player.GetUser();
|
||||||
|
if (!jailtime.ContainsKey(user.Id))
|
||||||
|
return;
|
||||||
|
if (player.Position.DistanceTo2D(new Vector3(458.9842, -997.2126, 24.91485)) > 7)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
player.GetUser(dbContext).Wanteds = 50;
|
||||||
|
player.GetUser(dbContext).JailTime = 0;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
jailtime.Remove(user.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||||
|
{
|
||||||
|
User user = player.GetUser();
|
||||||
|
if (jailtime.ContainsKey(user.Id))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (user.JailTime <= 0)
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
int rndInt = rnd.Next(1, 5);
|
||||||
|
switch (rndInt)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
player.Position = new Vector3(462.0074, -991.5361, 24.91487);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
player.Position = new Vector3(462.2939, -989.9335, 24.91487);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
player.Position = new Vector3(461.7256, -988.6035, 24.91487);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
player.Position = new Vector3(462.5977, -989.9182, 24.91487);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
player.Position = new Vector3(462.4364, -991.4973, 24.91487);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
jailtime.Remove(user.Id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (user.JailTime > 0)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
player.GetUser(dbContext).JailTime -= 60;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ using System.Threading;
|
|||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
using ReallifeGamemode.Server.Entities;
|
using ReallifeGamemode.Server.Entities;
|
||||||
using ReallifeGamemode.Server.Extensions;
|
using ReallifeGamemode.Server.Extensions;
|
||||||
|
using ReallifeGamemode.Server.Models;
|
||||||
using ReallifeGamemode.Server.Services;
|
using ReallifeGamemode.Server.Services;
|
||||||
|
|
||||||
namespace ReallifeGamemode.Server.Wanted
|
namespace ReallifeGamemode.Server.Wanted
|
||||||
@@ -68,7 +69,12 @@ namespace ReallifeGamemode.Server.Wanted
|
|||||||
if (waTimer[user.Id] <= 0)
|
if (waTimer[user.Id] <= 0)
|
||||||
{
|
{
|
||||||
ResetWantedTimeToElapse(player);
|
ResetWantedTimeToElapse(player);
|
||||||
user.Wanteds -= 1;
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
player.GetUser(dbContext).Wanteds -= 1;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isNearCop)
|
if (!isNearCop)
|
||||||
|
|||||||
Reference in New Issue
Block a user