Setting model w/ AMX Mod X

NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Default model set methods that works with CS, DoD, etc. doesn't work on ESF.
The way is the server_frame() (StartFrame in Fakemeta).
But the problem is that the StartFrame is called too often and is cousing lag.
PHP:
#include <amxmodx>
#include <fakemeta>

new g_MaxPlayers;

public plugin_init()
{
        register_forward(FM_StartFrame, "StartFrame");

        g_MaxPlayers = get_maxplayers();
}

public SetModel()
{
        for (new Client = 1; Client <= g_MaxPlayers; Client++)
        {
                if (!is_user_connected(Client) || !is_user_alive(Client))
                        return;

                switch (pev(Client, pev_playerclass))
                {
                        case 1: engfunc(EngFunc_SetModel, Client, "models/custom/buu/buu.mdl");
                        case 2: engfunc(EngFunc_SetModel, Client, "models/custom/goku/goku.mdl");
                        case 3: engfunc(EngFunc_SetModel, Client, "models/custom/gohan/gohan.mdl");
                        case 4: engfunc(EngFunc_SetModel, Client, "models/custom/krillin/krillin.mdl");
                        case 5: engfunc(EngFunc_SetModel, Client, "models/custom/frieza/frieza.mdl");
                        case 6: engfunc(EngFunc_SetModel, Client, "models/custom/piccolo/piccolo.mdl");
                        case 7: engfunc(EngFunc_SetModel, Client, "models/custom/trunks/trunks.mdl");
                        case 8: engfunc(EngFunc_SetModel, Client, "models/custom/vegeta/vegeta.mdl");
                        case 9: engfunc(EngFunc_SetModel, Client, "models/custom/cell/cell.mdl");
                }

                client_print(Client, print_chat, "Model set");
        }
}
The debug message "Model set" is printed like 5 or more timer per sec. if I move fast. If I stop the StartFrame, model changes back to default one.
Maybe anyone know how to set the model permanently so it wouldn't unchange to default one?
 
Project Manager
🌠 Staff
✔️ HL Verified
💻 Oldtimer
Joined
Nov 25, 2001
Messages
1,729
Best answers
0
please state the exact version of ESF you are using.
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
1.2.3 though Metamod doesn't work with 1.3 (at least for me and my friends).
 
Project Manager
🌠 Staff
✔️ HL Verified
💻 Oldtimer
Joined
Nov 25, 2001
Messages
1,729
Best answers
0
You can adapt this function.
it's from the ECX source.

PHP:
public __setClientMODEL ()
{
	static Client;
	Client = get_param( 1 );
	
	if ( !validateClient( Client ) )
		return 0;

	static Model[ 32 ];
	get_string( 2, Model, 22 );

	static Location[ 65 ];
	formatex( Location, 64, "models/player/%s/%s.mdl", Model, Model );

	if ( !file_exists( Location ) )
	{
		log_error( AMX_ERR_NATIVE, "< Core >> Model does not exist > ^"%s^"", Location );

		return 0;
	}

	setPDS( Client, coreModel, Model );
	set_pev( Client, pev_model, Location );
	engfunc( EngFunc_SetModel, Client, Location );

	return 1;
}
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Don't really know how to use this, what modules required etc.
 
Project Manager
🌠 Staff
✔️ HL Verified
💻 Oldtimer
Joined
Nov 25, 2001
Messages
1,729
Best answers
0
Don't really know how to use this, what modules required etc.
required modules were: fakemeta and engine if I remember correctly. This code however is really simple and if u can't get this to work u might wanna do some more practising before trying this :) ? ( no offense )
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
I'm enough practiced to understand that neither doesn't have setPDS() & coreModel. That's why I'm asking what modules required.

BTW where/how can I look at ECX' source?
 
Last edited:
ESF Coder
🌠 Staff
Joined
Jun 13, 2004
Messages
585
Best answers
0
I'm enough practiced to understand that neither doesn't have setPDS() & coreModel. That's why I'm asking what modules required.

BTW where/how can I look at ECX' source?
you could ask the ecx developers :p
that would be: Raven, Lord of Destruction, and me

but you could download the CCI and use the includes from there.
there is a setClientModel native to set the model ( Core.amxx required )
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
PHP:
#include <amxmodx>
#include <ecx>
#include <hamsandwich>

public plugin_precache()
        precache_model("models/player/goku/goku.mdl");

public plugin_init()
        RegisterHam(Ham_Spawn, "player", "SetModelTask", 1);

public SetModelTask(Client)
{
        if (!is_user_connected(Client) || !is_user_alive(Client))
                return;

        set_task(1.0, "SetModel", Client);
}

public SetModel(Client)
{
        if (!is_user_connected(Client) || !is_user_alive(Client))
                return;

        setClientMODEL(Client, "goku");
        setClientMODEL(Client, "goku");
        setClientMODEL(Client, "goku");
        setClientMODEL(Client, "goku");
        setClientMODEL(Client, "goku");
        setClientMODEL(Client, "goku");
        setClientMODEL(Client, "goku");
        setClientMODEL(Client, "goku");
        setClientMODEL(Client, "goku");
        setClientMODEL(Client, "goku");
        client_print(Client, print_chat, "Model set");
}
Explain this... The model showed up for less than 1 sec. and then I got back my default model. It looks like kinda familiar to the way I was doing before (with server frame) - in both methods the model sets back to default one if I don't set it on each server frame.

* ecx.inc contains core.inc information.
 
Last edited:
ESF Coder
🌠 Staff
Joined
Jun 13, 2004
Messages
585
Best answers
0
1) you dont have to use an task, just one time setClientMODEL is enough
2) could it be that you are using other plugins that are modifying the model?
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
PHP:
#include <amxmodx>
#include <ecx>
#include <hamsandwich>

public plugin_precache()
        precache_model("models/player/goku/goku.mdl");

public plugin_init()
        RegisterHam(Ham_Spawn, "player", "SetModel");

public SetModel(Client)
{
        if (!is_user_connected(Client) || !is_user_alive(Client))
                return;

        setClientMODEL(Client, "goku");
        client_print(Client, print_chat, "Model set");
}
After spawn I can't see a model for a couple of secs, then I get my default one.
 

Users who are viewing this thread

Top