Raised This Month: $ Target: $400
 0% 

Issue Store Skins


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
Deathsuxs
New Member
Join Date: Jan 2014
Old 01-06-2014 , 12:51   Store Skins
#1

hello when i have everything installed correctly but i when i equip skin nothing change's players skin's stay's the same Please Help Heres the script am running CS:S V34
HTML Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <store>
#include <smjansson>
#include <smartdm>

enum Skin
{
	String:SkinName[STORE_MAX_NAME_LENGTH],
	String:SkinModelPath[PLATFORM_MAX_PATH], 
	SkinTeams[5]
}

new g_skins[1024][Skin];
new g_skinCount = 0;

new Handle:g_skinNameIndex;

new String:g_game[32];

public Plugin:myinfo =
{
    name        = "[Store] Skins",
    author      = "alongub",
    description = "Skins component for [Store]",
    version     = "1.1-alpha",
    url         = "https://github.com/alongubkin/store"
};

/**
 * Plugin is loading.
 */
public OnPluginStart()
{
	LoadTranslations("store.phrases");
	
	HookEvent("player_spawn", Event_PlayerSpawn);
	Store_RegisterItemType("skin", OnEquip, LoadItem);
	GetGameFolderName(g_game, sizeof(g_game));
}

/**
 * Map is starting
 */
public OnMapStart()
{
	for (new skin = 0; skin < g_skinCount; skin++)
	{
		if (strcmp(g_skins[skin][SkinModelPath], "") != 0 && (FileExists(g_skins[skin][SkinModelPath]) || FileExists(g_skins[skin][SkinModelPath], true)))
		{
			PrecacheModel(g_skins[skin][SkinModelPath]);
			Downloader_AddFileToDownloadsTable(g_skins[skin][SkinModelPath]);
		}
	}
}

/** 
 * Called when a new API library is loaded.
 */
public OnLibraryAdded(const String:name[])
{
	if (StrEqual(name, "store-inventory"))
	{
		Store_RegisterItemType("skin", OnEquip, LoadItem);
	}
}

public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));

	if (!IsClientInGame(client))
		return Plugin_Continue;

	if (IsFakeClient(client))
		return Plugin_Continue;

	CreateTimer(1.0, Timer_Spawn, GetClientSerial(client));
	
	return Plugin_Continue;
}

public Action:Timer_Spawn(Handle:timer, any:serial)
{
	new client = GetClientFromSerial(serial);
	
	if (client == 0)
		return Plugin_Continue;
		
	Store_GetEquippedItemsByType(Store_GetClientAccountID(client), "skin", Store_GetClientLoadout(client), OnGetPlayerSkin, serial);
	
	return Plugin_Continue;
}

public Store_OnClientLoadoutChanged(client)
{
	Store_GetEquippedItemsByType(Store_GetClientAccountID(client), "skin", Store_GetClientLoadout(client), OnGetPlayerSkin, GetClientSerial(client));
}

public OnGetPlayerSkin(ids[], count, any:serial)
{
	new client = GetClientFromSerial(serial);

	if (client == 0)
		return;
		
	if (!IsClientInGame(client))
		return;
	
	if (!IsPlayerAlive(client))
		return;
	
	new team = GetClientTeam(client);
	for (new index = 0; index < count; index++)
	{
		decl String:itemName[STORE_MAX_NAME_LENGTH];
		Store_GetItemName(ids[index], itemName, sizeof(itemName));
		
		new skin = -1;
		if (!GetTrieValue(g_skinNameIndex, itemName, skin))
		{
			PrintToChat(client, "%s%t", STORE_PREFIX, "No item attributes");
			continue;
		}

		new bool:teamAllowed = false;
		for (new teamIndex = 0; teamIndex < 5; teamIndex++)
		{
			if (g_skins[skin][SkinTeams][teamIndex] == team)
			{
				teamAllowed = true;
				break;
			}
		}


		if (!teamAllowed)
		{
			continue;
		}

		if (StrEqual(g_game, "tf"))
		{
			SetVariantString(g_skins[skin][SkinModelPath]);
			AcceptEntityInput(client, "SetCustomModel");
			SetEntProp(client, Prop_Send, "m_bUseClassAnimations", 1);
		}
		else
		{
			SetEntityModel(client, g_skins[skin][SkinModelPath]);
		}
	}
}

public Store_OnReloadItems() 
{
	if (g_skinNameIndex != INVALID_HANDLE)
		CloseHandle(g_skinNameIndex);
		
	g_skinNameIndex = CreateTrie();
	g_skinCount = 0;
}

public LoadItem(const String:itemName[], const String:attrs[])
{
	strcopy(g_skins[g_skinCount][SkinName], STORE_MAX_NAME_LENGTH, itemName);

	SetTrieValue(g_skinNameIndex, g_skins[g_skinCount][SkinName], g_skinCount);

	new Handle:json = json_load(attrs);
	json_object_get_string(json, "model", g_skins[g_skinCount][SkinModelPath], PLATFORM_MAX_PATH);

	if (strcmp(g_skins[g_skinCount][SkinModelPath], "") != 0 && (FileExists(g_skins[g_skinCount][SkinModelPath]) || FileExists(g_skins[g_skinCount][SkinModelPath], true)))
	{
		PrecacheModel(g_skins[g_skinCount][SkinModelPath]);
		Downloader_AddFileToDownloadsTable(g_skins[g_skinCount][SkinModelPath]);
	}

	new Handle:teams = json_object_get(json, "teams");

	for (new i = 0, size = json_array_size(teams); i < size; i++)
		g_skins[g_skinCount][SkinTeams][i] = json_array_get_int(teams, i);

	CloseHandle(json);

	g_skinCount++;
}

public Store_ItemUseAction:OnEquip(client, itemId, bool:equipped)
{
	if (equipped)
		return Store_UnequipItem;
	
	PrintToChat(client, "%s%t", STORE_PREFIX, "Equipped item apply next spawn");
	return Store_EquipItem;
}
Deathsuxs is offline
Deathsuxs
New Member
Join Date: Jan 2014
Old 01-06-2014 , 14:17   Re: Store Skins
#2

if you put a command to change skins instantly i think that could fix it i try'ed to do it my self but could'nt find the command for it plus am newb at editing the scripts
Deathsuxs is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 01-06-2014 , 14:31   Re: Store Skins
#3

https://forums.alliedmods.net/misc.php?do=showrules

No Steam, No Service/Help.
Drixevel is offline
Arrow768
Veteran Member
Join Date: Nov 2011
Location: Austria
Old 01-07-2014 , 11:10   Re: Store Skins
#4

Closed, because you are violating the forum rules
__________________

Last edited by Arrow768; 01-07-2014 at 11:11.
Arrow768 is offline
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:13.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode