Raised This Month: $ Target: $400
 0% 

[TUT-CS] Changing player models and lowering svc_bad


Post New Thread Reply   
 
Thread Tools Display Modes
ble85
Junior Member
Join Date: May 2008
Old 10-09-2008 , 13:38   Re: [TUT-CS] Changing player models and lowering svc_bad
Reply With Quote #31

Quote:
3. If the model is big enough, its owner will be able to see part of it even though he shouldn't
Biohazard is not using that :/
After i added it to code, zombie model was invisible.

Any other ideas? The only way i could see for now is using the fakemeta way.

Dont forget zombie_swarm model is using other bones structures and that is the reason
When i replaced standard models (leet,gsg etc) to zombie_swarm the model changing looks allright, but of course it make no sense: changing from zombie to zombie.
ble85 is offline
padilha007
Senior Member
Join Date: Jul 2008
Old 10-20-2008 , 19:37   Re: [TUT-CS] Changing player models and lowering svc_bad
Reply With Quote #32

I used separate entities but i get this error >

PHP Code:
L 10/20/2008 21:32:27Invalid message argument 12
L 10
/20/2008 21:32:27: [AMXXDisplaying debug trace (plugin "model.amxx")
L 10/20/2008 21:32:27: [AMXXRun time error 10native error (native "get_msg_arg_int")
L 10/20/2008 21:32:27: [AMXX]    [0new2.sma::message_clcorpse (line 96
i edited my plugin for player model.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>

#define ZOMBIE_MODEL "zombie_source" // The model we're gonna use for zombies
#define PLAYERMODEL_CLASSNAME "ent_playermodel"

new g_player_model[33][32// player's model name (string)
new g_ent_playermodel[33// playermodel entity following this player
new g_zombie[33// whether the player is a zombie
new g_glow[33// whether the player has glow

/*================================================================================
 [Plugin Start]
=================================================================================*/

public plugin_precache()
{
    new 
modelpath[100]
    
formatex(modelpathsizeof modelpath 1"models/player/%s/%s.mdl"ZOMBIE_MODELZOMBIE_MODEL)
    
engfunc(EngFunc_PrecacheModelmodelpath)
}

public 
plugin_init()
{
    
register_plugin("Player Model Changer Example""0.3""MeRcyLeZZ")
   
    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn"1)
    
register_forward(FM_AddToFullPack"fw_AddToFullPack")

    
register_message(get_user_msgid("ClCorpse"), "message_clcorpse")
   
    
register_clcmd("say /glow""clcmd_sayglow")
}

/*================================================================================
 [Player Spawn Event]
=================================================================================*/

public fw_PlayerSpawn(id)
{   
    
// Not alive
    
if (!is_user_alive(id))
        return;
   
    
// Set to zombie if on Terrorist team
    
g_zombie[id] = cs_get_user_team(id) == CS_TEAM_T true false;
   
    
// Check if the player is a zombie
    
if (g_zombie[id])
    {
        
// Store our custom model in g_player_model[id]
        
copy(g_player_model[id], sizeof g_player_model[] - 1ZOMBIE_MODEL)
       
        
// Set the model on our playermodel entity
        
fm_set_playermodel_ent(idg_player_model[id])
    }
    
// Not a zombie, but still has a custom model
    
else if (fm_has_custom_model(id))
    {
        
// Reset it back to default
        
fm_remove_model_ents(id)
    }
}

/*================================================================================
 [Add to Full Pack Forward]
=================================================================================*/

public fw_AddToFullPack(eseenthosthostflagsplayer)
{
    
// Narrow down our matches a little bit
    
if (player || !ent) return FMRES_IGNORED;
   
    
// Check if it's one of our custom model ents being sent to its owner
    
static owner
    
for (owner 1owner <= 32owner++)
    {
        
// Both player and weapon models are blocked just in case...
        
if ((ent == g_ent_playermodel[owner]) && host == owner)
            return 
FMRES_SUPERCEDE;
    }
   
    return 
FMRES_IGNORED;
}

/*================================================================================
 [ClCorpse Message]
=================================================================================*/

public message_clcorpse()
{
    
// Get player id
    
static id
    id 
get_msg_arg_int(12)
   
    
// Check if the player is using a custom player model
    
if (fm_has_custom_model(id))
    {
        
// Set correct model on player corpse
        
set_msg_arg_string(1g_player_model[id])
    }
}

/*================================================================================
 [Client Disconnect Event]
=================================================================================*/

public client_disconnect(id)
{
    
// Check if the player was using a custom player model
    
if (fm_has_custom_model(id))
    {
        
// Remove custom entities
        
fm_remove_model_ents(id)
    }
}

/*================================================================================
 [Client Command: Say /Glow]
=================================================================================*/

public clcmd_sayglow(id)
{
    
// Turn glow on/off
    
g_glow[id] = !(g_glow[id])
   
    
// Check if the player is using a custom player model
    
if (fm_has_custom_model(id))
    {
        
// Check if the player has glow
        
if (g_glow[id])
        {
            
// Set glow on playermodel entity
            
fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell20000kRenderNormal50)
        }
        else
        {
            
// Remove glow on playermodel entity
            
fm_set_rendering(g_ent_playermodel[id])
        }
    }
    else
    {
        
// Set and remove glow the usual way
        
if (g_glow[id])
        {
            
fm_set_rendering(idkRenderFxGlowShell20000kRenderNormal50)
        }
        else
        {
            
fm_set_rendering(id)
        }
    }
}

/*================================================================================
 [Stocks]
=================================================================================*/

stock fm_set_playermodel_ent(id, const modelname[])
{
    
// Make original player entity invisible
    
set_pev(idpev_rendermodekRenderTransTexture)
    
// This is not 0 because it would hide some effects when firing weapons
    
set_pev(idpev_renderamt1.0)
   
    
// Since we're passing the short model name to the function
    // we need to make the full path out of it
    
static modelpath[100]
    
formatex(modelpathsizeof modelpath 1"models/player/%s/%s.mdl"modelnamemodelname)
   
    
// Check if the entity assigned to this player exists
    
if (!pev_valid(g_ent_playermodel[id]))
    {
        
// If it doesn't, proceed to create a new one
        
g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
       
        
// If it failed to create for some reason, at least this will prevent further "Invalid entity" errors...
        
if (!pev_valid(g_ent_playermodel[id])) return;
       
        
// Set its classname
        
set_pev(g_ent_playermodel[id], pev_classnamePLAYERMODEL_CLASSNAME)

        
// Make it follow the player
        
set_pev(g_ent_playermodel[id], pev_movetypeMOVETYPE_FOLLOW)
        
set_pev(g_ent_playermodel[id], pev_aimentid)
        
set_pev(g_ent_playermodel[id], pev_ownerid)
    }
   
    
// Entity exists now, set its model
    
engfunc(EngFunc_SetModelg_ent_playermodel[id], modelpath)
}

stock fm_has_custom_model(id)
{
    return 
pev_valid(g_ent_playermodel[id]) ? true false;
}

stock fm_remove_model_ents(id)
{
    
// Make the player visible again
    
set_pev(idpev_rendermodekRenderNormal)
   
    
// Remove "playermodel" ent if present
    
if (pev_valid(g_ent_playermodel[id]))
    {
        
engfunc(EngFunc_RemoveEntityg_ent_playermodel[id])
        
g_ent_playermodel[id] = 0
    
}
}

// Set entity's rendering type (from fakemeta_util)
stock fm_set_rendering(entityfx kRenderFxNone255255255render kRenderNormalamount 16)
{
    new 
Float:color[3]
    
color[0] = float(r)
    
color[1] = float(g)
    
color[2] = float(b)
   
    
set_pev(entitypev_renderfxfx)
    
set_pev(entitypev_rendercolorcolor)
    
set_pev(entitypev_rendermoderender)
    
set_pev(entitypev_renderamtfloat(amount))

__________________

padilha007 is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 10-23-2008 , 22:11   Re: [TUT-CS] Changing player models and lowering svc_bad
Reply With Quote #33

Quote:
Originally Posted by padilha007
I used separate entities but i get this error >
Code:
L 10/20/2008 - 21:32:27: Invalid message argument 12
L 10/20/2008 - 21:32:27: [AMXX] Displaying debug trace (plugin "model.amxx")
L 10/20/2008 - 21:32:27: [AMXX] Run time error 10: native error (native "get_msg_arg_int")
L 10/20/2008 - 21:32:27: [AMXX]    [0] new2.sma::message_clcorpse (line 96)
That's odd, the message was always passing 12 arguments when I tested. Try adding:
Code:
if (get_msg_args() < 12)     return;
That should get rid of the errors.
__________________
MeRcyLeZZ is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 02-19-2009 , 13:06   Re: [TUT-CS] Changing player models and lowering svc_bad
Reply With Quote #34

Updated first method with the delay code snippet used in ZP 4.2, which makes mid-round model changing more practical and is safer than the previous "model counter" system.
__________________
MeRcyLeZZ is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-23-2009 , 08:36   Re: [TUT-CS] Changing player models and lowering svc_bad
Reply With Quote #35

I have a question. Its really needed to hook player spawn? It wouldn't be enough to set the model instead on the change team event?
joaquimandrade is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 02-23-2009 , 09:23   Re: [TUT-CS] Changing player models and lowering svc_bad
Reply With Quote #36

IMO ResetHUD event would also be OK in this case.
__________________
hleV is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 02-23-2009 , 09:24   Re: [TUT-CS] Changing player models and lowering svc_bad
Reply With Quote #37

CS resets the custom model, as been said in the main post, therefore - only one change won't last long.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-23-2009 , 09:31   Re: [TUT-CS] Changing player models and lowering svc_bad
Reply With Quote #38

Quote:
Originally Posted by Dores View Post
CS resets the custom model, as been said in the main post, therefore - only one change won't last long.
I'm talking about the final code:

Code:
4. To block CS from changing the model, we make use of the forward FM_SetClientKeyValue:
So:

Its really needed to hook player spawn? It wouldn't be enough to set the model instead on the change team event?
joaquimandrade is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 02-26-2009 , 14:51   Re: [TUT-CS] Changing player models and lowering svc_bad
Reply With Quote #39

Quote:
Originally Posted by joaquimandrade View Post
Its really needed to hook player spawn? It wouldn't be enough to set the model instead on the change team event?
You can change models whenever you want. The example is just that: an example.
__________________
MeRcyLeZZ is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-26-2009 , 17:39   Re: [TUT-CS] Changing player models and lowering svc_bad
Reply With Quote #40

Quote:
Originally Posted by MeRcyLeZZ View Post
You can change models whenever you want. The example is just that: an example.
A spawn happens much more frequently than a team change. So if you can use your code and change the spawn forward by the join team event it would be even better. I didn't mess with models yet so i don't have knowledge in this topic, so i asked you. If using the join team event works it would also allow to remove the tasks.
__________________
joaquimandrade is offline
Reply



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 06:55.


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