Raised This Month: $12 Target: $400
 3% 

Owner Knife Only When CT


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SHIFT0
Senior Member
Join Date: Apr 2021
Location: Palestine
Old 11-05-2021 , 18:18   Owner Knife Only When CT
Reply With Quote #1

Hi Guys i want this owner knife only when iam CT Not for T cuz for T
I did it zm knife
so just for CT I want it

PHP Code:
/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "Owner Knife"
#define VERSION "1.0"
#define AUTHOR "Edited By SHIFT0"


new const v_Knife_Owner[64] = "models/owner_knife/v_knife_owner.mdl"
new const p_Knife_Owner[64] = "models/owner_knife/p_knife_owner.mdl"

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

public 
plugin_precache( ) {
    
precache_modelv_Knife_Owner )
    
precache_modelp_Knife_Owner )
    
}

public 
Event_CurWeaponid ) {
    new 
Arma read_data)
    
    if( 
get_user_flagsid ) == ADMIN_IMMUNITY && Arma == CSW_KNIFE){
        
set_pevidpev_viewmodel2v_Knife_Owner )
        
set_pevidpev_weaponmodel2p_Knife_Owner )
        
    }
    
    
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1036\\ f0\\ fs16 \n\\ par }
*/ 

Last edited by SHIFT0; 11-05-2021 at 18:18. Reason: Edited Errors
SHIFT0 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-05-2021 , 20:01   Re: Owner Knife Only When CT
Reply With Quote #2

PHP Code:
if( get_user_flagsid ) == ADMIN_IMMUNITY && Arma == CSW_KNIFE
-->

PHP Code:
if( get_user_flagsid ) == ADMIN_IMMUNITY && Arma == CSW_KNIFE && cs_get_user_team(id) == CS_TEAM_CT
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-05-2021 , 21:14   Re: Owner Knife Only When CT
Reply With Quote #3

I used get_user_team because when using cs_get_user_team the plugin will not work with zp mod, bb mod or it will give bug:

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

// Credits : @Bugsy for some optimizations
enum
{
    
TEAM_UNASSIGNED 0,
    
TEAM_T,
    
TEAM_CT,
    
TEAM_SPEC
}

enum pWeapons
{
    
WeaponsID,
    
ModelV64 ],
    
ModelP64 ],
    
Access,
    
Teams
}

new 
g_szWeapons[ ][ pWeapons ] = 
{
    
/* Weapon ID,         Model V,            Model P            Access */
    
CSW_KNIFE"models/vipweapons/knife.mdl""models/vipweapons/knife.mdl"ADMIN_LEVEL_ATEAM_CT },// Owner knife model
    
CSW_KNIFE"models/vipweapons/knife.mdl""models/vipweapons/knife.mdl"ADMIN_LEVEL_HTEAM_CT }, // Vip knife model
    
CSW_AK47"models/vipweapons/ak47.mdl"""ADMIN_LEVEL_HTEAM_CT },
    { 
CSW_M4A1"models/vipweapons/m4a1.mdl"""ADMIN_LEVEL_HTEAM_CT },
    { 
CSW_AWP"models/vipweapons/awp.mdl"""ADMIN_LEVEL_HTEAM_CT  }
}

public 
plugin_init() 
{
    
register_plugin("Weapon models""1.0.2""Supremache")
    
register_event("CurWeapon""OnCurWeapon""be""1=1");
}

public 
plugin_precache( )
{
    for( new 
sizeofg_szWeapons ); i++ )
    {
        if( 
g_szWeapons][ ModelV ][ ] != EOS )
        {
            
precache_modelg_szWeapons][ ModelV ] )
        }
        
        if( 
g_szWeapons][ ModelP ][ ] != EOS )
        {
            
precache_modelg_szWeapons][ ModelP ] )
        }
    }
}

public 
OnCurWeaponid )
{
    if( !
is_user_aliveid ) ) 
    {
        return;
    }
    
    new 
iWeapon read_data(2);
    
    for(new 
sizeofg_szWeapons ); i++ )
    {
        if( 
get_user_teamid ) == g_szWeapons][ Teams ] && ( get_user_flagsid ) & g_szWeapons][ Access ] == g_szWeapons][ Access ] ) && iWeapon == g_szWeapons][ WeaponsID ] )
        {
            if( 
g_szWeapons][ ModelV ][ ] != EOS )                        
                
set_pevidpev_viewmodel2g_szWeapons][ ModelV ] )
        
            if( 
g_szWeapons][ ModelP ][ ] != EOS )
                
set_pevidpev_weaponmodel2g_szWeapons][ ModelP ] )
                
            break;
        }
    }

__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 11-06-2021 at 14:36.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-05-2021 , 21:29   Re: Owner Knife Only When CT
Reply With Quote #4

It may work as-is, but I'd use g_szWeapons[ i ][ ModelV ][ 0 ] and g_szWeapons[ i ][ ModelP ][ 0 ]
Code:
public plugin_precache( ) {     for( new i = 0 ; i < charsmax( g_szWeapons ); i++ )     {
        if( g_szWeapons[ i ][ ModelV ] != EOS )
        {             precache_model( g_szWeapons[ i ][ ModelV ] )         }        
        if( g_szWeapons[ i ][ ModelP ] != EOS )
        {             precache_model( g_szWeapons[ i ][ ModelP ] )         }     } }

To allow support for multiple flags, I'd do: ( get_user_flags( id ) & g_szWeapons[ i ][ Access ] == g_szWeapons[ i ][ Access ] )
Code:
        if( get_user_flags( id ) & g_szWeapons[ i ][ Access ] && iWeapon == g_szWeapons[ i ][ WeaponsID ] )
        {             set_pev( id, pev_viewmodel2, g_szWeapons[ i ][ ModelV ] )             set_pev( id, pev_weaponmodel2, g_szWeapons[ i ][ ModelP ] )                         break;         }
__________________

Last edited by Bugsy; 11-05-2021 at 21:30.
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-05-2021 , 22:55   Re: Owner Knife Only When CT
Reply With Quote #5

Thanks for this but i think you advised me before to use EOS better than check variable had found or not!


I added team info i see this would be better with this plugin
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-05-2021 , 23:18   Re: Owner Knife Only When CT
Reply With Quote #6

What do you mean? I'm not saying to not use EOS, only that you should check the first character of the string. But, this may not be required as the string variable alone by default begins with the first character (0), so it may not be required. I'd just recommend testing it.
__________________
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-05-2021 , 23:27   Re: Owner Knife Only When CT
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
What do you mean? I'm not saying to not use EOS, only that you should check the first character of the string. But, this may not be required as the string variable alone by default begins with the first character (0), so it may not be required. I'd just recommend testing it.
I said you advise use EOS but i know the two ways will work, anyway i will use this way and thanks again for these details
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-05-2021 , 23:29   Re: Owner Knife Only When CT
Reply With Quote #8

I just tested it and I get "Error: Array must be indexed (variable "szTest") on line 15". So add [0] in your code.
PHP Code:
new szTest];
    
if ( 
szTest == EOS )
    
server_print"empty" ); 
Edit: I just tested your code and the compiler accepts it. Just change charsmax() to sizeof() in the for loop in plugin_precache().
__________________

Last edited by Bugsy; 11-05-2021 at 23:39.
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-05-2021 , 23:40   Re: Owner Knife Only When CT
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
I just tested it and I get "Error: Array must be indexed (variable "szTest") on line 15". So add [0] in your code.
Well, i understood!

Quote:
Originally Posted by Bugsy View Post
Edit: I just tested your code and the compiler accepts it. Just change charsmax() to sizeof() in the for loop in plugin_precache().
Done.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 11-05-2021 at 23:41.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-05-2021 , 23:51   Re: Owner Knife Only When CT
Reply With Quote #10

Use sizeof() in OnCurWeapon as well. Any time you are looping through an array, use sizeof(). charsmax() should only be used in string functions/natives to set the max chars.

You should probably also check that a model exists in the string here. Or atleast for model P
Code:
    for( new i = 0 ; i < charsmax( g_szWeapons ); i++ )
    {         if( get_user_team( id ) == g_szWeapons[ i ][ Teams ] && ( get_user_flags( id ) & g_szWeapons[ i ][ Access ] == g_szWeapons[ i ][ Access ] ) && iWeapon == g_szWeapons[ i ][ WeaponsID ] )         {
            if ( g_szWeapons[ i ][ ModelV ][ 0 ] != EOS )
                        set_pev( id, pev_viewmodel2, g_szWeapons[ i ][ ModelV ] )
            if ( g_szWeapons[ i ][ ModelP ][ 0 ] != EOS )
                        set_pev( id, pev_weaponmodel2, g_szWeapons[ i ][ ModelP ] )                         break;         }     }
__________________

Last edited by Bugsy; 11-05-2021 at 23:52.
Bugsy is offline
Reply


Thread Tools
Display Modes

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 04:08.


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