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

player models bug


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 05-14-2021 , 12:30   player models bug
Reply With Quote #1

Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < hamsandwich >

#define PLUGIN	"Player Models"
#define VERSION	"1.0"
#define AUTHOR	"LondoN eXtream"

#define MAX_PLAYERS 32

native cs_set_player_model ( iEntity, const szModel [ ] );
native cs_reset_player_model ( iEntity );

enum _:hDBModels
{
	g_hPlayerName [ MAX_PLAYERS ],
	g_hPlayerModel [ MAX_PLAYERS ]
};

new g_hDBModels [ hDBModels ], Array: g_hDBArray;

public plugin_precache ( )
{
	register_plugin ( PLUGIN, VERSION, AUTHOR );

	if ( g_hDBArray )
		ArrayDestroy ( g_hDBArray );

	g_hDBArray = ArrayCreate ( hDBModels );

	new szFile [ 128 ];
	get_configsdir ( szFile, charsmax ( szFile ) );
	formatex ( szFile, charsmax ( szFile ), "%s/PlayerModels.ini", szFile );

	if ( !file_exists ( szFile ) )	set_fail_state ( "File not found" );

	new PlayerModelsFile = fopen ( szFile, "r" );

	if ( PlayerModelsFile )
	{
		new szBuffer [ 256 ], szName [ MAX_PLAYERS ], szModel [ MAX_PLAYERS ];
		
		while ( !feof ( PlayerModelsFile ) )
		{
			fgets ( PlayerModelsFile, szBuffer, charsmax ( szBuffer ) );
			trim ( szBuffer );

			if ( szBuffer [ 0 ] == ';' || ( szBuffer [ 0 ] == '/' && szBuffer [ 1 ] == '/' ) )
				continue;

			if ( parse ( szBuffer, szName, charsmax ( szName ), szModel, charsmax ( szModel ) ) < 2 )
				continue;

			g_hDBModels [ g_hPlayerName ] = szName;
			g_hDBModels [ g_hPlayerModel ] = szModel;

			ArrayPushArray ( g_hDBArray, g_hDBModels );
		}
	}

	fclose ( PlayerModelsFile );

	// Precache Models
	new iSize = ArraySize ( g_hDBArray );
	new ModelFile [ 128 ];
	new ij;

	for ( new i = 0; i < iSize; i++ )
	{
		ArrayGetArray ( g_hDBArray, i, g_hDBModels );

		formatex ( ModelFile, charsmax ( ModelFile ), "models/player/%s/%s.mdl", g_hDBModels [ g_hPlayerModel ], g_hDBModels [ g_hPlayerModel ] );

		log_amx ( "[DEBUG] File : %s", ModelFile );
		ij++;

		if ( file_exists ( ModelFile ) )
			precache_model ( ModelFile );
	}	

	log_amx ( "[DEBUG] Adding %d models to download table.", ij );
}

public plugin_init ( )
{
	RegisterHam ( Ham_Spawn, "player", "CBase_Spawn_Post", true );
	RegisterHam ( Ham_Killed, "player", "CBase_Killed_Post", true );
}

public CBase_Spawn_Post ( iEntity )
{
	if ( !is_user_alive ( iEntity ) )
		return;

	set_task ( 0.7, "CBase_ModelSet_Player_", iEntity );
}

public CBase_ModelSet_Player_ ( iEntity )
{
	new iSize = ArraySize ( g_hDBArray );
	
	new hName [ 32 ];
	get_user_name ( iEntity, hName, charsmax ( hName ) );

	for ( new i = 0; i < iSize; i++ )
	{
		ArrayGetArray ( g_hDBArray, i, g_hDBModels );

		if ( equal ( hName, g_hDBModels [ g_hPlayerName ] ) )
		{
			cs_set_user_model ( iEntity, g_hDBModels [ g_hPlayerModel ] );
			cs_set_player_model ( iEntity, g_hDBModels [ g_hPlayerModel ] );
			log_amx ( "[DEBUG] Set %s model for client %s", g_hDBModels [ g_hPlayerModel ], hName );
			break;
		}
		else	log_amx ( "[DEBUG] No model set for client %s", hName );
	}
}

public CBase_Killed_Post ( iEntity )
	cs_reset_player_model ( iEntity );
This is my code
Code:
L 05/14/2021 - 19:25:05: -------- Mapchange to de_dust2 --------
L 05/14/2021 - 19:25:05: [PlayerModels.amxx] [DEBUG] File : models/player/plr_admin/plr_admin.mdl
L 05/14/2021 - 19:25:05: [PlayerModels.amxx] [DEBUG] File : models/player/avh_alien/avh_alien.mdl
L 05/14/2021 - 19:25:05: [PlayerModels.amxx] [DEBUG] Adding 2 models to download table.
[AMXX] Loaded 1 admin from file
Executing AMX Mod X Configuration File 
Scrolling message displaying frequency: 10:00 minutes
Menu item 17 added to Menus Front-End: "Plugin Cvars" from plugin "pluginmenu.amxx"
Menu item 18 added to Menus Front-End: "Plugin Commands" from plugin "pluginmenu.amxx"
L 05/14/2021 - 19:25:15: [PlayerModels.amxx] [DEBUG] Set plr_admin model for client LondoN eXtream
Dropped LondoN eXtream from server
Reason:  Client sent 'drop'
192.168.1.139:27005:reconnect
L 05/14/2021 - 19:25:22: [PlayerModels.amxx] [DEBUG] Set plr_admin model for client LondoN eXtream
L 05/14/2021 - 19:25:29: [PlayerModels.amxx] [DEBUG] Set plr_admin model for client LondoN eXtream
Dropped LondoN eXtream from server
Reason:  Timed out
Console debug

But model don't apply to player. Maibe because i test on windows?

Using CS Player Models API and CSTRIKE but no one set the model

Ini file design

Code:
;"name" "model"
"LondoN eXtream" "plr_admin"
__________________
LondoN is offline
 



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:09.


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