Raised This Month: $32 Target: $400
 8% 

[Bug Fix] Players Can't Join Because of This Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Snake.
Senior Member
Join Date: Jul 2017
Old 08-17-2022 , 08:27   [Bug Fix] Players Can't Join Because of This Plugin
Reply With Quote #1

Hello, i got a plugin which has a problem that cause players not to enter the server even though the server is running. It makes players quit on the half of loading. Here how the problem occurs: When i add { "Abstract", 400, "models/usp/v_usp_abstract.mdl", "models/p_usp.mdl" }, to new const USPSkins[][skin_e], i can't enter the server even though it's running. There is no model error or 512 limit.

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <hamsandwich>
#include <fvault>
#include <fakemeta>

#define MAX_PLAYERS 32

#pragma compress 1

native back_skin_menu( id )

new const SkinVault[] = "DeathRun_USP_Knife";

new g_bitOwnedUSPs[MAX_PLAYERS+1], g_iEquippedUSP[MAX_PLAYERS+1]
new g_bitOwnedKnifes[MAX_PLAYERS+1], g_iEquippedKnife[MAX_PLAYERS+1]


#define BIT(%0) (1<<%0)

native get_dr_points( id )
native set_dr_points( id, amount )

new g_iUID[ 33 ]

enum _:skin_e
{
	SKIN_NAME[32],
	SKIN_COST,
	SKIN_V_MODEL[64],
	SKIN_P_MODEL[64],
};


new const USPSkins[][skin_e] =
{
	{ "Default USP" }, // Always keep this USP
	{ "Fov USP", 100, "models/usp/v_usp_fov.mdl", "models/p_usp.mdl" },
	{ "Laser USP", 150, "models/usp/v_usp_laser.mdl", "models/p_usp.mdl" },
	{ "No Hand USP", 200, "models/usp/v_no_hand.mdl", "models/p_usp.mdl" },
	{ "Chrome Slide", 250, "models/usp/v_chrome_slide.mdl", "models/p_usp.mdl" },
	{ "Guardian", 300, "models/usp/v_guardian.mdl", "models/p_usp.mdl" },
	{ "Black Sleeve", 350, "models/usp/v_black_sleeve.mdl", "models/p_usp.mdl" },
	{ "Brutal Sleeve", 380, "models/usp/v_brutal_sleeve.mdl", "models/p_usp.mdl" },
};
new const KnifeSkins[][skin_e] =
{
	{ "Default Knife" }, // Always keep this Knife
	{ "Fov Knife", 100, "models/knife/v_knife_fov.mdl", "models/p_knife.mdl" },
	{ "Spiderman", 150, "models/knife/v_spiderman.mdl", "models/p_knife.mdl" },
	{ "Blue", 200, "models/knife/v_blue_default.mdl", "models/p_knife.mdl" },
	{ "Veteran", 250, "models/knife/v_veteran.mdl", "models/p_knife.mdl" },
	{ "Among Us", 300, "models/knife/v_among.mdl", "models/p_knife.mdl" },
	{ "Gray KZ", 400, "models/knife/v_graykz.mdl", "models/p_knife.mdl" },
	{ "Fire Carbon", 450, "models/knife/v_fire_carbon.mdl", "models/p_knife.mdl" },
	{ "Tattoo", 550, "models/knife/v_tattoo.mdl", "models/p_knife.mdl" },
	{ "Tattoo White", 600, "models/knife/v_tattoo_white.mdl", "models/p_knife.mdl" },
	{ "Black&White", 650, "models/knife/v_blackwhite.mdl", "models/p_knife.mdl" },
	{ "Blue Lori", 700, "models/knife/v_bluelori.mdl", "models/p_knife.mdl" },
	{ "Orange Commander", 750, "models/knife/v_orangecoma.mdl", "models/p_knife.mdl" },
	{ "Venom", 800, "models/knife/v_venom.mdl", "models/p_knife.mdl" },
	{ "Kreedz", 850, "models/knife/v_kz.mdl", "models/p_knife.mdl" },
	{ "Foot Red", 900, "models/knife/v_footred.mdl", "models/p_knife.mdl" },
	{ "Razer", 1000, "models/knife/v_razer.mdl", "models/p_knife.mdl" },
	{ "Sharp", 1500, "models/knife/v_sharp.mdl", "models/p_knife.mdl" },
	{ "Bayonet Safari", 2000, "models/knife/v_bayonet_safari.mdl", "models/p_knife.mdl" },
};


public plugin_init()
{
	register_plugin( "DR Usp/Knife Menu", "1.0", "author" )
	RegisterHam( Ham_Item_Deploy, "weapon_usp", "CUSP_Deploy_Post", true )
	RegisterHam( Ham_Item_Deploy, "weapon_knife", "CKnife_Deploy_Post", true )
	register_dictionary( "deathrun.txt" )
	set_task( 3.0, "curl_example", 0 )
}
public plugin_natives()
{
	register_native( "usp_menu", "USPMenu", 1 )
	register_native( "knife_menu", "KnifeMenu", 1 )
}
public plugin_precache()
{
	for (new i = 0; i < sizeof USPSkins; i++)
	{
		if (USPSkins[i][SKIN_V_MODEL][0])
			precache_model(USPSkins[i][SKIN_V_MODEL]);

		if (USPSkins[i][SKIN_P_MODEL][0])
			precache_model(USPSkins[i][SKIN_P_MODEL]);
	}
	for( new i; i < sizeof KnifeSkins; i++ )
	{
		if( KnifeSkins[ i ][ SKIN_V_MODEL ][ 0 ] )
			precache_model( KnifeSkins[ i ][ SKIN_V_MODEL ] )
		if( KnifeSkins[ i ][ SKIN_P_MODEL ][ 0 ] )
			precache_model( KnifeSkins[ i ][ SKIN_P_MODEL ] )
	}
}

public client_putinserver( id )
{
	g_iUID[ id ] = get_user_userid( id )

	g_bitOwnedUSPs[ id ] = 0;
	g_iEquippedUSP[ id ] = 0;
	g_bitOwnedKnifes[ id ] = 0
	g_iEquippedKnife[ id ] = 0

	if( !is_user_bot( id ) || !is_user_hltv( id ) )
		LoadPlayerData(id, g_iUID[ id ]);
}
public client_disconnected( id )
{
	if( g_bitOwnedUSPs[ id ] != 0 || g_bitOwnedKnifes[ id ] != 0 )
		SavePlayerData(id, g_iUID[ id ] );
}

LoadPlayerData(id, uid)
{
	new szAuthId[35];
	get_user_authid(id, szAuthId, charsmax(szAuthId));

	new uid1 = get_user_userid( id )

	if (!szAuthId[0])
		return;

	new szBuffer[56], data[5][15];

	if (fvault_get_data(SkinVault, szAuthId, szBuffer, charsmax(szBuffer)))
	{
		if( uid1 != uid )
			return

		parse(szBuffer, data[0], charsmax(data[]), data[1], charsmax(data[]), data[2], charsmax(data[]), data[3], charsmax(data[]));
		g_iEquippedUSP[id] = str_to_num(data[0]);
		g_bitOwnedUSPs[id] = str_to_num(data[1]);
		g_iEquippedKnife[id] = str_to_num(data[2]);
		g_bitOwnedKnifes[id] = str_to_num(data[3]);
	}

}

SavePlayerData(id, uid)
{
	new szAuthId[35];
	get_user_authid(id, szAuthId, charsmax(szAuthId));

	new szBuffer[56];

	if( uid == get_user_userid( id ) )
	{
		formatex(szBuffer, charsmax(szBuffer), "%d %d %d %d", g_iEquippedUSP[id], g_bitOwnedUSPs[id], g_iEquippedKnife[id], g_bitOwnedKnifes[id]);
		fvault_pset_data(SkinVault, szAuthId, szBuffer);
	}
}
public USPMenu(id)
{
	new szBuffer[96];

	//formatex(szBuffer, charsmax(szBuffer), "USP Skins^n\dYour Points:\y %d", get_dr_points( id ));
	formatex(szBuffer, charsmax(szBuffer), fmt( "%L", id, "USP_SKIN_TITLE", get_dr_points( id )));

	new iMenu = menu_create(szBuffer, "USPMenu_Handler");

	new szItemInfo[3], iLen;

	for (new i = 0; i < sizeof USPSkins; i++)
	{
		iLen = 0;

		if (!(g_bitOwnedUSPs[id] & BIT(i)) && USPSkins[i][SKIN_COST] && get_dr_points( id ) < USPSkins[i][SKIN_COST])
			iLen = copy(szBuffer, charsmax(szBuffer), "\d");
		else if (g_iEquippedUSP[id] == i)
			iLen = copy(szBuffer, charsmax(szBuffer), "\r");

		iLen += copy(szBuffer[iLen], charsmax(szBuffer)-iLen, USPSkins[i][SKIN_NAME]);

		if (g_bitOwnedUSPs[id] & BIT(i))
			//iLen += formatex(szBuffer[iLen], charsmax(szBuffer)-iLen, "\y [ OWNED ]" );
			iLen += formatex(szBuffer[iLen], charsmax(szBuffer)-iLen, fmt( "%L", id, "OWNED"));

		else if (USPSkins[i][SKIN_COST])
			//iLen += formatex(szBuffer[iLen], charsmax(szBuffer)-iLen, " [ %d Points ]", USPSkins[i][SKIN_COST] );
			iLen += formatex(szBuffer[iLen], charsmax(szBuffer)-iLen, fmt( " %L", id, "POINTS", USPSkins[i][SKIN_COST] ));

		num_to_str(i, szItemInfo, charsmax(szItemInfo));
		menu_additem(iMenu, szBuffer, szItemInfo);
	}

	menu_display(id, iMenu)
}
public USPMenu_Handler(id, iMenu, iItem)
{
	if (iItem == MENU_EXIT)
	{
		menu_destroy(iMenu);
		back_skin_menu( id )
		return PLUGIN_HANDLED;
	}
	new szItemInfo[3], iUSPId, dummy;

	menu_item_getinfo(iMenu, iItem, dummy, szItemInfo, charsmax(szItemInfo), _, _, dummy);
	menu_destroy(iMenu);

	iUSPId = str_to_num(szItemInfo);

	if (g_iEquippedUSP[id] == iUSPId)
	{
		//ColorChat(id, RED, "^4[DR]^1 You already have this skin." );
		client_print_color(id, print_chat, "^4[DR] %L", LANG_PLAYER, "ALR_SKIN" )

		USPMenu(id);
		return PLUGIN_HANDLED;
	}

	if (!(g_bitOwnedUSPs[id] & BIT(iUSPId)))
	{
		if (USPSkins[iUSPId][SKIN_COST] && get_dr_points( id ) < USPSkins[iUSPId][SKIN_COST])
		{
			//ColorChat(id, RED, "^4[DR]^1 You don't have enough points." );
			client_print_color(id, print_chat, "^4[DR] %L", LANG_PLAYER, "NO_POINT" )


			USPMenu(id);
			return PLUGIN_HANDLED;
		}

		set_dr_points( id, -USPSkins[iUSPId][SKIN_COST] )
		g_bitOwnedUSPs[id] |= BIT(iUSPId);

		//client_print_color(0, print_chat, "^4[DR]^3 %n^1 bought^3 %s^1.", id, USPSkins[iUSPId][SKIN_NAME]);
		client_print_color(0, print_chat, "^4[DR] %L", LANG_PLAYER, "BOUGHT_SKIN", id, USPSkins[iUSPId][SKIN_NAME]);
	}

	g_iEquippedUSP[id] = iUSPId;

	if (is_user_alive(id))
	{
		new pActiveItem = get_pdata_cbase(id, 373, 5);

		if (is_valid_ent(pActiveItem) && cs_get_weapon_id(pActiveItem) == CSW_USP)
		{
			ExecuteHamB(Ham_Item_Holster, pActiveItem, 0);
			ExecuteHamB(Ham_Item_Deploy, pActiveItem);
		}
	}
	USPMenu(id);
	return PLUGIN_HANDLED;
}
public KnifeMenu(id)
{
	new szBuffer[96];

	//formatex(szBuffer, charsmax(szBuffer), "Knife Skins^n\dYour Points:\y %d", get_dr_points( id ));
	formatex(szBuffer, charsmax(szBuffer), fmt( "%L", id, "KNIFE_SKIN_TITLE", get_dr_points( id )));

	new iMenu = menu_create(szBuffer, "KnifeMenu_Handler");

	new szItemInfo[3], iLen;

	for (new i = 0; i < sizeof KnifeSkins; i++)
	{
		iLen = 0;

		if (!(g_bitOwnedKnifes[id] & BIT(i)) && KnifeSkins[i][SKIN_COST] && get_dr_points( id ) < KnifeSkins[i][SKIN_COST])
			iLen = copy(szBuffer, charsmax(szBuffer), "\d");
		else if (g_iEquippedKnife[id] == i)
			iLen = copy(szBuffer, charsmax(szBuffer), "\r");

		iLen += copy(szBuffer[iLen], charsmax(szBuffer)-iLen, KnifeSkins[i][SKIN_NAME]);

		if (g_bitOwnedKnifes[id] & BIT(i))
			//iLen += formatex(szBuffer[iLen], charsmax(szBuffer)-iLen, " [ OWNED ]" );
			iLen += formatex(szBuffer[iLen], charsmax(szBuffer)-iLen, fmt( "%L", id, "OWNED"));
		else if (KnifeSkins[i][SKIN_COST])
			//iLen += formatex(szBuffer[iLen], charsmax(szBuffer)-iLen, " [ %d Points ]", KnifeSkins[i][SKIN_COST] );
			iLen += formatex(szBuffer[iLen], charsmax(szBuffer)-iLen, fmt( " %L", id, "POINTS", KnifeSkins[i][SKIN_COST] ));

		num_to_str(i, szItemInfo, charsmax(szItemInfo));
		menu_additem(iMenu, szBuffer, szItemInfo);
	}

	menu_display(id, iMenu)
}
public KnifeMenu_Handler(id, iMenu, iItem)
{
	if (iItem == MENU_EXIT)
	{
		menu_destroy(iMenu);
		back_skin_menu( id )
		return PLUGIN_HANDLED;
	}

	new szItemInfo[3], iKnifeId, dummy;

	menu_item_getinfo(iMenu, iItem, dummy, szItemInfo, charsmax(szItemInfo), _, _, dummy);
	menu_destroy(iMenu);

	iKnifeId = str_to_num(szItemInfo);

	if (g_iEquippedKnife[id] == iKnifeId)
	{
		//ColorChat(id, RED, "^4[DR]^1 You already have this skin." );
		client_print_color(id, print_chat, "^4[DR] %L", LANG_PLAYER, "ALR_SKIN" )

		KnifeMenu(id);
		return PLUGIN_HANDLED;
	}

	if (!(g_bitOwnedKnifes[id] & BIT(iKnifeId)))
	{
		if (KnifeSkins[iKnifeId][SKIN_COST] && get_dr_points( id ) < KnifeSkins[iKnifeId][SKIN_COST])
		{
			//ColorChat(id, RED, "^4[DR]^1 You don't have enough points." );
			client_print_color(id, print_chat, "^4[DR] %L", LANG_PLAYER, "NO_POINT" )

			KnifeMenu(id);
			return PLUGIN_HANDLED;
		}

		set_dr_points( id, -KnifeSkins[iKnifeId][SKIN_COST] )
		g_bitOwnedKnifes[id] |= BIT(iKnifeId);

		//client_print_color(0, print_chat, "^4[DR]^3 %n^1 bought^3 %s^1.", id, KnifeSkins[iKnifeId][SKIN_NAME]);
		client_print_color(id, print_chat, "^4[DR] %L", LANG_PLAYER, "BOUGHT_SKIN", id, KnifeSkins[iKnifeId][SKIN_NAME])
	}

	g_iEquippedKnife[id] = iKnifeId;

	if (is_user_alive(id))
	{
		new pActiveItem = get_pdata_cbase(id, 373, 5);

		if (is_valid_ent(pActiveItem) && cs_get_weapon_id(pActiveItem) == CSW_KNIFE)
		{
			ExecuteHamB(Ham_Item_Holster, pActiveItem, 0);
			ExecuteHamB(Ham_Item_Deploy, pActiveItem);
		}
	}

	KnifeMenu(id);
	return PLUGIN_HANDLED;
}
public CUSP_Deploy_Post(iEntity)
{
	new id = get_pdata_cbase(iEntity, 41, 4);
	new iUSPId = g_iEquippedUSP[id];

	if (USPSkins[iUSPId][SKIN_V_MODEL][0])
		entity_set_string(id, EV_SZ_viewmodel, USPSkins[iUSPId][SKIN_V_MODEL]);

	if (USPSkins[iUSPId][SKIN_P_MODEL][0])
		entity_set_string(id, EV_SZ_weaponmodel, USPSkins[iUSPId][SKIN_P_MODEL]);
}
public CKnife_Deploy_Post(iEntity)
{
	new id = get_pdata_cbase(iEntity, 41, 4);
	new iKnifeId = g_iEquippedKnife[id];

	if (KnifeSkins[iKnifeId][SKIN_V_MODEL][0])
		entity_set_string(id, EV_SZ_viewmodel, KnifeSkins[iKnifeId][SKIN_V_MODEL]);

	if (KnifeSkins[iKnifeId][SKIN_P_MODEL][0])
		entity_set_string(id, EV_SZ_weaponmodel, KnifeSkins[iKnifeId][SKIN_P_MODEL]);
}
Snake. is offline
Send a message via Skype™ to Snake.
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-17-2022 , 08:57   Re: [Bug Fix] Players Can't Join Because of This Plugin
Reply With Quote #2

Try it with a different model, if that works, you know what the problem is.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Snake.
Senior Member
Join Date: Jul 2017
Old 08-17-2022 , 09:12   Re: [Bug Fix] Players Can't Join Because of This Plugin
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
Try it with a different model, if that works, you know what the problem is.
Tried million times, it has nothing to do with model's itself. I didnt get what you meant with "you know what the problem is"
Snake. is offline
Send a message via Skype™ to Snake.
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-17-2022 , 12:51   Re: [Bug Fix] Players Can't Join Because of This Plugin
Reply With Quote #4

Quote:
Originally Posted by Snake. View Post
Tried million times, it has nothing to do with model's itself. I didnt get what you meant with "you know what the problem is"
Perhaps you'll have to read what i said again, cause i have no idea on how i could explain myself any better on that sentence
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Snake.
Senior Member
Join Date: Jul 2017
Old 08-17-2022 , 13:09   Re: [Bug Fix] Players Can't Join Because of This Plugin
Reply With Quote #5

Quote:
Originally Posted by Napoleon_be View Post
Perhaps you'll have to read what i said again, cause i have no idea on how i could explain myself any better on that sentence
yea sorry read as you said "if that does not work". I'm sure the plugin has a troublesome bug
Snake. is offline
Send a message via Skype™ to Snake.
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-17-2022 , 13:24   Re: [Bug Fix] Players Can't Join Because of This Plugin
Reply With Quote #6

Show what you have when it's not working.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Snake.
Senior Member
Join Date: Jul 2017
Old 08-17-2022 , 13:34   Re: [Bug Fix] Players Can't Join Because of This Plugin
Reply With Quote #7

Quote:
Originally Posted by Napoleon_be View Post
Show what you have when it's not working.
There are no debug logs or console messages related to it unfortunatelly
Snake. is offline
Send a message via Skype™ to Snake.
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-17-2022 , 14:43   Re: [Bug Fix] Players Can't Join Because of This Plugin
Reply With Quote #8

Quote:
Originally Posted by Snake. View Post
There are no debug logs or console messages related to it unfortunatelly
I mean your code
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Snake.
Senior Member
Join Date: Jul 2017
Old 08-17-2022 , 16:04   Re: [Bug Fix] Players Can't Join Because of This Plugin
Reply With Quote #9

Quote:
Originally Posted by Napoleon_be View Post
I mean your code
Well, i shared it above already
Snake. is offline
Send a message via Skype™ to Snake.
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-18-2022 , 08:33   Re: [Bug Fix] Players Can't Join Because of This Plugin
Reply With Quote #10

Quote:
Originally Posted by Snake. View Post
Well, i shared it above already
Reading seems pretty hard... I asked for the code when it's not working. You're currently sharing what is most likely the original code.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Reply


Thread Tools
Display Modes

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 01:49.


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