hlmod / Shop-Core

Documentation
https://hlmod.github.io/Shop-Core/module/create/
GNU General Public License v3.0
28 stars 26 forks source link

GiveItem with type "Item_BuyOnly", "count" is always 0 #151

Closed DarklSide closed 2 years ago

DarklSide commented 2 years ago

Describe the bug https://github.com/hlmod/Shop-Core/blob/61d1489c0fb85463339d25ccd9ed5772957f65c5/addons/sourcemod/scripting/shop.sp#L1674-L1680

Expression (type == Item_Finite) ? count : duration) is always "duration":

 switch (type) 
 { 
    case Item_BuyOnly : 
    {
        (type == Item_Finite) ? count : duration)
    }

To Reproduce Steps to reproduce the behavior:

// type = Item_BuyOnly
// value/count = 1
Shop_SetInfo("name", "description", 5, -1, Item_BuyOnly, 1);
Shop_SetCallbacks(.buy = OnShop_ItemBuyCallback);
// ...
Shop_GiveClientItem(client, item_id);

Expected behavior

public bool OnShop_ItemBuyCallback(int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item, ItemType type, int price, int sell_price, int value, int gold_price, int gold_sell_price)
{
    if (value > 0)
    {
        // value/count = 1
        return true;
    }
    else
    {
        LogError("always 'duration': value = 0, value[%d]", value);
    }
    return false;
}

Server: