有关 Store 内置模块 以及 案例说明

版本需求

  • 3.04或以上
  • 控制台使用命令 sm_rcon sm plugins info store 显示版本信息
  • 在3.04之后 增加了动态加载配置文件功能

加载文件

默认情况下遍历加载所有名称为 addons/sourcemod/configs/store/items_xxxx.txt 【仅在服务器启动时】
您可以手动加载您的配置以实现按顺序(命令:store_load_item_config my_123.txt ) 自定义文件名 不要包含 items_
请注意 为了防止冲突 每个文件路径只能加载一次 使用 store_reload_config 命令 进行清空后 再加载!

  • 您可以加入参数中

通用配置集

参数名 用途
price 价格定义 “price” “6666”
flag 道具限制权限 “flag” “a”
unique_id 数据库储存道具唯一解锁ID(确保唯一) 判断用户 张三 有没有这个道具的依据 “unique_id” “abcd1234”
Plans 使道具可以按时间过期 数组用法 请看配置样本
time 道具过期时间 按秒计算 配合Plans使用
"Store"
{
    "VIP权限服务"
    {
        "普通VIP-flag-a"
        {
            "flags"        "a"
            "type"        "admin"
            "unique_id"        "vip_a"
            "Plans"
            {
                "30天"
                {
                    "price"        "1000"
                    "time"        "2592000"
                }
                "无限"
                {
                    "price"        "9999"
                    "time"        "0"
                }
            }
        }
    }
}

内置模块

模块类型type 用途 模块属性集 必须项
playerskin 人物皮肤模型 “model”,”arms”,”team”,”model_path”,”material_path”,”bodyindex”,”skinindex”,”gender” “model” (模型文件)
namecolor 聊天名称颜色 “color” 所有
nametag 聊天标签 “color” 所有
msgcolor 聊天消息颜色 “color” 所有
admin 权限/VIP等 “flags” 所有
trails 足迹 “material” 所有(材质文件)
CustomWeaponModel 自定义武器模型(Store 3.04+) “model”,”worldmodel”,”dropmodel”,”model_grenade_thorw”,”model_path”,”material_path”,”sndpath”,”entclass”,”slot”,”weaponslot” “model”,”entclass”,”slot” (模型文件,实体名(如weapon_ak47),Store装备插槽(同武器请相同)
paintball 彩色弹孔 “material” 所有(材质文件)
tracer 激光弹道 “color”,”rainbow” 颜色代码RGB(如 “color” “138 43 226”,如需随机色 添加 “rainbow” “1”)
facemask 面部饰品 “model” “model” (模型文件)
pets 跟随宠物 “model” “model” (模型文件)
spray 喷漆 “material” “material” (材质文件)
zr_zombieskin 僵尸皮肤(暂时未开放 适用于ZR插件) “model” “model” (模型文件)

面向开发者内容:

您可以根据API开发外置插件

  • 注册新的类型,以添加物品.
  • 比如 实现道具交易,赠送 积分增加等等.
#if defined _store_included
    #endinput
#endif
#define _store_included

int g_cvarChatTag = -1;
#define CHAT_TAG g_eCvars[g_cvarChatTag].sCache

#define ITEM_NAME_LENGTH 128
#define STORE_MAX_ITEMS 2048
#define STORE_MAX_HANDLERS 64
#define STORE_MAX_PLANS 8
#define STORE_MAX_SLOTS 32
#define STORE_ITEM_MAX_PRICE 999999

#define LoadedStats_LoadCredits 1
#define LoadedStats_LoadClientInventory_Items 2
#define LoadedStats_LoadClientInventory_Equipment 3

enum struct Item_Plan
{
    char szName[ITEM_NAME_LENGTH];
    int iPrice;
    int iTime;
}

enum struct Store_Item
{
    char szName[ITEM_NAME_LENGTH];
    char szUniqueId[PLATFORM_MAX_PATH];
    char szShortcut[64];
    int iId;
    int iPrice;
    int iParent;
    int iHandler;
    int iFlagBits;
    int iData;
    int iPlans;
    bool bBuyable;
    bool bIgnoreVIP;
    Handle hAttributes;
    char szItemNote[100];
    bool bException_Free;
    char szAvailable_server_type[64];
    char szUnAvailable_server_type[64];
    bool bDisable;
    int iSlot;
    bool bGroupItem;
}

enum struct Type_Handler
{
    char szType[64];
    char szUniqueKey[32];
    bool bEquipable;
    bool bRaw;
    Handle hPlugin;
    Function fnMapStart;
    Function fnReset;
    Function fnConfig;
    Function fnUse;
    Function fnRemove;
}

enum struct Client_Item
{
    int iId;
    int iUniqueId;
    bool bSynced;
    bool bDeleted;
    int iDateOfPurchase;
    int iDateOfExpiration;
    int iPriceOfPurchase;
}

native Store_RegisterHandler(String:type[], String:uniquekey[], Function:mapstart, Function:reset, Function:config, Function:use, Function:remove, bool:equipable = true, bool:raw = false);
native Store_RegisterMenuHandler(String:identifier[], Function:menu, Function:handler);
native Store_SetDataIndex(itemid, index);
native Store_GetDataIndex(itemid);
native Store_GetEquippedItem(client, String:type[], slot=0);
native Store_IsClientLoaded(client);
native Store_IsClientFullLoaded(client);
native Store_DisplayPreviousMenu(client);
native Store_SetClientMenu(client, num);
native Store_GetClientCredits(client);
native Store_SetClientCredits(client, credits);
native Store_IsClientVIP(client);
native Store_IsItemInBoughtPackage(client, itemid, uid=-1);
native Store_ShouldConfirm();
native Store_DisplayConfirmMenu(client, String:title[], Function:callback, data);
native int Store_GetItem(int itemid, any output[sizeof(Store_Item)]);
native void Store_GetHandler(int index, any output[sizeof(Type_Handler)]);
native Store_GiveItem(client, itemid, purchase=0, expiration=0, price=0);
native Store_RemoveItem(client, itemid);
native bool Store_GetClientItem(int client, int itemid, any output[sizeof(Client_Item)]);
native Store_GetClientTarget(client);
native Store_GiveClientItem(client, recipient, itemid);
native Store_HasClientItem(client, itemid);
native Store_IterateEquippedItems(client, &start, bool:attributes=false);
native Store_ReloadClient(int client);
native Store_GiveItemByUniqueId(int client, const char[] C_UniqueId, int C_purchase, int C_expiration, int C_price);
native Store_SetPlayerSkinVIP(int client,bool bVIP);
native void Store_SetItemNote(int itemid,const char[] sNote);
native void Store_SetItemName(int itemid,const char[] sName);
native int Store_GetItemIdByUniqueId(const char[] m_szUniqueId);//通过uniqueid  得到物品ID
native void Store_SetItemExceptionFree(int itemid); //设置物品忽略免费解锁 例如是活动物品


// forwards
forward Action Store_OnClientModelChanged(client, const char[] szModelPath,bool bIsArmsModel);
forward void Store_OnItemEquipPost(client, const char[] szType,const char[] m_szUniqueId,const char [] szitemName);//装备物品
forward void Store_OnItemUnEquipPost(client, const char[] szType,const char[] m_szUniqueId,const char [] szitemName);//取消装备物品
forward void Store_OnClientLoaded(int client,int Loadstats);
forward Action Store_OnInventoryLoad_Pre(int client,const char[] szType,const char[] m_szUniqueId);

//配置加载完成 Total_items 代表物品总数
forward void Store_OnConfigLoaded(int Total_items);

//如果 return Plugin_Changed; 则视为拥有. 默认请 return Plugin_Continue;
forward Action Store_OnClientHasItem_Pre(int client,int itemid,const char[] szType,const char[] m_szUniqueId);

//人物皮肤应用完成.
forward void Store_OnPlayerSkinAlreadyApplied(int client,bool is_arms,const char[] sModel,const char[] sArms,int iBodyID,int iSkinId,int iGender);

public SharedPlugin __pl_store = 
{
    name = "store",
    file = "store.smx",
#if defined REQUIRE_PLUGIN
    required = 1,
#else
    required = 0,
#endif
};

#if !defined REQUIRE_PLUGIN
public void __pl_store_SetNTVOptional()
{
    MarkNativeAsOptional("Store_GetDataIndex");
    MarkNativeAsOptional("Store_GetEquippedItem");
    MarkNativeAsOptional("Store_IsClientLoaded");
    MarkNativeAsOptional("Store_IsClientFullLoaded");
    MarkNativeAsOptional("Store_DisplayPreviousMenu");
    MarkNativeAsOptional("Store_SetClientMenu");
    MarkNativeAsOptional("Store_GetClientCredits");
    MarkNativeAsOptional("Store_SetClientCredits");
    MarkNativeAsOptional("Store_IsClientVIP");
    MarkNativeAsOptional("Store_IsItemInBoughtPackage");
    MarkNativeAsOptional("Store_ShouldConfirm");
    MarkNativeAsOptional("Store_DisplayConfirmMenu");
    MarkNativeAsOptional("Store_GetItem");
    MarkNativeAsOptional("Store_GetHandler");
    MarkNativeAsOptional("Store_GiveItem");
    MarkNativeAsOptional("Store_RemoveItem");
    MarkNativeAsOptional("Store_GetClientItem");
    MarkNativeAsOptional("Store_GetClientTarget");
    MarkNativeAsOptional("Store_GiveClientItem");
    MarkNativeAsOptional("Store_HasClientItem");
    MarkNativeAsOptional("Store_IterateEquippedItems");
    MarkNativeAsOptional("Store_ReloadClient");
    MarkNativeAsOptional("Store_GiveItemByUniqueId");
    MarkNativeAsOptional("Store_SetPlayerSkinVIP");
    MarkNativeAsOptional("Store_SetItemNote");
    MarkNativeAsOptional("Store_SetItemName");
    MarkNativeAsOptional("Store_GetItemIdByUniqueId");
    MarkNativeAsOptional("Store_SetItemExceptionFree");

}
#endif
作者:admin  创建时间:2023-01-30 11:11
最后编辑:admin  更新时间:2024-09-25 02:22