AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set lefthand and righthand weapon skins (https://forums.alliedmods.net/showthread.php?t=329128)

feren02 12-10-2020 02:37

Set lefthand and righthand weapon skins
 
Hello everyone! Hope you are coping with the pandemic.

I have this .sma activated on my server and it works fully.

However, I want to add some codes that would trigger a weapon skin model (v_model) to be shown for admins if they are on lefthand OR righthand (depending) in-game.

***THE PROBLEM***
My custom weapon skins model work already in-game for admins. The only glitch is that, even I use v_model default on righthand set on my models folder inside cstrike, it still shows righthand view even players are cl_righthand 0 or setinfo lefthand 1 in-game.

***THE REQUESTED SOLUTION***
Can I add some code in my .sma to view my mirrored v_model (.mdl which is lefthanded) in-game for admins when they are on cl_righthand 0 and setinfo lefthand 1? For example:

PHP Code:

case CSW_M4A1set_pevidpev_viewmodel2v_m4a1 );
case 
CSW_M4A1set_pevidpev_viewmodel2v_m4a1_2 ); } if setinfo lefthand 1;cl_righthand 0 (JUST AN EXAMPLE

~HERE IS THE .SMA I AM USING CURRENTLY:~

PHP Code:

#include <amxmodx>  
#include <amxmisc>  
#include <cstrike>  
#include <fakemeta>

new const v_knife [] = "models/olgPH_weapons/v_neonknife.mdl";  
new const 
v_knife_r [] = "models/olgPH_weapons/v_neonknife_r.mdl"
new const 
v_m4a1 [] = "models/olgPH_weapons/v_neonm4a1.mdl";  
new const 
v_m4a1_r [] = "models/olgPH_weapons/v_neonm4a1_r.mdl";  
new const 
v_ak47 [] = "models/olgPH_weapons/v_neonak47.mdl";  
new const 
v_ak47_r [] = "models/olgPH_weapons/v_neonak47_r.mdl";  
new const 
v_awp [] = "models/olgPH_weapons/v_neonawp.mdl";  
new const 
v_awp_r [] = "models/olgPH_weapons/v_neonawp_r.mdl";  
//new const v_usp [] = "models/usp_comet.mdl";  
//new const v_glock18 [] = "models/glock18_water.mdl";  
new const v_deagle [] = "models/olgPH_weapons/v_neondeagle.mdl";  
new const 
v_deagle_r [] = "models/olgPH_weapons/v_neondeagle_r.mdl";  


new 
g_HaveFlags;  


public 
plugin_init( )  
{  
    
register_plugin"Server Models""1.0""feruchio" );  
    
    
    
register_event"CurWeapon""event_Curwp""be""1=1""2=18""2=22""2=26""2=28""2=29" );  
    
    
g_HaveFlags register_cvar"admin_knife_flags""t" );  
}  


public 
plugin_precache( )  
{  
    
precache_modelv_knife );  
    
precache_modelv_knife_r );  
    
precache_modelv_m4a1 ); 
    
precache_modelv_m4a1_r ); 
    
precache_modelv_ak47 ); 
    
precache_modelv_ak47_r ); 
    
precache_modelv_awp ); 
    
precache_modelv_awp_r ); 
//    precache_model( v_usp ); 
//    precache_model( v_glock18 ); 
    
precache_modelv_deagle ); 
    
precache_modelv_deagle_r ); 
}  

public 
event_Curwpid )  
{  
    new 
szHaveFlag[15];  
    
get_pcvar_stringg_HaveFlagsszHaveFlagcharsmaxszHaveFlag ) )  
    
    new 
WeaponIdUserHandle get_user_weaponid );
    
    if( 
has_all_flagsidszHaveFlag ) )  
    {  
        switch ( 
WeaponIdUserHandle )
        {
            case 
CSW_KNIFEset_pevidpev_viewmodel2v_knife );
            case 
CSW_M4A1set_pevidpev_viewmodel2v_m4a1 );
            case 
CSW_AK47set_pevidpev_viewmodel2v_ak47 );
            case 
CSW_AWPset_pevidpev_viewmodel2v_awp );
//            case CSW_USP: set_pev( id, pev_viewmodel2, v_usp );
//            case CSW_GLOCK18:set_pev( id, pev_viewmodel2, v_glock18 );
            
case CSW_DEAGLE:set_pevidpev_viewmodel2v_deagle );
        }
    }  
    
    return 
PLUGIN_CONTINUE;  


Thank you for your usual support, looking forward! :)

gabuch2 12-10-2020 10:10

Re: Set lefthand and righthand weapon skins
 
Wouldn't be better to flip the model instead?

AnimalMonster 12-10-2020 17:09

Re: Set lefthand and righthand weapon skins
 
Are you sure that the skin's isn t already in righthand in the model and when you cl_righthand 1 it goes left?

feren02 12-11-2020 21:52

Re: Set lefthand and righthand weapon skins
 
Quote:

Originally Posted by Gabe Iggy (Post 2728308)
Wouldn't be better to flip the model instead?

Hello can you expound this for me? I used an application for flipping my v_model (custom weapon skins), I have a .mdl for left and for right.

I use as default the "righthand".mdl so that technically when setinfo lefthand 1 or cl_righthand 0 in-game, the weapon skin would display on left hand. (THE PROBLEM is, even weapon is set to lefthand still shows the custom weapon skin in righthand)

How do I find a way round to force a code to my .sma to read a different v_model file which is a mirrored or flipped .mdl of my custom weapon skin righthand model to be guaranteed that when a player in-game sets weapon in lefthand, this v_model_lefthand would be triggered for pevview.


Thank you and regards!

feren02 12-11-2020 22:01

Re: Set lefthand and righthand weapon skins
 
Quote:

Originally Posted by AnimalMonster (Post 2728355)
Are you sure that the skin's isn t already in righthand in the model and when you cl_righthand 1 it goes left?

Hi the exact problems I am experiencing in-game considering my default v_model is set to display on righthand:

- When a player sets weapon to be on lefthand (setinfo lefthand 1 / cl_righthand 0), the custom weapon skin is still showed and appears on the righthand.

- I don't know how to add a code to my .sma that triggers to call a different v_model to be forced when players in-game are on lefthand;
e.g.
IF RIGHTHAND:
PHP Code:

case CSW_M4A1set_pevidpev_viewmodel2v_m4a1 );  ***WORKING*** 

IF LEFTHAND:
PHP Code:

case CSW_M4A1set_pevidpev_viewmodel2v_m4a1_2 ); ***NOT WORKING OR HOW TO MAKE THIS WORK IF PLAYERS ARE SETINFO LEFTHAND 1 and CL_RIGHTHAND 0 IN-GAME*** 


feren02 12-18-2020 00:07

Re: Set lefthand and righthand weapon skins
 
UP :)

CrazY. 12-18-2020 09:13

Re: Set lefthand and righthand weapon skins
 
Code:
foo(id) {     new buf[15]     get_user_info(id, "lefthand", buf, charsmax(buf))     if (str_to_num(buf) == 1)     {         // set lefthand model     }     else     {         // set righthand model     } }

feren02 12-19-2020 02:21

Re: Set lefthand and righthand weapon skins
 
Quote:

Originally Posted by CrazY. (Post 2729202)
Code:
foo(id) {     new buf[15]     get_user_info(id, "lefthand", buf, charsmax(buf))     if (str_to_num(buf) == 1)     {         // set lefthand model     }     else     {         // set righthand model     } }

Hi there! Thank you for really extending your knowledge to me, will have to try this.

Is it okay to ask where to insert this in my existing .sma? Here is the copy of it:

PHP Code:

#include <amxmodx>  
#include <amxmisc>  
#include <cstrike>  
#include <fakemeta>

new const v_knife [] = "models/olgPH_weapons/v_neonknife.mdl";  
new const 
v_knife_r [] = "models/olgPH_weapons/v_neonknife_r.mdl"
new const 
v_m4a1 [] = "models/olgPH_weapons/v_neonm4a1.mdl";  
new const 
v_m4a1_r [] = "models/olgPH_weapons/v_neonm4a1_r.mdl";  
new const 
v_ak47 [] = "models/olgPH_weapons/v_neonak47.mdl";  
new const 
v_ak47_r [] = "models/olgPH_weapons/v_neonak47_r.mdl";  
new const 
v_awp [] = "models/olgPH_weapons/v_neonawp.mdl";  
new const 
v_awp_r [] = "models/olgPH_weapons/v_neonawp_r.mdl";  
//new const v_usp [] = "models/usp_comet.mdl";  
//new const v_glock18 [] = "models/glock18_water.mdl";  
new const v_deagle [] = "models/olgPH_weapons/v_neondeagle.mdl";  
new const 
v_deagle_r [] = "models/olgPH_weapons/v_neondeagle_r.mdl";  


new 
g_HaveFlags;  


public 
plugin_init( )  
{  
    
register_plugin"Server Models""1.0""feruchio" );  
    
    
    
register_event"CurWeapon""event_Curwp""be""1=1""2=18""2=22""2=26""2=28""2=29" );  
    
    
g_HaveFlags register_cvar"admin_knife_flags""t" );  
}  


public 
plugin_precache( )  
{  
    
precache_modelv_knife );  
    
precache_modelv_knife_r );  
    
precache_modelv_m4a1 ); 
    
precache_modelv_m4a1_r ); 
    
precache_modelv_ak47 ); 
    
precache_modelv_ak47_r ); 
    
precache_modelv_awp ); 
    
precache_modelv_awp_r ); 
//    precache_model( v_usp ); 
//    precache_model( v_glock18 ); 
    
precache_modelv_deagle ); 
    
precache_modelv_deagle_r ); 
}  

public 
event_Curwpid )  
{  
    new 
szHaveFlag[15];  
    
get_pcvar_stringg_HaveFlagsszHaveFlagcharsmaxszHaveFlag ) )  
    
    new 
WeaponIdUserHandle get_user_weaponid );
    
    if( 
has_all_flagsidszHaveFlag ) )  
    {  
        switch ( 
WeaponIdUserHandle )
        {
            case 
CSW_KNIFEset_pevidpev_viewmodel2v_knife );
            case 
CSW_M4A1set_pevidpev_viewmodel2v_m4a1 );
            case 
CSW_AK47set_pevidpev_viewmodel2v_ak47 );
            case 
CSW_AWPset_pevidpev_viewmodel2v_awp );
//            case CSW_USP: set_pev( id, pev_viewmodel2, v_usp );
//            case CSW_GLOCK18:set_pev( id, pev_viewmodel2, v_glock18 );
            
case CSW_DEAGLE:set_pevidpev_viewmodel2v_deagle );
        }
    }  
    
    return 
PLUGIN_CONTINUE;  



Looking forward! :)

CrazY. 12-19-2020 06:35

Re: Set lefthand and righthand weapon skins
 
If the *_r models are the right hand ones, something like this

Code:
public event_Curwp( id )   {       new szHaveFlag[15];       get_pcvar_string( g_HaveFlags, szHaveFlag, charsmax( szHaveFlag ) )           new WeaponIdUserHandle = get_user_weapon( id );         if( has_all_flags( id, szHaveFlag ) )       {         new szLeftHand[15]         get_user_info(id, "lefthand", szLeftHand, charsmax(szLeftHand))         if (str_to_num(szLeftHand) == 1)         {             // left hand models here             switch ( WeaponIdUserHandle )             {                 case CSW_M4A1: set_pev( id, pev_viewmodel2, v_m4a1 );             }         }         else         {             // right hand models here             switch ( WeaponIdUserHandle )             {                 case CSW_M4A1: set_pev( id, pev_viewmodel2, v_m4a1_r );             }         }     }           return PLUGIN_CONTINUE;   }

feren02 12-30-2020 01:36

Re: Set lefthand and righthand weapon skins
 
Quote:

Originally Posted by CrazY. (Post 2729325)
If the *_r models are the right hand ones, something like this

Code:
public event_Curwp( id )   {       new szHaveFlag[15];       get_pcvar_string( g_HaveFlags, szHaveFlag, charsmax( szHaveFlag ) )           new WeaponIdUserHandle = get_user_weapon( id );         if( has_all_flags( id, szHaveFlag ) )       {         new szLeftHand[15]         get_user_info(id, "lefthand", szLeftHand, charsmax(szLeftHand))         if (str_to_num(szLeftHand) == 1)         {             // left hand models here             switch ( WeaponIdUserHandle )             {                 case CSW_M4A1: set_pev( id, pev_viewmodel2, v_m4a1 );             }         }         else         {             // right hand models here             switch ( WeaponIdUserHandle )             {                 case CSW_M4A1: set_pev( id, pev_viewmodel2, v_m4a1_r );             }         }     }           return PLUGIN_CONTINUE;   }

Hi there, will have to try this, will keep you updated! Happy holidays! :)


All times are GMT -4. The time now is 14:09.

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