Change Items , add Cooldown
This commit is contained in:
@@ -13,7 +13,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override string Description => "Ein Fisch";
|
||||
public override int Gewicht => 3600;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 786272259;
|
||||
public override int Price => 0;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 10;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 20;
|
||||
public override float Cooldown => 5000;
|
||||
public override int Price => 200;
|
||||
public override float Cooldown => 10000;
|
||||
|
||||
public override void Consume(UserItem uItem)
|
||||
{
|
||||
|
||||
@@ -4,15 +4,14 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
class AssaultRifle : WeaponDealItem
|
||||
internal class AssaultRifle : WeaponDealItem
|
||||
{
|
||||
public override int Id => 13;
|
||||
public override string Name => "AssaultRifle";
|
||||
public override string Description => "Waffe";
|
||||
public override int Gewicht => 500;
|
||||
public override string Einheit => "g";
|
||||
public override uint Object => 3666746839; //3061944032
|
||||
public override int Price => 0;
|
||||
public override int Id => 13;
|
||||
public override string Name => "AssaultRifle";
|
||||
public override string Description => "Waffe";
|
||||
public override int Gewicht => 4780;
|
||||
public override string Einheit => "g";
|
||||
public override uint Object => 3666746839; //3061944032
|
||||
public override int Price => 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,14 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
class AssaultSmg : WeaponDealItem
|
||||
internal class AssaultSmg : WeaponDealItem
|
||||
{
|
||||
public override int Id => 14;
|
||||
public override string Name => "AssaultSmg";
|
||||
public override string Description => "Waffe";
|
||||
public override int Gewicht => 500;
|
||||
public override int Gewicht => 2300;
|
||||
public override string Einheit => "g";
|
||||
public override uint Object => 3666746839; //3061944032
|
||||
public override int Price => 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
internal class Baklava : ConsumableItem
|
||||
{
|
||||
public override int Id => 104;
|
||||
public override int Id => 105;
|
||||
public override string Name => "Baklava";
|
||||
public override string Description => "Dessert für dannach.";
|
||||
public override int Gewicht => 100;
|
||||
@@ -19,7 +19,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 300;
|
||||
|
||||
public override float Cooldown => 10000;
|
||||
public override float Cooldown => 20000;
|
||||
|
||||
public override void Consume(UserItem uItem)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override string Description => "Ein Fisch";
|
||||
public override int Gewicht => 2600;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 786272259;
|
||||
public override int Price => 0;
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public override int Id => 102;
|
||||
public override string Name => "Bier";
|
||||
public override string Description => "Ein Bier";
|
||||
public override int Gewicht => 10;
|
||||
public override string Description => "Ein Kolben";
|
||||
public override int Gewicht => 500;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 10;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 20;
|
||||
public override int Price => 50;
|
||||
|
||||
public override float Cooldown => 1000;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||
@@ -8,14 +9,29 @@
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Cannabis : IDroppableItem
|
||||
public class Cannabis : ConsumableItem
|
||||
{
|
||||
public int Id => 30;
|
||||
public string Name => "Grünes Gift";
|
||||
public string Description => "puff puff and pass";
|
||||
public int Gewicht => 50;
|
||||
public string Einheit => "g";
|
||||
public uint Object => 3076948544;
|
||||
public int Price => 0;
|
||||
public override int Id => 108;
|
||||
|
||||
public override string Name => "Grünes Gift";
|
||||
|
||||
public override string Description => "puff puff and pass";
|
||||
|
||||
public override int Gewicht => 2;
|
||||
|
||||
public override string Einheit => "g";
|
||||
|
||||
public override uint Object => 3076948544;
|
||||
|
||||
public override int Price => 0;
|
||||
|
||||
public override int HpAmount => -5;
|
||||
|
||||
public override float Cooldown => 20000;
|
||||
|
||||
public override void Consume(UserItem uItem)
|
||||
{
|
||||
//nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override int Id => 6;
|
||||
public override string Name => "CarbineRifle";
|
||||
public override string Description => "Waffe";
|
||||
public override int Gewicht => 500;
|
||||
public override int Gewicht => 3200;
|
||||
public override string Einheit => "g";
|
||||
public override uint Object => 3666746839; //3061944032
|
||||
public override int Price => 0;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 150;
|
||||
public override float Cooldown => 4000;
|
||||
public override float Cooldown => 7000;
|
||||
|
||||
public override void Consume(UserItem uItem)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 5;
|
||||
|
||||
public override float Cooldown => 3500;
|
||||
public override float Cooldown => 5500;
|
||||
|
||||
public override void Consume(UserItem uItem)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Cocain : ConsumableItem
|
||||
{
|
||||
public override int Id => 31;
|
||||
public override int Id => 107;
|
||||
public override string Name => "Koks";
|
||||
public override string Description => "Rave";
|
||||
public override int Gewicht => 2;
|
||||
@@ -19,7 +19,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 0;
|
||||
|
||||
public override float Cooldown => throw new System.NotImplementedException();
|
||||
public override float Cooldown => 20000;
|
||||
|
||||
public override void Consume(UserItem uItem)
|
||||
{
|
||||
|
||||
@@ -4,15 +4,14 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
class CombatPDW : WeaponDealItem
|
||||
internal class CombatPDW : WeaponDealItem
|
||||
{
|
||||
public override int Id => 12;
|
||||
public override string Name => "CombatPDW";
|
||||
public override string Description => "Waffe";
|
||||
public override int Gewicht => 500;
|
||||
public override string Einheit => "g";
|
||||
public override uint Object => 3666746839; //3061944032
|
||||
public override int Price => 0;
|
||||
public override int Id => 12;
|
||||
public override string Name => "CombatPDW";
|
||||
public override string Description => "Waffe";
|
||||
public override int Gewicht => 2300;
|
||||
public override string Einheit => "g";
|
||||
public override uint Object => 3666746839; //3061944032
|
||||
public override int Price => 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
class Combatpstiol : WeaponDealItem
|
||||
internal class Combatpstiol : WeaponDealItem
|
||||
{
|
||||
public override int Id => 4;
|
||||
public override string Name => "Combatpistol";
|
||||
public override string Description => "Waffe";
|
||||
public override int Gewicht => 500;
|
||||
public override int Gewicht => 950;
|
||||
public override string Einheit => "g";
|
||||
public override uint Object => 3666746839; //3061944032
|
||||
public override int Price => 0;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
@@ -23,14 +25,36 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public bool Use(UserItem uItem)
|
||||
{
|
||||
User user = uItem.GetUser();
|
||||
if (user.Player.IsLoggedIn() && InventoryManager.itemCooldown.ContainsKey(user.Player))
|
||||
if (user.Player == null || !user.Player.IsLoggedIn())
|
||||
return false;
|
||||
|
||||
if (InventoryManager.itemCooldown.ContainsKey(user.Player))
|
||||
{
|
||||
uItem.GetUser().Player.TriggerEvent("Error", "Du kannst dieses Item nicht benutzen.");
|
||||
PlayerTimer timer = InventoryManager.itemCooldown[user.Player];
|
||||
int timeToNextUse = (int)(timer.startTime - DateTime.Now).TotalSeconds;
|
||||
uItem.GetUser().Player.TriggerEvent("Error", $"Versuche es nach {timeToNextUse} Sekunden erneut.");
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerTimer playerTimer = new PlayerTimer(user.Player, this, Cooldown);
|
||||
playerTimer.Elapsed += _CooldownElapse;
|
||||
InventoryManager.itemCooldown.Add(user.Player, playerTimer);
|
||||
Consume(uItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _CooldownElapse(Player player, dynamic usableItem)
|
||||
{
|
||||
NAPI.Task.Run(() =>
|
||||
{
|
||||
if (player == null || !player.IsLoggedIn())
|
||||
return;
|
||||
|
||||
if (!InventoryManager.itemCooldown.ContainsKey(player))
|
||||
return;
|
||||
|
||||
InventoryManager.itemCooldown[player].Stop();
|
||||
InventoryManager.itemCooldown.Remove(player);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public abstract class DropItem : IDroppableItem
|
||||
{
|
||||
public abstract int HpAmount { get; }
|
||||
public abstract int Id { get; }
|
||||
public abstract string Name { get; }
|
||||
public abstract string Description { get; }
|
||||
|
||||
39
ReallifeGamemode.Server/Inventory/Items/Döner.cs
Normal file
39
ReallifeGamemode.Server/Inventory/Items/Döner.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
internal class Döner : ConsumableItem
|
||||
{
|
||||
public override int Id => 106;
|
||||
public override string Name => "Döner";
|
||||
public override string Description => "Von Emre selbst gemacht.";
|
||||
public override int Gewicht => 500;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 80;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 50000;
|
||||
|
||||
public override float Cooldown => 15000;
|
||||
|
||||
public override void Consume(UserItem uItem)
|
||||
{
|
||||
Player player = uItem.GetUser().Player;
|
||||
|
||||
int amountToAdd = HpAmount;
|
||||
if (player.Health + amountToAdd > 100)
|
||||
{
|
||||
amountToAdd = 100 - player.Health;
|
||||
}
|
||||
|
||||
player.SafeSetHealth(player.Health + amountToAdd);
|
||||
player.SendNotification("Du hast ein ~y~" + Name + " ~s~gegessen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override string Description => "Ein Fisch";
|
||||
public override int Gewicht => 7700;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 786272259;
|
||||
public override int Price => 0;
|
||||
}
|
||||
|
||||
@@ -8,14 +8,18 @@
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Holz : IDroppableItem
|
||||
public class Holz : DropItem
|
||||
{
|
||||
public int Id => 32;
|
||||
public string Name => "Holz";
|
||||
public string Description => "Ich und mein Holz.";
|
||||
public int Gewicht => 650;
|
||||
public string Einheit => "g";
|
||||
public uint Object => 1805779401;
|
||||
public int Price => 0;
|
||||
public override int Id => 20;
|
||||
|
||||
public override string Name => "Holz";
|
||||
|
||||
public override string Description => "Ich und mein Holz.";
|
||||
public override int Gewicht => 650;
|
||||
public override string Einheit => "g";
|
||||
|
||||
public override uint Object => 1805779401;
|
||||
|
||||
public override int Price => 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override string Description => "Du Lachs";
|
||||
public override int Gewicht => 4200;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 786272259;
|
||||
public override int Price => 0;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override string Description => "Ein Fisch";
|
||||
public override int Gewicht => 11000;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 786272259;
|
||||
public override int Price => 0;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override string Description => "Ein Fisch";
|
||||
public override int Gewicht => 5000;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 786272259;
|
||||
public override int Price => 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user