change stuff with objects
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||
{
|
||||
public interface IUsableItem : IItem, IDroppableItem
|
||||
public interface IUsableItem : IItem, IDroppableItem //marker Interface
|
||||
{
|
||||
void Use(UserItem uItem);
|
||||
bool Use(UserItem uItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,38 @@
|
||||
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
|
||||
{
|
||||
class Apfel : FoodItem
|
||||
internal class Apfel : ConsumableItem
|
||||
{
|
||||
public override int Id => 101;
|
||||
public override string Name => "Apfel";
|
||||
public override string Description => "Ein Apfel";
|
||||
public override int Gewicht => 10;
|
||||
public override int Gewicht => 200;
|
||||
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 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 einen ~y~" + Name + " ~s~gegessen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +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
|
||||
{
|
||||
class AChips : FoodItem
|
||||
internal class AChips : ConsumableItem
|
||||
{
|
||||
public override int Id => 104;
|
||||
public override string Name => "Aviates Chips";
|
||||
public override string Name => "aviates Chips";
|
||||
public override string Description => "aviate liebt sie.";
|
||||
public override int Gewicht => 10;
|
||||
public override int Gewicht => 200;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 10;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 20;
|
||||
public override int Price => 1000;
|
||||
|
||||
public override float Cooldown => 5000;
|
||||
|
||||
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 ~y~" + Name + " ~s~gegessen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
39
ReallifeGamemode.Server/Inventory/Items/Baklava.cs
Normal file
39
ReallifeGamemode.Server/Inventory/Items/Baklava.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 Baklava : ConsumableItem
|
||||
{
|
||||
public override int Id => 104;
|
||||
public override string Name => "Baklava";
|
||||
public override string Description => "Dessert für dannach.";
|
||||
public override int Gewicht => 100;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 30;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 300;
|
||||
|
||||
public override float Cooldown => 10000;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
class Bier : FoodItem
|
||||
internal class Bier : ConsumableItem
|
||||
{
|
||||
public override int Id => 102;
|
||||
public override string Name => "Bier";
|
||||
@@ -14,5 +15,12 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public override int HpAmount => 10;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 20;
|
||||
|
||||
public override float Cooldown => 1000;
|
||||
|
||||
public override void Consume(UserItem uItem)
|
||||
{
|
||||
//nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/**
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Cheeseburger (Cheeseburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
@@ -6,15 +11,31 @@
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Cheeseburger : FoodItem
|
||||
public class Cheeseburger : ConsumableItem
|
||||
{
|
||||
public override int Id => 103;
|
||||
public override string Name => "Cheeseburger";
|
||||
public override string Description => "Ein Burger";
|
||||
public override int Gewicht => 50;
|
||||
public override int Gewicht => 120;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 100;
|
||||
public override int Price => 150;
|
||||
public override float Cooldown => 4000;
|
||||
|
||||
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 einen ~y~" + Name + " ~s~gegessen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +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
|
||||
{
|
||||
class Chips : FoodItem
|
||||
internal class Chips : ConsumableItem
|
||||
{
|
||||
public override int Id => 100;
|
||||
public override string Name => "Chips";
|
||||
public override string Description => "Eine tüte Chips";
|
||||
public override int Gewicht => 10;
|
||||
public override int Gewicht => 180;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 10;
|
||||
public override int HpAmount => 5;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 20;
|
||||
public override int Price => 5;
|
||||
|
||||
public override float Cooldown => 3500;
|
||||
|
||||
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 ~y~" + Name + " ~s~gegessen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
/**
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Inventory Items Chickenburger (Chickenburger.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
@@ -6,15 +8,22 @@
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Cocain : FoodItem
|
||||
public class Cocain : ConsumableItem
|
||||
{
|
||||
public override int Id => 31;
|
||||
public override string Name => "Kosks";
|
||||
public override string Name => "Koks";
|
||||
public override string Description => "Rave";
|
||||
public override int Gewicht => 50;
|
||||
public override int Gewicht => 2;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 25;
|
||||
public override int HpAmount => -5;
|
||||
public override uint Object => 2240524752;
|
||||
public override int Price => 0;
|
||||
|
||||
public override float Cooldown => throw new System.NotImplementedException();
|
||||
|
||||
public override void Consume(UserItem uItem)
|
||||
{
|
||||
//nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using ReallifeGamemode.Server.Managers;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public abstract class FoodItem : IUsableItem
|
||||
public abstract class ConsumableItem : IUsableItem
|
||||
{
|
||||
public abstract int HpAmount { get; }
|
||||
public abstract int Id { get; }
|
||||
@@ -16,20 +16,21 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public abstract string Einheit { get; }
|
||||
public abstract uint Object { get; }
|
||||
public abstract int Price { get; }
|
||||
public abstract float Cooldown { get; }
|
||||
|
||||
public void Use(UserItem uItem)
|
||||
public abstract void Consume(UserItem uItem);
|
||||
|
||||
public bool Use(UserItem uItem)
|
||||
{
|
||||
Player player = uItem.GetUser().Player;
|
||||
|
||||
int amountToAdd = HpAmount;
|
||||
if (player.Health + amountToAdd > 100)
|
||||
User user = uItem.GetUser();
|
||||
if (user.Player.IsLoggedIn() && InventoryManager.itemCooldown.ContainsKey(user.Player))
|
||||
{
|
||||
amountToAdd = 100 - player.Health;
|
||||
uItem.GetUser().Player.TriggerEvent("Error", "Du kannst dieses Item nicht benutzen.");
|
||||
return false;
|
||||
}
|
||||
|
||||
player.SafeSetHealth(player.Health + amountToAdd);
|
||||
player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
Consume(uItem);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,13 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
public abstract uint Object { get; }
|
||||
public abstract int Price { get; }
|
||||
|
||||
public void Use(UserItem uItem)
|
||||
public bool Use(UserItem uItem)
|
||||
{
|
||||
Player player = uItem.GetUser().Player;
|
||||
|
||||
if (uItem.ItemId != 200)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
Random random = new Random();
|
||||
int randomNumber = random.Next(1, 5);
|
||||
@@ -47,6 +47,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
}
|
||||
player.SendNotification("Du hast ~g~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~verwendet.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user