hlmod / Shop-Core

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

Added forward Shop_OnItemRegistered #121

Closed IL0co closed 2 years ago

IL0co commented 2 years ago

All tested, works great.

Console output:

sm plugins reload shop
Shop_OnCategoryRegistered 0 test_mm
Shop_OnItemRegistered 0 test_mm 2 item_mm
Shop_OnItemRegistered 0 test_mm 4 item_mm2
[Shop] Trying to connect!
[SM] Plugin [Shop] Core reloaded successfully.```

Test plugin code:


#include <shop>
#pragma newdecls required

public void OnPluginEnd()
{
    Shop_UnregisterMe();
}

public void OnPluginStart()
{
    if(Shop_IsStarted()) {
        Shop_Started();
    }
}

public void Shop_Started()
{
    CategoryId cat_id = Shop_RegisterCategory("test_mm", "Test category", "");

    if(Shop_StartItem(cat_id,"item_mm")) {
        Shop_SetInfo("Test item methodmaps", "", 500, 400, Item_Finite);
        Shop_SetCallbacks(CallBack_OnItemRegistered, CallBack_OnItemUse);
        Shop_EndItem();
    }

    if(Shop_StartItem(cat_id,"item_mm2")) {
        Shop_SetInfo("Test item methodmaps", "", 500, 400, Item_Finite);
        Shop_SetCallbacks(CallBack_OnItemRegistered, CallBack_OnItemUse);
        Shop_EndItem();
    }

}

public void CallBack_OnItemRegistered(CategoryId category_id, const char[] category, const char[] item, ItemId item_id)
{
}

public ShopAction CallBack_OnItemUse(int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item)
{
}

public void Shop_OnCategoryRegistered(CategoryId category_id, const char[] name)
{
    PrintToServer("Shop_OnCategoryRegistered %i %s", category_id, name);
}

public void Shop_OnItemRegistered(CategoryId category_id, const char[] category, ItemId item_id, const char[] item)
{
    PrintToServer("Shop_OnItemRegistered %i %s %i %s", category_id, category, item_id, item);
}