I was trying to create a knife module for csgo store and i had some issues.
i created the plugin store-knifes and created a category and items but when trying to use shop at the server it wasnt showing this categorey or items you could only see trails category and trails was working fine.
this is the sourcecode of the plugin i made:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <store>
#include <cstrike>
new Handle:g_knifePaths = INVALID_HANDLE;
new g_knifes[MAXPLAYERS+1];
public OnPluginStart()
{
HookEvent("player_spawn",SpawnEvent);
g_knifePaths = CreateTrie();
Store_RegisterItemType("knife", OnKnifeUse, OnKnifeAttributesLoad);
}
public OnLibraryAdded(const String:name[])
{
if (StrEqual(name, "store-inventory"))
{
Store_RegisterItemType("knife", OnKnifeUse, OnKnifeAttributesLoad);
}
}
// This will be called when the attributes are loaded.
public OnKnifeAttributesLoad(const String:itemName[], const String:knifename[])
{
SetTrieString(g_knifePaths, itemName, knifename);
}
// This will be called when players use our item in their inventory.
public Store_ItemUseAction:OnKnifeUse(client, itemId, bool:equipped)
{
decl String:displayName[STORE_MAX_DISPLAY_NAME_LENGTH];
Store_GetItemDisplayName(itemId, displayName, sizeof(displayName));
if (IsClientInGame(client))
{
if (equipped)
{
PrintToChat(client, "%s%t", STORE_PREFIX, "Unequipped item", displayName);
decl String:knifeName[STORE_MAX_NAME_LENGTH];
Store_GetItemName(itemId, knifeName, sizeof(knifeName));
g_knifes[client]=0;
return Store_UnequipItem;
}
else
{
decl String:knifeName[STORE_MAX_NAME_LENGTH];
Store_GetItemName(itemId, knifeName, sizeof(knifeName));
if(StrEqual(knifeName,"bayonet")) g_knifes[client]=1;
else if(StrEqual(knifeName,"gut")) g_knifes[client]=2;
else if(StrEqual(knifeName,"flip")) g_knifes[client]=3;
else if(StrEqual(knifeName,"m9bayonet")) g_knifes[client]=4;
else if(StrEqual(knifeName,"karambit")) g_knifes[client]=5;
//else if(StrEqual(knifeName,"m9")) g_knifes[client]=2;
else if(StrEqual(knifeName,"butterfly")) g_knifes[client]=6;
else g_knifes[client]=0;
PrintToChat(client, "%s%t", STORE_PREFIX, "Equipped item", displayName);
return Store_EquipItem;
}
}
else return Store_DoNothing;
}
public Action:SpawnEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new client_id = GetEventInt(event, "userid");
new client = GetClientOfUserId(client_id);
if(!IsPlayerAlive(client)) return;
new iWeapon = GetPlayerWeaponSlot(client, 2);
if (iWeapon != INVALID_ENT_REFERENCE) return;
//if (knife_choice[client] < 0 || knife_choice[client] > 9) knife_choice[client] = 0;
//if (knife_choice[client] == 8) knife_choice[client] = 0; //Set Default Knife to 0 so default knife users bypass extra strip / equip
new iItem;
switch(g_knifes[client])
{
case 0:
{
if(GetClientTeam(client==3))iItem = GivePlayerItem(client, "weapon_knife");
else iItem = GivePlayerItem(client, "weapon_knife_t");
}
case 1:iItem = GivePlayerItem(client, "weapon_bayonet");
case 2:iItem = GivePlayerItem(client, "weapon_knife_gut");
case 3:iItem = GivePlayerItem(client, "weapon_knife_flip");
case 4:iItem = GivePlayerItem(client, "weapon_knife_m9_bayonet");
case 5:iItem = GivePlayerItem(client, "weapon_knife_karambit");
case 6:iItem = GivePlayerItem(client, "weapon_knife_tactical");
case 7:iItem = GivePlayerItem(client, "weapon_knife_butterfly");
case 8:iItem = GivePlayerItem(client, "weapon_knife");
case 9:iItem = GivePlayerItem(client, "weapon_knifegg");
default: return;
}
if (iItem > 0 && IsPlayerAlive(client) && iWeapon == INVALID_ENT_REFERENCE) EquipPlayerWeapon(client, iItem);
}
i think there is a problem with the plugin that is why its not showing the category.
how i set the category:
display name:knifes
required plugin:knifes (real plugin name is store-knifes in plugins/store folder also tried to write store-knife in required plugin)
descripton:doesnt matter
web description: doesnt matter
web color: #000000
how i set the items: (example: bayonet)
name: bayonet
display name: Bayonet
type:knife
loadout slot: i tried it empty and also 2.
price: 500
category: knifes
attributes:empty
buyable: 1
tradeable: 1
refundable: 1
i dont know what's wrong i need help pls.