add wanteds
This commit is contained in:
7
ReallifeGamemode.Client/Gui/wanteds.ts
Normal file
7
ReallifeGamemode.Client/Gui/wanteds.ts
Normal 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});`);
|
||||
});
|
||||
}
|
||||
@@ -154,7 +154,7 @@ export default function tuning(globalData: GlobalData) {
|
||||
var localPlayer = mp.players.local;
|
||||
var localVehicle = localPlayer.vehicle;
|
||||
|
||||
localVehicle.setHalt(1.0, true, false);
|
||||
localVehicle.setHalt(1.0, 1, false);
|
||||
|
||||
globalData.InMenu = true;
|
||||
globalData.InTuning = true;
|
||||
|
||||
57
ReallifeGamemode.Client/assets/html/wanteds/index.html
Normal file
57
ReallifeGamemode.Client/assets/html/wanteds/index.html
Normal 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>
|
||||
4
ReallifeGamemode.Client/assets/img/wanteds/star.svg
Normal file
4
ReallifeGamemode.Client/assets/img/wanteds/star.svg
Normal 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>
|
||||
@@ -25,6 +25,9 @@ var inMenu = false;
|
||||
|
||||
mp.game.vehicle.defaultEngineBehaviour = false;
|
||||
|
||||
import wanteds from './Gui/wanteds';
|
||||
wanteds(globalData);
|
||||
|
||||
import playerBlips from './Gui/blips';
|
||||
playerBlips();
|
||||
|
||||
|
||||
4
ReallifeGamemode.Client/package-lock.json
generated
4
ReallifeGamemode.Client/package-lock.json
generated
@@ -194,8 +194,8 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/ragemp-c": {
|
||||
"version": "git+https://github.com/sprayzcs/types-ragemp-c.git#5bad2bb24e8cd1f286d8ee26b30272891423d9f9",
|
||||
"from": "git+https://github.com/sprayzcs/types-ragemp-c.git#master",
|
||||
"version": "github:CocaColaBear/types-ragemp-c#6a118e6399b77a347ac67e07f6b15f842109b0ff",
|
||||
"from": "github:CocaColaBear/types-ragemp-c#master",
|
||||
"dev": true
|
||||
},
|
||||
"@webassemblyjs/ast": {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.3.4",
|
||||
"@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",
|
||||
"babel-loader": "^8.0.5",
|
||||
"copy-webpack-plugin": "^5.0.1",
|
||||
|
||||
@@ -195,6 +195,12 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if(amount <= 0)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Es muss eine positive Wantedanzahl vergeben werden");
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
@@ -205,6 +211,38 @@ namespace ReallifeGamemode.Server.Commands
|
||||
User targetUser = target.GetUser();
|
||||
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
|
||||
#region Global Fraktions Commands
|
||||
#endregion
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class User : IBankAccountOwner
|
||||
{
|
||||
[NotMapped]
|
||||
private int _wanteds;
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
@@ -66,7 +69,15 @@ namespace ReallifeGamemode.Server.Entities
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -183,9 +194,15 @@ namespace ReallifeGamemode.Server.Entities
|
||||
internal void GiveWanteds(Client cop, int amount, string reason)
|
||||
{
|
||||
if (this.Wanteds + amount > 40)
|
||||
{
|
||||
ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 40 nicht überschreiten");
|
||||
return;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
User user = dbContext.Users.Where(u => u.Id == this.Id).FirstOrDefault();
|
||||
user.Wanteds += amount;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace ReallifeGamemode.Server.Events
|
||||
var userBankAccount = user.GetBankAccount();
|
||||
userBankAccount.Balance = userBankAccount.Balance;
|
||||
|
||||
user.Wanteds = user.Wanteds;
|
||||
|
||||
if(user.Group != null)
|
||||
{
|
||||
string msg = $"{player.Name} ist wieder online.";
|
||||
|
||||
Reference in New Issue
Block a user