diff --git a/addons/sourcemod/scripting/shop.sp b/addons/sourcemod/scripting/shop.sp index 362b5c1..90180c9 100644 --- a/addons/sourcemod/scripting/shop.sp +++ b/addons/sourcemod/scripting/shop.sp @@ -45,7 +45,7 @@ ConVar g_hHideCategoriesItemsCount; #include "shop/item_manager.sp" #include "shop/player_manager.sp" #if defined _SteamWorks_Included -#include "shop/stats.sp" + #include "shop/stats.sp" #endif public Plugin myinfo = @@ -1511,15 +1511,15 @@ bool RemoveItemEx(int client, const char[] sItemId, int count = 1) return PlayerManager_RemoveItemEx(client, sItemId, count); } -bool GiveItem(int client, int item_id) +bool GiveItem(int client, int item_id, int giveCount = 1) { char sItemId[16]; IntToString(item_id, sItemId, sizeof(sItemId)); - return GiveItemEx(client, sItemId); + return GiveItemEx(client, sItemId, giveCount); } -bool GiveItemEx(int client, const char[] sItemId) +bool GiveItemEx(int client, const char[] sItemId, int giveCount = 1) { int category_id, price, sell_price, count, duration; ItemType type; @@ -1536,7 +1536,7 @@ bool GiveItemEx(int client, const char[] sItemId) { char category[SHOP_MAX_STRING_LENGTH]; ItemManager_GetCategoryById(category_id, category, sizeof(category)); - if (!ItemManager_OnItemBuyEx(client, category_id, category, StringToInt(sItemId), item, type, price, sell_price, (type == Item_Finite) ? count : duration)) + if (!ItemManager_OnItemBuyEx(client, category_id, category, StringToInt(sItemId), item, type, price, sell_price, (type == Item_Finite) ? giveCount : duration)) { return false; } @@ -1546,7 +1546,9 @@ bool GiveItemEx(int client, const char[] sItemId) { if (ClientHasItemEx(client, sItemId)) { - return false; + int timeleft = PlayerManager_GetItemTimeleftEx(client, sItemId); + if(timeleft <= 0) return true; // Do not change a time of an infinite item + return PlayerManager_SetItemTimeleftEx(client, sItemId, timeleft + duration * giveCount); } } } diff --git a/addons/sourcemod/scripting/shop/player_manager.sp b/addons/sourcemod/scripting/shop/player_manager.sp index d12f914..b94a56f 100644 --- a/addons/sourcemod/scripting/shop/player_manager.sp +++ b/addons/sourcemod/scripting/shop/player_manager.sp @@ -142,9 +142,7 @@ public int PlayerManager_GiveClientItem(Handle plugin, int numParams) ThrowNativeError(SP_ERROR_NATIVE, error); } - int item_id = GetNativeCell(2); - - return GiveItem(client, item_id); + return GiveItem(client, GetNativeCell(2), GetNativeCell(3)); } public int PlayerManager_BuyClientItem(Handle plugin, int numParams) @@ -155,9 +153,7 @@ public int PlayerManager_BuyClientItem(Handle plugin, int numParams) if (!CheckClient(client, error, sizeof(error))) ThrowNativeError(SP_ERROR_NATIVE, error); - int item_id = GetNativeCell(2); - - return BuyItem(client, item_id, true); + return BuyItem(client, GetNativeCell(2), true); } public int PlayerManager_SellClientItem(Handle plugin, int numParams) @@ -170,9 +166,7 @@ public int PlayerManager_SellClientItem(Handle plugin, int numParams) ThrowNativeError(SP_ERROR_NATIVE, error); } - int item_id = GetNativeCell(2); - - return SellItem(client, item_id); + return SellItem(client, GetNativeCell(2)); } public int PlayerManager_UseClientItem(Handle plugin, int numParams) @@ -183,9 +177,7 @@ public int PlayerManager_UseClientItem(Handle plugin, int numParams) if (!CheckClient(client, error, sizeof(error))) ThrowNativeError(SP_ERROR_NATIVE, error); - int item_id = GetNativeCell(2); - - return UseItem(client, item_id, true); + return UseItem(client, GetNativeCell(2), true); } public int PlayerManager_RemoveClientItem(Handle plugin, int numParams) @@ -196,10 +188,7 @@ public int PlayerManager_RemoveClientItem(Handle plugin, int numParams) if (!CheckClient(client, error, sizeof(error))) ThrowNativeError(SP_ERROR_NATIVE, error); - int item_id = GetNativeCell(2); - int count = GetNativeCell(3); - - return PlayerManager_RemoveItem(client, item_id, count); + return PlayerManager_RemoveItem(client, GetNativeCell(2), GetNativeCell(3)); } public int PlayerManager_GetClientItemCount(Handle plugin, int numParams) @@ -210,9 +199,7 @@ public int PlayerManager_GetClientItemCount(Handle plugin, int numParams) if (!CheckClient(client, error, sizeof(error))) ThrowNativeError(SP_ERROR_NATIVE, error); - int item_id = GetNativeCell(2); - - return PlayerManager_GetItemCount(client, item_id); + return PlayerManager_GetItemCount(client, GetNativeCell(2)); } public int PlayerManager_SetClientItemCount(Handle plugin, int numParams) @@ -223,9 +210,7 @@ public int PlayerManager_SetClientItemCount(Handle plugin, int numParams) if (!CheckClient(client, error, sizeof(error))) ThrowNativeError(SP_ERROR_NATIVE, error); - int item_id = GetNativeCell(2); - - PlayerManager_SetItemCount(client, item_id, GetNativeCell(3)); + PlayerManager_SetItemCount(client, GetNativeCell(2), GetNativeCell(3)); } public int PlayerManager_GetClientItemSellPrice(Handle plugin, int numParams) @@ -236,9 +221,7 @@ public int PlayerManager_GetClientItemSellPrice(Handle plugin, int numParams) if (!CheckClient(client, error, sizeof(error))) ThrowNativeError(SP_ERROR_NATIVE, error); - int item_id = GetNativeCell(2); - - return PlayerManager_GetItemSellPrice(client, item_id); + return PlayerManager_GetItemSellPrice(client, GetNativeCell(2)); } public int PlayerManager_SetClientItemTimeleft(Handle plugin, int numParams) @@ -275,9 +258,7 @@ public int PlayerManager_IsClientItemToggled(Handle plugin, int numParams) if (!CheckClient(client, error, sizeof(error))) ThrowNativeError(SP_ERROR_NATIVE, error); - int item_id = GetNativeCell(2); - - return PlayerManager_IsItemToggled(client, item_id); + return PlayerManager_IsItemToggled(client, GetNativeCell(2)); } public int PlayerManager_IsClientHasItem(Handle plugin, int numParams) @@ -288,9 +269,7 @@ public int PlayerManager_IsClientHasItem(Handle plugin, int numParams) if (!CheckClient(client, error, sizeof(error))) ThrowNativeError(SP_ERROR_NATIVE, error); - int item_id = GetNativeCell(2); - - return PlayerManager_ClientHasItem(client, item_id); + return PlayerManager_ClientHasItem(client, GetNativeCell(2)); } public int PlayerManager_ToggleClientItem(Handle plugin, int numParams) @@ -301,10 +280,7 @@ public int PlayerManager_ToggleClientItem(Handle plugin, int numParams) if (!CheckClient(client, error, sizeof(error))) ThrowNativeError(SP_ERROR_NATIVE, error); - int item_id = GetNativeCell(2); - ToggleState toggle = GetNativeCell(3); - - return ToggleItem(client, item_id, toggle, true); + return ToggleItem(client, GetNativeCell(2), GetNativeCell(3), true); } void PlayerManager_OnPluginStart() @@ -601,12 +577,12 @@ public int PlayerManager_ToggleClientCategoryOff(Handle plugin, int numParams) if (!CheckClient(client, error, sizeof(error))) ThrowNativeError(SP_ERROR_NATIVE, error); - int category_id = GetNativeCell(2); - h_KvClientItems[client].Rewind(); if (!h_KvClientItems[client].GotoFirstSubKey()) return; + int category_id = GetNativeCell(2); + char sItemId[16]; do { diff --git a/addons/sourcemod/scripting/shop/stats.sp b/addons/sourcemod/scripting/shop/stats.sp index c70b45c..fff5395 100644 --- a/addons/sourcemod/scripting/shop/stats.sp +++ b/addons/sourcemod/scripting/shop/stats.sp @@ -2,9 +2,9 @@ stock const char API_KEY[] = "e34fa2f3adb922bf76fb7b06807caa3c"; stock const char URL[] = "http://stats.tibari.ru/api/v1/add_server"; /* Stats pusher */ -public int SteamWorks_SteamServersConnected() +public void SteamWorks_SteamServersConnected() { - int iIp[4]; + char iIp[4]; // Get ip if (SteamWorks_GetPublicIP(iIp))