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

set pev model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 03-22-2020 , 12:24   set pev model
Reply With Quote #1

PHP Code:
public checkModel(id)
{
    if ( !
g_HasAk[id] || !g_HasMp5[id]) 
    {
        return 
PLUGIN_HANDLED
    
}
    
    new 
szWeapID read_data(2)
    
    if ( 
szWeapID == CSW_AK47 && g_HasAk[id] == true)
    {
        
set_pev(idpev_viewmodel2AK_V_MODEL)
        
set_pev(idpev_weaponmodel2AK_P_MODEL)
    }
    if ( 
szWeapID == CSW_MP5NAVY && g_HasMp5[id] == true)
    {
        
set_pev(idpev_viewmodel2MP_V_MODEL)
        
set_pev(idpev_weaponmodel2MP_P_MODEL)
    }
    return 
PLUGIN_HANDLED
}

public 
checkWeapon(id)
{
    new 
plrWeapId
    
    
if (plrWeapId == CSW_AK47 && g_HasAk[id] || CSW_MP5NAVY && g_HasMp5[id])
    {
        
checkModel(id)
    }
    else 
    {
        return 
PLUGIN_CONTINUE
    
}
    return 
PLUGIN_HANDLED

It only sets the model when i've got both of ak and mp5 weapons.. I've tried to make an if for each one but then it doesn't work at all, any help?
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-22-2020 , 13:26   Re: set pev model
Reply With Quote #2

Your first if-check is wrong. Simply translate it:

"If the player doesn't have AK OR doesn't have MP5, stop the code."

You need to do AND instead of OR.

But, you don't even need this since you're checking it down below as well, so you can remove the first check completely.

PS: I would use "switch" instead of "if" for each weapon.
__________________

Last edited by OciXCrom; 03-22-2020 at 13:26.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 03-22-2020 , 16:50   Re: set pev model
Reply With Quote #3

huh, i dont really get it, first time working with this kind of models
PHP Code:
public checkModel(id)
{
    new 
szWeapID read_data(2)
    
    if ( 
szWeapID == CSW_AK47 && g_HasAk[id] == true)
    {
        
set_pev(idpev_viewmodel2AK_V_MODEL)
        
set_pev(idpev_weaponmodel2AK_P_MODEL)
    }
    if ( 
szWeapID == CSW_MP5NAVY && g_HasMp5[id] == true)
    {
        
set_pev(idpev_viewmodel2MP_V_MODEL)
        
set_pev(idpev_weaponmodel2MP_P_MODEL)
    }
    return 
PLUGIN_HANDLED
}

public 
checkWeapon(id)
{
    new 
plrWeapId
    
    
if (plrWeapId == CSW_AK47 && g_HasAk[id] || CSW_MP5NAVY && g_HasMp5[id])
    {
        
checkModel(id)
    }
    else 
    {
        return 
PLUGIN_CONTINUE
    
}
    return 
PLUGIN_HANDLED

i tried to change to AND instead of OR but doesnt work, i made for each an If again, doesn't work
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-22-2020 , 17:07   Re: set pev model
Reply With Quote #4

Code:
public checkModel(id) {     new szWeapID = read_data(2)     switch(szWeapID)     {         case CSW_AK47:         {             if(g_HasAk[id])             {                 set_pev(id, pev_viewmodel2, AK_V_MODEL)                 set_pev(id, pev_weaponmodel2, AK_P_MODEL)             }         }         case CSW_MP5NAVY:         {             if(g_HasMp5[id])             {                 set_pev(id, pev_viewmodel2, MP_V_MODEL)                 set_pev(id, pev_weaponmodel2, MP_P_MODEL)             }         }     } }

PS: how is this function actually registered? Is it the "CurWeapon" event? Why do you have another function that's calling it?

The plrWeapId variable in your other function is always 0.
__________________

Last edited by OciXCrom; 03-22-2020 at 17:07.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 03-22-2020 , 17:43   Re: set pev model
Reply With Quote #5

alright, thank you, it seems to work properly but there's only one thing
If i have a default MP5 Navy, and I choose the AK model, the model does not show.
i tried with default AK and chose MP5 and here it worked.
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-22-2020 , 22:01   Re: set pev model
Reply With Quote #6

Show the full code.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 03-23-2020 , 13:25   Re: set pev model
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
Show the full code.
PHP Code:
public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
cvar_dmgmultiplier register_cvar("ak_multiplier""1")
    
cvar_goldbullets register_cvar("ak_bullets""1")
    
cvar_dmgmultiplier2 register_cvar("mp5_dmg_multiplier""1")
    
    
register_event("WeapPickup","checkModel","b","1=19")
    
register_event("DeathMsg""Event_DeathMsg""a"
    
// Current Weapon Event
    
register_event("CurWeapon","checkWeapon","be","1=1")
    
register_event("CurWeapon""make_tracer""be""1=1""3>0")
    
// Ham TakeDamage
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
register_forwardFM_CmdStart"fw_CmdStart" )
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
    
    
g_Players get_maxplayers(); 
    
register_clcmd("say /testmenu""extra_weapon_menu")
    
}

public 
client_connect(id)
{
    
g_HasMp5[id] = false
    g_HasAk
[id] = false
}

public 
client_disconnect(id)
{
    
g_HasMp5[id] = false
    g_HasAk
[id] = false
}

public 
Death()
{
    
g_HasMp5[read_data(2)] = false
    g_HasAk
[read_data(2)] = false
}

public 
fwHamPlayerSpawnPost(id)
{
    
g_HasMp5[id] = false
    g_HasAk
[id] = false
}
public 
checkWeapon(id)
{
    new 
plrWeapId
    
if (plrWeapId == CSW_AK47 && g_HasAk[id] || CSW_MP5NAVY && g_HasMp5[id])
    {
        
checkModel(id)
    }
    else 
    {
        return 
PLUGIN_CONTINUE
    
}
    return 
PLUGIN_HANDLED


public 
checkModel(id)
{
    new 
szWeapID read_data(2)
    
    switch(
szWeapID)
    {
        case 
CSW_AK47:
        {
            if(
g_HasAk[id])
            {
                
set_pev(idpev_viewmodel2AK_V_MODEL)
                
set_pev(idpev_weaponmodel2AK_P_MODEL)
            }
        }
        case 
CSW_MP5NAVY:
        {
            if(
g_HasMp5[id])
            {
                
set_pev(idpev_viewmodel2MP_V_MODEL)
                
set_pev(idpev_weaponmodel2MP_P_MODEL)
            }
        }
    }
}


public 
fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    if ( 
is_valid_playerattacker ) && get_user_weapon(attacker) == CSW_AK47 && g_HasAk[attacker] )
    {
        
SetHamParamFloat(4damage get_pcvar_floatcvar_dmgmultiplier ) )
    }
    if ( 
is_valid_playerattacker ) && get_user_weapon(attacker) == CSW_MP5NAVY && g_HasMp5[attacker] )
    {
        
SetHamParamFloat(4damage get_pcvar_floatcvar_dmgmultiplier2 ) )
    }
}

public 
fw_CmdStartiduc_handleseed )
{
    if( !
is_user_aliveid ) ) 
        return 
PLUGIN_HANDLED
    
    
if( ( get_ucuc_handleUC_Buttons ) & IN_ATTACK2 ) && !( pevidpev_oldbuttons ) & IN_ATTACK2 ) )
    {
        new 
szClipszAmmo
        
new szWeapID get_user_weaponidszClipszAmmo )
        
        if( 
szWeapID == CSW_AK47 && g_HasAk[id] == true && !g_hasZoom[id] == true)
        {
            
g_hasZoom[id] = true
            cs_set_user_zoom
idCS_SET_AUGSG552_ZOOM)
            
emit_soundidCHAN_ITEM"weapons/zoom.wav"0.202.400100 )
        }
        
        else if ( 
szWeapID == CSW_AK47 && g_HasAk[id] == true && g_hasZoom[id])
        {
            
g_hasZoomid ] = false
            cs_set_user_zoom
idCS_RESET_ZOOM)
            
        }
        
    }
    return 
PLUGIN_HANDLED
}

public 
make_tracer(id)
{
    if (
get_pcvar_num(cvar_goldbullets))
    {
        new 
clip,ammo
        
new wpnid get_user_weapon(id,clip,ammo)
        new 
pteam[16]
        
        
get_user_team(idpteam15)
        
        if ((
bullets[id] > clip) && (wpnid == CSW_AK47) && g_HasAk[id]) 
        {
            new 
vec1[3], vec2[3]
            
get_user_origin(idvec11// origin; your camera point.
            
get_user_origin(idvec24// termina; where your bullet goes (4 is cs-only)
            
            
            //BEAMENTPOINTS
            
message_beginMSG_BROADCAST,SVC_TEMPENTITY)
            
write_byte (0)     //TE_BEAMENTPOINTS 0
            
write_coord(vec1[0])
            
write_coord(vec1[1])
            
write_coord(vec1[2])
            
write_coord(vec2[0])
            
write_coord(vec2[1])
            
write_coord(vec2[2])
            
write_shortm_spriteTexture )
            
write_byte(1// framestart
            
write_byte(5// framerate
            
write_byte(2// life
            
write_byte(10// width
            
write_byte(0// noise
            
write_byte255 )     // r, g, b
            
write_byte215 )       // r, g, b
            
write_byte)       // r, g, b
            
write_byte(200// brightness
            
write_byte(150// speed
            
message_end()
        }
        
        
bullets[id] = clip
    
}
    
}

public 
Event_DeathMsg() 

    
set_task(0.1,"check_alive"0
}

public 
check_alive() 

    if(
fnGetAliveCt() == 1
    { 
        for( new 
1<= g_Playersi++ )  
        {  
            if (
is_user_alive(i) && cs_get_user_team(i) == CS_TEAM_CT)  
            { 
                
extra_weapon_menu(i)
                
client_print(0print_center"%s is the last survivor"i)
            } 
        }  
    } 

fnGetAliveCt() 

    static 
iAliveid 
    iAlive 

    
    
for (id 1id <= g_Playersid++) 
    { 
        if (
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT
            
iAlive++ 
    } 
    return 
iAlive


public 
extra_weapon_menu(id)
{
    new 
menu menu_create"\yChoose weapon:""menu_handler" )
    
    
menu_additem(menu"Scorpion MP5");
    
menu_additem(menu"Golden AK");
    
menu_additem(menu"M249");
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
menu_display(idmenu);
}


public 
menu_handler(idmenuitem)
{
    switch( 
item )
    {
        case 
0: {
            
give_item(id"weapon_mp5navy")
            
g_HasMp5[id] = true
            
return PLUGIN_HANDLED
        
}
        case 
1: {
            
give_item(id"weapon_ak47")
            
g_HasAk[id] = true
            
return PLUGIN_HANDLED
        
}
        case 
2: {
            
give_item(id"weapon_m249")
        }
    }
    return 
PLUGIN_HANDLED

There you go, I want that the last alive CT to get a extra weapon menu to choose, and i was trying to fix the models first and then make it work for last ct only, now, does not work, if you could also help me with this would be wonderful, thanks +karma
__________________
a simple act of caring creates an endless ripple.

Last edited by Nutu_; 03-23-2020 at 16:20.
Nutu_ is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-23-2020 , 15:17   Re: set pev model
Reply With Quote #8

Remove this and the function that it's calling:

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

"CurWeapon" does what you need, but you're not registering it correctly.
The first argument needs to be 1, not 19. The second argument is the weapon id.
You don't need to register it twice. Just do this:

Code:
register_event("CurWeapon","checkWeapon","be","1=1")

In the "checkWeapon" function, "plrWeapId" is 0. It should be:

Code:
new plrWeapId = read_data(2)

This is not how you check multiple conditions:

Code:
if (plrWeapId == CSW_AK47 && g_HasAk[id] || CSW_MP5NAVY && g_HasMp5[id])

You must specify that you're checking "plrWeapId" in the second statement, too:

Code:
if ((plrWeapId == CSW_AK47 && g_HasAk[id]) || (plrWeapId == CSW_MP5NAVY && g_HasMp5[id]))

But the entire function is poorly formatted. I would do this:

Code:
public checkWeapon(id) {     switch(read_data(2))     {         case CSW_AK47:         {             if(g_HasAk[id])             {                 set_pev(id, pev_viewmodel2, AK_V_MODEL)                 set_pev(id, pev_weaponmodel2, AK_P_MODEL)             }         }         case CSW_MP5NAVY:         {             if(g_HasMp5[id])             {                 set_pev(id, pev_viewmodel2, MP_V_MODEL)                 set_pev(id, pev_weaponmodel2, MP_P_MODEL)             }         }     } }
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 03-23-2020 , 16:19   Re: set pev model
Reply With Quote #9

thank you very much, everything works cool now, +karma
__________________
a simple act of caring creates an endless ripple.
Nutu_ 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 00:07.


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