add wanteds

This commit is contained in:
hydrant
2019-06-26 20:09:19 +02:00
parent 8125ba673e
commit 3a894ddb93
10 changed files with 135 additions and 7 deletions

View File

@@ -0,0 +1,7 @@
export default function wanteds(globalData: GlobalData) {
var browser = mp.browsers.new("package://assets/html/wanteds/index.html");
mp.events.add("SERVER:SetWanteds", (count: number) => {
browser.execute(`setWanteds(${count});`);
});
}

View File

@@ -154,7 +154,7 @@ export default function tuning(globalData: GlobalData) {
var localPlayer = mp.players.local; var localPlayer = mp.players.local;
var localVehicle = localPlayer.vehicle; var localVehicle = localPlayer.vehicle;
localVehicle.setHalt(1.0, true, false); localVehicle.setHalt(1.0, 1, false);
globalData.InMenu = true; globalData.InMenu = true;
globalData.InTuning = true; globalData.InTuning = true;

View File

@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Wanteds</title>
<style>
html, body {
margin: 0;
padding: 0;
}
#wanteds {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
top: 40px;
right: 20px;
height: 50px;
padding-top: 10px;
line-height: 50px;
}
#wanteds img {
width: 50px;
height: 50px;
}
#wanteds span {
margin-top: 10px;
margin-left: 5px;
font-size: 50px;
color: white;
font-family: 'Bebas Neue';
}
</style>
</head>
<body>
<div id="wanteds" style="display: none;">
<img src="package://assets/img/wanteds/star.svg" />
<span id="wanted-count">10</span>
</div>
<script src="package://assets/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
function setWanteds(count) {
if (count === 0) {
$("#wanteds").hide();
} else {
$("#wanteds").show();
$("#wanted-count").text(count.toString());
}
}
</script>
</body>
</html>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240">
<path fill="#F8D64E" d="m48,234 73-226 73,226-192-140h238z"/>
</svg>

View File

@@ -25,6 +25,9 @@ var inMenu = false;
mp.game.vehicle.defaultEngineBehaviour = false; mp.game.vehicle.defaultEngineBehaviour = false;
import wanteds from './Gui/wanteds';
wanteds(globalData);
import playerBlips from './Gui/blips'; import playerBlips from './Gui/blips';
playerBlips(); playerBlips();

View File

@@ -194,8 +194,8 @@
"dev": true "dev": true
}, },
"@types/ragemp-c": { "@types/ragemp-c": {
"version": "git+https://github.com/sprayzcs/types-ragemp-c.git#5bad2bb24e8cd1f286d8ee26b30272891423d9f9", "version": "github:CocaColaBear/types-ragemp-c#6a118e6399b77a347ac67e07f6b15f842109b0ff",
"from": "git+https://github.com/sprayzcs/types-ragemp-c.git#master", "from": "github:CocaColaBear/types-ragemp-c#master",
"dev": true "dev": true
}, },
"@webassemblyjs/ast": { "@webassemblyjs/ast": {

View File

@@ -4,7 +4,7 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.3.4", "@babel/core": "^7.3.4",
"@types/node": "^11.9.5", "@types/node": "^11.9.5",
"@types/ragemp-c": "git+https://github.com/sprayzcs/types-ragemp-c.git#master", "@types/ragemp-c": "github:CocaColaBear/types-ragemp-c#master",
"NativeUI": "https://github.com/sprayzcs/RageMP-NativeUI/tarball/master", "NativeUI": "https://github.com/sprayzcs/RageMP-NativeUI/tarball/master",
"babel-loader": "^8.0.5", "babel-loader": "^8.0.5",
"copy-webpack-plugin": "^5.0.1", "copy-webpack-plugin": "^5.0.1",

View File

@@ -195,6 +195,12 @@ namespace ReallifeGamemode.Server.Commands
return; return;
} }
if(amount <= 0)
{
ChatService.ErrorMessage(player, "Es muss eine positive Wantedanzahl vergeben werden");
return;
}
Client target = ClientService.GetClientByNameOrId(nameOrId); Client target = ClientService.GetClientByNameOrId(nameOrId);
if (target == null || !target.IsLoggedIn()) if (target == null || !target.IsLoggedIn())
{ {
@@ -205,6 +211,38 @@ namespace ReallifeGamemode.Server.Commands
User targetUser = target.GetUser(); User targetUser = target.GetUser();
targetUser.GiveWanteds(player, amount, reason); targetUser.GiveWanteds(player, amount, reason);
} }
[Command("clear", "~m~Benutzung: ~s~/clear [Name / ID] [Grund]")]
public void CmdFactionClear(Client player, string nameOrId, string reason)
{
User user = player.GetUser();
if (user == null || (user.FactionId != 1 && user.FactionId != 2))
{
ChatService.NotAuthorized(player);
return;
}
Client target = ClientService.GetClientByNameOrId(nameOrId);
if (target == null || !target.IsLoggedIn())
{
ChatService.PlayerNotFound(player);
return;
}
using (var dbContext = new DatabaseContext())
{
User targetUser = target.GetUser(dbContext);
if(targetUser.Wanteds == 0)
{
ChatService.ErrorMessage(player, "Der Spieler hat keine Wanteds");
return;
}
targetUser.Wanteds = 0;
dbContext.SaveChanges();
}
}
#endregion #endregion
#region Global Fraktions Commands #region Global Fraktions Commands
#endregion #endregion

View File

@@ -19,6 +19,9 @@ namespace ReallifeGamemode.Server.Entities
{ {
public class User : IBankAccountOwner public class User : IBankAccountOwner
{ {
[NotMapped]
private int _wanteds;
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; } public int Id { get; set; }
@@ -66,7 +69,15 @@ namespace ReallifeGamemode.Server.Entities
public int? JobId { get; set; } public int? JobId { get; set; }
public int Wanteds { get; set; } public int Wanteds
{
get => _wanteds;
set
{
this._wanteds = value;
Client.TriggerEvent("SERVER:SetWanteds", value);
}
}
public FactionRank GetFactionRank() public FactionRank GetFactionRank()
{ {
@@ -182,10 +193,16 @@ namespace ReallifeGamemode.Server.Entities
internal void GiveWanteds(Client cop, int amount, string reason) internal void GiveWanteds(Client cop, int amount, string reason)
{ {
if(this.Wanteds + amount > 40) if (this.Wanteds + amount > 40)
{
ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 40 nicht überschreiten");
return;
}
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
User user = dbContext.Users.Where(u => u.Id == this.Id).FirstOrDefault();
user.Wanteds += amount;
dbContext.SaveChanges();
} }
} }
} }

View File

@@ -59,6 +59,8 @@ namespace ReallifeGamemode.Server.Events
var userBankAccount = user.GetBankAccount(); var userBankAccount = user.GetBankAccount();
userBankAccount.Balance = userBankAccount.Balance; userBankAccount.Balance = userBankAccount.Balance;
user.Wanteds = user.Wanteds;
if(user.Group != null) if(user.Group != null)
{ {
string msg = $"{player.Name} ist wieder online."; string msg = $"{player.Name} ist wieder online.";