Model Menu (AS or SourceMod)
#1
I've been trying to make a Model Menu Server Side Plugin for my custom server, in both AngelScript, and SourceMod... and both haven't been able to get the desired functionality.

For SourceMod, I've tried using the following :

      SetEntityModel(entity, info)... and this isn't working for me, and I don't think it's supported.

For AngelScript, I've tried using the "OnPlayerSpawn" Hook... but I can't get it to fire for me, which is integral to the plugin, because it needs to set the model when you spawn each round.

HookReturnCode OnPlayerSpawn(CBasePlayer@ pPlayer)
{
       // Not Hitting any of these
       Engine.Print(chat, pPlayer, "Hello!");
       Engine.PrecacheFile(model, "models\\test.mdl");
       pPlayer.SetModel("models\\test.mdl");
       return HOOK_HANDLED;
}

I'm stuck, and would appreciate any help with these issues.
Reply
#2
You need to setup the hook, here is an example:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void PluginInit()
{
	// Name of the plugin
	PluginData.SetName( "Test Plugin" );
	
	// Author of the plugin
	PluginData.SetAuthor( "JonnyBoy0719" );
	
	// Version of the plugin
	PluginData.SetVersion( "1.0.0" );
	
	Events::Player::OnPlayerSpawn.Hook( @PlayerSpawned );
}

HookReturnCode PlayerSpawned( CHL2MP_Player@ pPlayer )
{
	// Precache our models
	Engine.PrecacheFile(model, "models/characters_custom/arms/rex.mdl");
	Engine.PrecacheFile(model, "models/characters_custom/rex.mdl");

	// Set the model
	pPlayer.SetArmModel("models/characters_custom/arms/rex.mdl");
	pPlayer.SetModel("models/characters_custom/rex.mdl");
	return HOOK_HANDLED;
}


In short,

Code:
Events::Player::OnPlayerSpawn.Hook( @OnPlayerSpawn );

tells it to register the hook OnPlayerSpawn, and use the function name PlayerSpawned. Hopefully this helps. Smile

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)