inshallah kein fehler

This commit is contained in:
hydrant
2020-05-10 23:18:53 +02:00
153 changed files with 6517 additions and 3407 deletions

View File

@@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using System.Linq;
using GTANetworkAPI;
public static class AttachmentSync
{
/// <summary>
/// Adds/Removes an attachment for an entity
/// </summary>
/// <param name="entity">The entity to attach the object to</param>
/// <param name="attachment">The attachment, should be in string or long type</param>
/// <param name="remove">Pass true to remove the specified attachment, false otherwise.</param>
public static void AddAttachment(this Entity entity, dynamic attachment, bool remove)
{
if (!entity.HasData("Attachments"))
entity.SetData("Attachments", new List<uint>());
List<uint> currentAttachments = entity.GetData<List<uint>>("Attachments");
uint attachmentHash = 0;
if (attachment.GetType() == typeof(string))
attachmentHash = NAPI.Util.GetHashKey(attachment);
else
attachmentHash = Convert.ToUInt32(attachment);
if (attachmentHash == 0)
{
Console.WriteLine($"Attachment hash couldn't be found for { attachment }");
return;
}
if (currentAttachments.IndexOf(attachmentHash) == -1) // if current attachment hasn't already been added
{
if (!remove) // if it needs to be added
{
currentAttachments.Add(attachmentHash);
}
}
else if (remove) // if it was found and needs to be removed
{
currentAttachments.Remove(attachmentHash);
}
// send updated data to playerside
entity.SetSharedData("attachmentsData", currentAttachments.Serialize());
}
/// <summary>
/// Returns true if an entity has a certain attachment
/// </summary>
/// <param name="entity">The entity to check</param>
/// <param name="attachment">The attachment to look for</param>
/// <returns>True if attachment was found, false otherwise</returns>
public static bool HasAttachment(this Entity entity, dynamic attachment)
{
if (!entity.HasData("Attachments"))
return false;
List<uint> currentAttachments = entity.GetData<List<uint>>("Attachments");
uint attachmentHash = 0;
if (attachment.GetType() == typeof(string))
attachmentHash = NAPI.Util.GetHashKey(attachment);
else
attachmentHash = Convert.ToUInt32(attachment);
if (attachmentHash == 0)
{
Console.WriteLine($"Attachment hash couldn't be found for { attachment }");
return false;
}
return currentAttachments.IndexOf(attachmentHash) != -1;
}
/// <summary>
/// Clears the entity's current attachments
/// </summary>
/// <param name="entity">The entity to clear the attachments of</param>
public static void ClearAttachments(this Entity entity)
{
if (!entity.HasData("Attachments"))
return;
List<uint> currentAttachments = entity.GetData<List<uint>>("Attachments");
if (currentAttachments.Count > 0)
{
for (int i = currentAttachments.Count - 1; i >= 0; i--)
{
entity.AddAttachment(currentAttachments[i], true);
}
}
entity.ResetSharedData("attachmentsData");
entity.SetData("Attachments", new List<uint>());
}
/// <summary>
/// Serializes a list of attachments
/// </summary>
/// <param name="attachments">a list of attachments in uint type</param>
/// <returns>serialized attachment string</returns>
public static string Serialize(this List<uint> attachments)
{
return string.Join('|', attachments.Select(a => Base36Extensions.ToBase36(a)).ToArray());
}
}
public class AttachmentSyncExample : Script
{
//REQUIRED
[ServerEvent(Event.PlayerConnected)]
public void OnPlayerConnect(Player player)
{
// reset data on connect
player.ClearAttachments();
player.TriggerEvent("SERVER:LoadAttachments");
}
//REQUIRED
[RemoteEvent("staticAttachments.Add")]
private void OnStaticAttachmentAdd(Player player, string hash)
{
player.AddAttachment(Base36Extensions.FromBase36(hash), false);
}
//REQUIRED
[RemoteEvent("staticAttachments.Remove")]
private void OnStaticAttachmentRemove(Player player, string hash)
{
player.AddAttachment(Base36Extensions.FromBase36(hash), true);
}
[Command("xdd")]
public void attachment(Player player)
{
Vehicle veh = player.Vehicle;
if (!veh.HasAttachment("weapondeal"))
{
veh.AddAttachment("weapondeal", false);
//veh.AddAttachment("weapondeal1", false);
//veh.AddAttachment("weapondeal2", false);
}
else
{
veh.ClearAttachments();
}
}
}

View File

@@ -1,6 +1,4 @@
using System.Collections.Generic;
using ReallifeGamemode.Server.Services;
using GTANetworkAPI;
using System.Linq;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Job;
@@ -42,6 +40,7 @@ namespace ReallifeGamemode.Server.Util
playerHandle.LastCheckpoint = 2;
}*/
}
public static void RemovePlayerHandlerFromList(Player player)
{
CheckPointListForPlayer temp = null;
@@ -283,6 +282,7 @@ namespace ReallifeGamemode.Server.Util
{
player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player, 0, this.delay, this.markerID, this.markerSize, this.markerDist, this.useVehicle, this.eventInCheckpoint);
}
public void NextCheckpoint()
{
this.checkPointsDone++;

View File

@@ -1,8 +1,5 @@
using GTANetworkAPI;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Globalization;
using GTANetworkAPI;
namespace ReallifeGamemode.Server.Util
{

View File

@@ -1,10 +1,10 @@
using GTANetworkAPI;
using System.Linq;
using GTANetworkAPI;
using ReallifeGamemode.Database.Models;
using System.Linq;
namespace ReallifeGamemode.Server.Util
{
class DatabaseHelper
internal class DatabaseHelper
{
public static void InitDatabaseFirstTime()
{

View File

@@ -8,7 +8,7 @@ using ReallifeGamemode.Server.Managers;
namespace ReallifeGamemode.Server.Util
{
class FactionHelper
internal class FactionHelper
{
public static void CheckFactionBankAccounts()
{

View File

@@ -1,17 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
namespace ReallifeGamemode.Server.Util
{
class FactionRankHelper
internal class FactionRankHelper
{
public string FactionName { get; set; }
public int FactionId { get; set; }
public List<Rank> Ranks { get; set; }
}
class Rank
internal class Rank
{
public int Id { get; set; }
public string Name { get; set; }

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using GTANetworkAPI;
namespace ReallifeGamemode.Server.Util

View File

@@ -5,4 +5,4 @@
public bool Left { get; set; } = false;
public bool Right { get; set; } = false;
}
}
}

View File

@@ -1,7 +1,4 @@
using GTANetworkAPI;
using System;
using System.Collections.Generic;
using System.Text;
namespace ReallifeGamemode.Server.Util
{

View File

@@ -1,18 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
using ReallifeGamemode.Server.Wanted;
using System.Timers;
using ReallifeGamemode.Server.Finance;
using ReallifeGamemode.Server.WeaponDeal;
using ReallifeGamemode.Server.Job;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Wanted;
using ReallifeGamemode.Server.WeaponDeal;
namespace ReallifeGamemode.Server.Util
{
public class ThreadTimers
{
private static Timer timer500 = new Timer(500); //0.5 seconds timer
private static Timer timer2500 = new Timer(2500); //2.5 seconds timer
private static Timer timer10000 = new Timer(10000); // 10 second timer

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ReallifeGamemode.Server.Util
namespace ReallifeGamemode.Server.Util
{
public enum TransactionResult
{