Skip to content

Commit

Permalink
Database api added
Browse files Browse the repository at this point in the history
  • Loading branch information
schwarper authored Jun 10, 2024
1 parent d5b5936 commit 4b38e18
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
5 changes: 5 additions & 0 deletions Store/src/api/api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public StoreAPI()
{
}

public string GetDatabaseString()
{
return Database.GlobalDatabaseConnectionString;
}

public int GetPlayerCredits(CCSPlayerController player)
{
return Credits.Get(player);
Expand Down
1 change: 0 additions & 1 deletion Store/src/menu/WASDMenu/Classes/WasdMenuPlayer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using Microsoft.Extensions.Localization;
using System.Text;
using static Store.Store;

Expand Down
16 changes: 7 additions & 9 deletions Store/src/menu/menu.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Capabilities;
using CounterStrikeSharp.API.Core.Translations;
using CounterStrikeSharp.API.Modules.Menu;
using System.Globalization;
using System.Text;
using static CounterStrikeSharp.API.Core.Listeners;
Expand All @@ -19,7 +17,7 @@ public static void SetSettings(bool hotReload)
{
Instance.RegisterEventHandler<EventPlayerActivate>((@event, info) =>
{
var player = @event.Userid;
CCSPlayerController? player = @event.Userid;

if (player == null)
{
Expand All @@ -37,7 +35,7 @@ public static void SetSettings(bool hotReload)

Instance.RegisterEventHandler<EventPlayerDisconnect>((@event, info) =>
{
var player = @event.Userid;
CCSPlayerController? player = @event.Userid;

if (player == null)
{
Expand Down Expand Up @@ -82,7 +80,7 @@ public static void DisplayStore(CCSPlayerController player, bool inventory)
StringBuilder builder = new();
builder.AppendFormat(Instance.Localizer["menu_store<title>", Credits.Get(player)]);

var menu = WasdManager.CreateMenu(builder.ToString());
IWasdMenu menu = WasdManager.CreateMenu(builder.ToString());

foreach (KeyValuePair<string, Dictionary<string, Dictionary<string, string>>> category in Instance.Config.Items)
{
Expand Down Expand Up @@ -110,8 +108,8 @@ public static void DisplayItems(CCSPlayerController player, string key, Dictiona

if (playerSkinItems.Count != 0)
{
var menu = WasdManager.CreateMenu(key);
if(prev != null)
IWasdMenu menu = WasdManager.CreateMenu(key);
if (prev != null)
menu.Prev = prev.Parent?.Options?.Find(prev);

foreach (int Slot in new[] { 2, 3 })
Expand Down Expand Up @@ -143,7 +141,7 @@ public static void DisplayItems(CCSPlayerController player, string key, Dictiona

public static void DisplayItem(CCSPlayerController player, bool inventory, string key, Dictionary<string, Dictionary<string, string>> items, IWasdMenuOption? prev = null)
{
var menu = WasdManager.CreateMenu(key);
IWasdMenu menu = WasdManager.CreateMenu(key);
if (prev != null)
menu.Prev = prev.Parent?.Options?.Find(prev);

Expand Down Expand Up @@ -190,7 +188,7 @@ public static void DisplayItem(CCSPlayerController player, bool inventory, strin

public static void DisplayItemOption(CCSPlayerController player, Dictionary<string, string> item, IWasdMenuOption? prev = null)
{
var menu = WasdManager.CreateMenu(item["name"]);
IWasdMenu menu = WasdManager.CreateMenu(item["name"]);
if (prev != null)
menu.Prev = prev.Parent?.Options?.Find(prev);

Expand Down
1 change: 1 addition & 0 deletions StoreApi/IStoreApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface IStoreApi
{
public static readonly PluginCapability<IStoreApi?> Capability = new("store:api");

public string GetDatabaseString();
public int GetPlayerCredits(CCSPlayerController player);
public int SetPlayerCredits(CCSPlayerController player, int credits);
public int GetPlayerOriginalCredits(CCSPlayerController player);
Expand Down

0 comments on commit 4b38e18

Please sign in to comment.