AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to set P_model Sequences? (https://forums.alliedmods.net/showthread.php?t=252200)

AGoodGuy 11-28-2014 06:17

How to set P_model Sequences?
 
1 Attachment(s)
Hi every one, i am making sub model for my weapons mod, but i have some mistake with p_model when change to sub model, Sequences of this is not change, so please help my the way to change Sequences of p_model, thank so much.

I try with set_pev(id, pev_sequence, 1) but not happen!


This is my code and model:

PHP Code:

register_event("WeapPickup","checkModel","b","1=19")

public 
checkModel(id)
{
    if ( !
g_has_ak47red[id] || !is_user_alive(id) )
    return 
PLUGIN_CONTINUE;
    
    new 
szWeapID read_data(2)
    
    if ( 
szWeapID == CSW_AK47 && g_has_ak47red[id] == true )
    {
        
set_pev(idpev_viewmodel2ak47red_V_MODEL)
        
        
set_pev(idpev_body1//Change to submodel
        
set_pev(idpev_weaponmodel2ak47red_P_MODEL)

        
//So how to set Sequences of p_model?
    
}
    return 
PLUGIN_HANDLED



RateX 11-28-2014 10:28

Re: How to set P_model Sequences?
 
A better way to do this is to make a new entity following player with p_model as model. That way, you can change any value without problems.
BTW, you are changing player's submodel and sequence.;)

AGoodGuy 11-28-2014 11:34

Re: How to set P_model Sequences?
 
Quote:

Originally Posted by RateX (Post 2229123)
A better way to do this is to make a new entity following player with p_model as model. That way, you can change any value without problems.
BTW, you are changing player's submodel and sequence.;)

Yes, but how to change sequence of p_model?, can you help me?

RateX 11-29-2014 02:12

Re: How to set P_model Sequences?
 
With your way, you can't since there's no proper way to find p_model's entity. So do as I said and everything will be much easier.

AGoodGuy 11-29-2014 02:28

Re: How to set P_model Sequences?
 
Yes, easy, but i'm begginer, i don't understand, i have 2 method to change model, and if can, please help me to change sequence. Thanks.

Use ham but not happen
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Weapon change model"
#define VERSION "1.0"
#define AUTHOR "ils"


new ak47red_P_MODEL[64] = "models/p_sub.mdl"

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Item_Deploy"weapon_ak47""HamF_Item_Deploy_Post",1)
}

public 
plugin_precache()
{
    
precache_model(ak47red_P_MODEL)
}

public 
HamF_Item_Deploy_Postentity )
{
    
    const 
m_pPlayer 41;
    
    static 
id
    
    id 
get_pdata_cbase(entitym_pPlayer4)
    

        
    
set_pev(idpev_weaponmodel2ak47red_P_MODEL);
    
set_pev(entitypev_sequence,1)



Use fakemeta but not happen
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Weapon change model"
#define VERSION "1.0"
#define AUTHOR "ils"


new ak47red_P_MODEL[64] = "models/p_sub.mdl"

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("CurWeapon","checkWeapon","be","1=1")
}

public 
plugin_precache()
{
    
precache_model(ak47red_P_MODEL)
}


public 
checkWeapon(id)
{
        
    new 
plrClipplrAmmo
    
new plrWeapId
    
    plrWeapId 
get_user_weapon(idplrClip plrAmmo)
    
    if (
plrWeapId == CSW_AK47)
    {
        
checkModel(id)
    }
    else 
    {
        return 
PLUGIN_CONTINUE
    
}

    return 
PLUGIN_HANDLED
}

public 
checkModel(id)
{
    if ( !
is_user_alive(id) )
    return 
PLUGIN_CONTINUE;
    
    new 
szWeapID read_data(2)
    
    if ( 
szWeapID == CSW_AK47 )
    {
        
        
        new 
iWpn=get_pdata_cbase(id3734//hamsandwich
        
set_pev(iWpnpev_sequence,1)
        
        
set_pev(idpev_weaponmodel2ak47red_P_MODEL)
        
        

        
        
        
    }
    return 
PLUGIN_HANDLED



RateX 11-29-2014 05:52

Re: How to set P_model Sequences?
 
Which part of "there's no proper way to find p_model's entity" didn't you understand? What you are doing is getting weapon entity, not p_model entity.
In HamF_Item_Deploy_Post do something like:
PHP Code:

        set_pev(idpev_weaponmodel2""// Hide your p_model
        
if (!pev_valid(g_ent_weaponmodel[id]))
    {
        
g_ent_weaponmodel[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target")) // Create your p_model entity
        
if (!pev_valid(g_ent_weaponmodel[id])) return;
        
        
set_pev(g_ent_weaponmodel[id], pev_classname"weapon_model")
        
set_pev(g_ent_weaponmodel[id], pev_movetypeMOVETYPE_FOLLOW)
        
set_pev(g_ent_weaponmodel[id], pev_aimentid)
        
set_pev(g_ent_weaponmodel[id], pev_ownerid)
    }
    
engfunc(EngFunc_SetModelg_ent_weaponmodel[id], ak47red_P_MODEL

Then you can set sequence, sub model or whatever you want.

AGoodGuy 11-29-2014 09:04

Re: How to set P_model Sequences?
 
Thanks for your support, because i'm beginer so i can't understand what you said, sorry.


All times are GMT -4. The time now is 17:33.

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