Add Edit-Mode, Hotkey-Blip-Saves

This commit is contained in:
VegaZ
2018-11-03 22:34:45 +01:00
parent c1cb9904dd
commit 0610c0bd57
6 changed files with 91 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ mp.keys.bind(0x0D, false, function () {
}
});
//F7
mp.keys.bind(0x76, false, function () {
if (showGui === true) {
@@ -27,6 +28,12 @@ mp.keys.bind(0x76, false, function () {
}
});
//NUM2
mp.keys.bind(0x62, false, function () {
mp.events.callRemote("keyPress:NUM2");
});
//I
mp.keys.bind(0x49, false, function () {
if (!chat) {

22
Main.cs
View File

@@ -41,6 +41,28 @@ namespace reallife_gamemode
context.Users.FirstOrDefault();
context.SaveChanges();
}
TempBlip tempBlip = new TempBlip()
{
Color = 1,
Name = "",
Transparency = 0,
ShortRange = true,
Sprite = 1,
Scale = 1,
};
NAPI.Data.SetWorldData("blipTemplate", tempBlip);
}
}
public class TempBlip
{
public byte Color { get; set; }
public string Name { get; set; }
public byte Transparency { get; set; }
public bool ShortRange { get; set; }
public uint Sprite { get; set; }
public float Scale { get; set; }
}
}

View File

@@ -894,6 +894,50 @@ namespace reallife_gamemode.Server.Commands
#region ALevel1337
[Command("editmode")]
public void CmdAdminToggleEditMode(Client player)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
{
ChatService.NotAuthorized(player);
return;
}
if(player.GetData("editmode") == false)
{
player.SetData("editmode", true);
player.SendNotification("Edit-Mode ~g~aktiviert");
}
else
{
player.SetData("editmode", false);
player.SendNotification("Edit-Mode ~r~deaktiviert");
}
}
[Command("setbliptemplate", "~m~Benutzung: ~s~/setbliptemplate [byte COLOR] [byte ALPHA] [bool SHORTRANGE] [uint SPRITE] [float SCALE] [string NAME]", GreedyArg = true)]
public void CmdAdminSetBlipTemplate(Client player, byte color, byte alpha, bool shortRange, uint sprite, float scale, string name)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
{
ChatService.NotAuthorized(player);
return;
}
TempBlip newTempBlip = new TempBlip()
{
Color = color,
Name = name,
Transparency = alpha,
ShortRange = shortRange,
Sprite = sprite,
Scale = scale,
};
NAPI.Data.SetWorldData("blipTemplate", newTempBlip);
}
[Command("setskin", "~m~Benutzung: ~s~/setskin [Spieler] [Skin]")]
public void CmdAdminSetSkin(Client player, string name, string Skin)
{

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
using Newtonsoft.Json;
using reallife_gamemode.Server.Extensions;
using reallife_gamemode.Server.Util;
/**
* @overview Life of German Reallife - Event Key (Key.cs)
@@ -14,6 +15,17 @@ namespace reallife_gamemode.Server.Events
{
public class Key : Script
{
[RemoteEvent("keyPress:NUM2")]
public void KeyPressNUM2(Client player)
{
if(player.GetData("editmode") == true && player.GetUser().IsAdmin(AdminLevel.HEADADMIN) == true)
{
TempBlip tempBlip = NAPI.Data.GetWorldData("blipTemplate");
SaveManager.OnSaveBlipData(player, tempBlip.Sprite.ToString(), tempBlip.Name, tempBlip.Scale.ToString(), tempBlip.Color.ToString(),
tempBlip.Transparency.ToString(), 200.ToString(), tempBlip.ShortRange.ToString(), 0.ToString(), 0.ToString());
}
}
[RemoteEvent("keyPress:I")]
public void KeyPressI(Client player)
{

View File

@@ -48,6 +48,11 @@ namespace reallife_gamemode.Server.Events
player.SetData("spec", true);
player.SetData("duty", false);
if(user.IsAdmin(AdminLevel.HEADADMIN) == true)
{
player.SetData("editmode", false);
}
var userBankAccount = loginUser.UserBankAccounts.SingleOrDefault(u => u.UserId == user.Id);
userBankAccount.Balance = userBankAccount.Balance;

View File

@@ -11,7 +11,7 @@ namespace reallife_gamemode.Server.Events
public class SaveManager : Script
{
[RemoteEvent("OnSaveBlipData")]
public void OnSaveBlipData(Client player, string blipSprite, string blipName, string blipScale, string blipColor,
public static void OnSaveBlipData(Client player, string blipSprite, string blipName, string blipScale, string blipColor,
string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension)
{
float x = player.Position.X;