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

help with CSPUM.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-04-2016 , 17:00   help with CSPUM.
Reply With Quote #1

Hello guys, i have 2 big problems with my cspum , i will try to be clear and directly.


1. With the current CODE ( i will post down .. ) is working everything just one fact! - When i touch a weapon is not Removing or Block Drop ... it let me pick up the weapon .. But after i drop it if i try to touch it again the plugin is doing his job wich means Remove/Blocking pick up(depends of the cvar ) ... so it working only after i touch it and drop to test it ... i think the problem is because gBlockingWeapons bitfield, because i check in the nvault file and is perfectly saving/removing everything works well with nvault.

2. That's not a problem, but a question ... How can i add to block the armoury entity because i have no clue how to do it ... bugsy show me how to remove it but not also how to block it ... ii aded it in they array with the index 32 ( started from 0 to count ) ... i added "kevlar' because his model is w_kevlar.mdl and my plugin already format the w_%s.mdl part, howevery it is not working ... anyway i removed everything and in the current code i will post is without any attempts of adding the armor, so about the problem 1 i'm more waiting, thanks!


The code is here, thanks guys

PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <fakemeta> 
#include <nvault> 
#include <engine> 
#include <cstrike> 
#include <hamsandwich> 

new const PLUGIN[] = "CS Pick up manager"
     
VERSION[] = "1.2",  
      
AUTHOR[] = "Craxor"


new const 
gKeyList[][] = 

    
"" 
    
"p228" 
    
"" 
    
"scout" 
    
"hegrenade" 
    
"xm1014" 
    
"c4" 
    
"mac10" 
    
"aug" 
    
"smokegrenade" 
    
"elite" 
    
"fiveseven" 
    
"ump45" 
    
"sg550" 
    
"galil" 
    
"famas" 
    
"usp" 
    
"glock18" 
    
"" 
    
"mp5navy" 
    
"m249" 
    
"m3" 
    
"m4a1" 
    
"tmp" 
    
"g3sg1" 
    
"flashbang" 
    
"deagle" 
    
"sg552" 
    
"ak47" 
    
"" 
    
"p90" 
    
"shield"

}; 


new 
giTypeCvar
new 
gNewVault


new 
gBlockWeapons;  
new 
gIgnoreWeapons = ( ( << ) | ( << ) | ( << 18 ) | ( << 29 ) ); 


new const 
gModelFile[] = "models/w_%s.mdl";  

const 
CSW_SHIELD 31
const 
XoCArmoury 
const m_iCount 35

public plugin_init( ) 

    
register_plugin 
    

        .
plugin_name PLUGIN,  
        .
version     VERSION,  
        .
author      AUTHOR 
    
); 

    
gNewVault nvault_open"cspick_up_manager_vault" ); 

    if( 
gNewVault == INVALID_HANDLE 
        
set_fail_state"Problems openning cspick up manager vault." ); 
    
    
register_concmd"amx_cspum_addkey" "addkey" ADMIN_BAN " < Weapon key-name to block > " ); 
    
register_concmd"amx_cspum_remkey" "remkey" ADMIN_BAN " < Weapon key-name to block > " );
 
    
register_concmd"amx_cspum_blocklist" "block_all" ADMIN_BAN  );
    
register_concmd"amx_cspum_resetlist" "reset" ADMIN_BAN  );

    
register_concmd"amx_cspum_keylist" "showkeylist" ADMIN_BAN ); 

    new 
EntityPlayerClass [] = "player";
    
    
register_touch"armoury_entity" EntityPlayerClass "player_touch" );  
    
register_touch"weaponbox" EntityPlayerClass "player_touch" );  
    
register_touch"weapon_shield" EntityPlayerClass "player_touch" );  
    
    
/*
        cspum_type 
            "1"
    */
    
giTypeCvar register_cvar"cspum_type" "2" ); 


public 
plugin_cfg() 

    new 
szModel12 14 ] , szVal] , iTS
    
    for( new 
sizeof gKeyList ) ; i++ ) 
    { 
        if ( !( 
gIgnoreWeapons & ( << ) ) ) 
        { 
            
formatexszModel charsmaxszModel ) , gModelFile gKeyList] ); 
            
            if ( 
nvault_lookupgNewVault szModel szVal charsmaxszVal ) , iTS ) ) 
            { 
                
gBlockWeapons |= ( << ); 
            } 
        } 
    } 


public 
plugin_end()  

    
nvault_closegNewVault );  


public 
addkeyid level cid 

    if( !
cmd_accessid level cid ) ) 
        return 
PLUGIN_HANDLED
    
    new 
szWeaponArg13 ] , szModelFile12 14 ] , szVaultData] , iTS iFoundIndex = -1

    
read_argv1szWeaponArgcharsmaxszWeaponArg ) );

    
    
formatexszModelFile charsmaxszModelFile ), gModelFile szWeaponArg ); 
    
    if( 
nvault_lookupgNewVault szModelFile szVaultDatacharsmaxszVaultData ) , iTS ) ) 
    { 
        
client_printid print_console "This key is already saved in the pick up manager list." ); 
        return 
PLUGIN_HANDLED
    } 
    
    for( new 
sizeof gKeyList ) ; i++ ) 
    { 
        if ( 
containigKeyList] , szWeaponArg ) > -&& !( gIgnoreWeapons & ( << ) ) ) 
        { 
            
iFoundIndex i
            break; 
        } 
    } 
    
    if ( 
iFoundIndex == -
    { 
        
client_printid print_console"Unable to find the key '%s', type amx_cspum_keylist for all keys available to insert." szWeaponArg ); 
    } 

    else 
    { 
        
client_printid print_console "You successfully added '%s' to the list!" szWeaponArg ); 
        
        
gBlockWeapons |= ( << iFoundIndex ); 
        
        
nvault_setgNewVault szModelFile "1" ); 
    } 
    
    return 
PLUGIN_HANDLED
}


public 
remkeyidlevelcid 

    if( !
cmd_accessidlevelcid) ) 
        return 
PLUGIN_HANDLED
    
    new 
szWeaponArg13 ] , szModelFile12 14 ] , szVaultData] , iTS iFoundIndex

    
read_argv1szWeaponArgcharsmaxszWeaponArg ) );
    
    
    
formatexszModelFile charsmaxszModelFile ) , gModelFile szWeaponArg ); 
    
    if( !
nvault_lookupgNewVault szModelFile szVaultData charsmaxszVaultData ) , iTS ) ) 
    { 
        
client_printid print_console "Sorry, this key is not saved yet." ); 
        return 
PLUGIN_HANDLED
    } 
    
    for( new 
sizeof gKeyList ) ; i++ ) 
    { 
        if ( 
containigKeyList] , szWeaponArg ) > -&& !( gIgnoreWeapons & ( << ) ) ) 
        { 
            
iFoundIndex i
            break; 
        } 
    } 
    
    
client_printid print_console "You succesfully removed '%s' from the list!" szWeaponArg ); 
    
    
gBlockWeapons &= ~( << iFoundIndex ); 
    
    
nvault_removegNewVault szModelFile ); 
    
    return 
PLUGIN_HANDLED


public 
block_allidlevelcid )

    if( !
cmd_accessid level cid ) ) 
        return 
PLUGIN_HANDLED
    

    new 
szModelFile12 14 ]; 

    for( new 
sizeof gKeyList ) ; i++ ) 
    {
        if ( !( 
gIgnoreWeapons & ( << ) ) && !( gBlockWeapons & ( << ) ) )
        {
            
formatexszModelFile charsmaxszModelFile ), gModelFile gKeyList] );
            
gBlockWeapons |= ( << );

            
nvault_setgNewVault szModelFile "1" );  
        }
    }
 
    
client_printidprint_console"All the weapons have been added inside of the list!" );      

    return 
PLUGIN_HANDLED
}

public 
resetidlevelcid )
{
    if( !
cmd_accessid level cid ) ) 
        return 
PLUGIN_HANDLED;


    
nvault_prunegNewVault0get_systime( ) );
    
client_printidprint_console"You've succesfully reseted all the list!" );

    
gBlockWeapons 0;
        

    return 
PLUGIN_HANDLED;
}

public 
showkeylistid levelcid 

    if( !
cmd_accessidlevelcid) ) 
        return 
PLUGIN_HANDLED;
    
    
client_printid print_console "========== All weapons available to add to the list ========== " ); 
    
    for( new 
0sizeofgKeyList ); i++ ) 
    { 
        if ( 
gKeyList][ ] && !( gIgnoreWeapons & ( << ) ) ) 
            
client_printid print_console " %s" gKeyList]  ); 
    } 
    
    return 
PLUGIN_HANDLED


public 
player_touchent id )  
{  
    if( !
pev_valident ) || !id || !( pevent pev_flags) & FL_ONGROUND ) )  
        return -
1
    
    new 
iWeaponID iCvarValue szClassName], iWeaponType
    
    
pevent pev_classname szClassName charsmaxszClassName ) ); 
    
    switch ( 
szClassName] ) 
    { 
        case 
'b':
        {
            
iWeaponID cs_get_weaponbox_typeent );
            
iWeaponType 1;
        } 

 
        case 
'_'
        {
            
iWeaponID CSW_SHIELD;
            
iWeaponType 0;
        } 
    } 
    
    if ( 
iWeaponID && ( gBlockWeapons & ( << iWeaponID ) ) )  
    { 
        
iCvarValue get_pcvar_numgiTypeCvar ); 
        
        switch( 
iCvarValue 
        { 
            case 
1:
            {

                if( 
iWeaponType )
                    
call_thinkent );
                else
                    
engfuncEngFunc_RemoveEntityent );

            }
            case 
2: return PLUGIN_HANDLED
            default: return 
PLUGIN_CONTINUE
        } 
    } 
    
    return 
PLUGIN_CONTINUE
}  

cs_get_weaponbox_typeiWeaponBox 

    new 
iWeapon 
    
new const m_rgpPlayerItems_CWeaponBox] = { 34 35 , ... };  

    for ( new 
<= i++ ) 
    { 
        if( ( 
iWeapon get_pdata_cbaseiWeaponBox m_rgpPlayerItems_CWeaponBox] , XoCArmoury ) ) > 
        { 
            return 
cs_get_weapon_idiWeapon 
        } 
    } 

    return 


__________________
Project: Among Us

Last edited by Craxor; 12-04-2016 at 17:00.
Craxor is offline
Send a message via ICQ to Craxor
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-04-2016 , 17:11   Re: help with CSPUM.
Reply With Quote #2

Quote:
Originally Posted by Craxor View Post
Hello guys, i have 2 big problems with my cspum , i will try to be clear and directly.


1. With the current CODE ( i will post down .. ) is working everything just one fact! - When i touch a weapon is not Removing or Block Drop ... it let me pick up the weapon .. But after i drop it if i try to touch it again the plugin is doing his job wich means Remove/Blocking pick up(depends of the cvar ) ... so it working only after i touch it and drop to test it ... i think the problem is because gBlockingWeapons bitfield, because i check in the nvault file and is perfectly saving/removing everything works well with nvault.

2. That's not a problem, but a question ... How can i add to block the armoury entity because i have no clue how to do it ... bugsy show me how to remove it but not also how to block it ... ii aded it in they array with the index 32 ( started from 0 to count ) ... i added "kevlar' because his model is w_kevlar.mdl and my plugin already format the w_%s.mdl part, howevery it is not working ... anyway i removed everything and in the current code i will post is without any attempts of adding the armor, so about the problem 1 i'm more waiting, thanks!
This is because when a weapon is on the ground that has never been picked up (like on fy_iceworld, fy_snow) it is an armoury entity. When a player picks it up and drops it, it becomes a weaponbox. Your touch code does not appear to have any handling for when an armoury_entity is touched.

While you registered the touch event for it, the function has no handling for it. I would also add more than a single character check for each type.
PHP Code:
    switch ( szClassName] ) 
    { 
        case 
'b':
        {
            
iWeaponID cs_get_weaponbox_typeent );
            
iWeaponType 1;
        } 
        case 
'_'
        {
            
iWeaponID CSW_SHIELD;
            
iWeaponType 0;
        } 
    } 
To get weapon ID and count (I dont think you need count) of an armoury_entity, use:
PHP Code:
const m_iType 34;
const 
m_iCount 35;
const 
XO_Armoury 4;

get_pdata_intiEntity m_iType XO_Armoury 
Here is a macro I used in my Armoury Manager plugin to check if the entity classname is 'armoury_entity'. You can create the same for weaponbox and shield.
PHP Code:
#define IsArmoury(%1)        (%1[0]=='a'&&%1[1]=='r'&&%1[7]=='_'&&%1[8]=='e'&&%1[12]=='t'&&%1[13]=='y') 
__________________

Last edited by Bugsy; 12-04-2016 at 17:19.
Bugsy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-05-2016 , 06:33   Re: help with CSPUM.
Reply With Quote #3

Is this correct ( about macros only ):

PHP Code:
    weaponbox 
'w' == 0
'e' == 1
'a' == 2
'p' == 3
'o' == 4
'n' == 5
'b' == 6
'o' == 7
'x' == 8

    armoury_entity 
'a' == 0
'r' == 1
'm' == 2
'o' == 3
'u' == 4
'r' == 5
'y' == 6  
'_' == 7
'e' == 8
'n' == 9
't' == 10
'i' == 11
't' == 12
'y' == 13

    weapon_shield
'w' == 0
'e' == 1
'a' == 2
'p' == 3
'o' == 4
'n' == 5
'_' == 6
's' == 7
'h' == 8
'i' == 9
'e' == 10
'l' == 11
'd' == 12

#define IsArmoury(%1)        (%1[0]=='a'&&%1[1]=='r'&&%1[7]=='_'&&%1[8]=='e'&&%1[12]=='t'&&%1[13]=='y')  
#define IsWpBox(%1)        (%1[0]=='w'&&%1[1]=='e'&&%1[5]=='n'&&%1[7]=='o'&&%1[8]=='x')
#define IsAShield(%1)        (%1[0]=='w'&&%1[1]=='e'&&%1[7]=='s'&&%1[8]=='h'&&%1[9]=='i'&&%1[11]=='l'&&%1[12]=='d') 
__________________
Project: Among Us

Last edited by Craxor; 12-05-2016 at 07:20.
Craxor is offline
Send a message via ICQ to Craxor
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-05-2016 , 07:00   Re: help with CSPUM.
Reply With Quote #4

Is doing the same thing, what i'm doing wrong ..

I just need to check wich kind of entity is using the macross, but after i know i don't need a separate way of removing them?

SMA



Edit: I added some client_print messages to see if it is checking correct wich kind of entity Is, the problem is the macross for checking armoury_entity is not working, but weaponbox and shield works good ... so the problem is at the macross.
__________________
Project: Among Us

Last edited by Craxor; 12-05-2016 at 07:18.
Craxor is offline
Send a message via ICQ to Craxor
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-05-2016 , 07:48   Re: help with CSPUM.
Reply With Quote #5

If you're confident it's the macro, print out the classname and see why it is not working.
__________________
Bugsy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-05-2016 , 07:52   Re: help with CSPUM.
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
If you're confident it's the macro, print out the classname and see why it is not working.
That's what i have done ... i aded client_print messages to see when i touch the entity if is printing me the message, look here:
PHP Code:
    if( IsArmouryszClassName ) )
    {
        
iWeaponID get_pdata_intent m_iType XoCArmoury )  
        
iWeaponType 1;
        
client_printidprint_chat"%s ( Armoury )"szClassName );
    }

    else if ( 
IsWpBoxszClassName ) )
    {
        
iWeaponID cs_get_weaponbox_typeent );
        
iWeaponType 1;
        
client_printidprint_chat"%s ( box )"szClassName );
    }

    else if ( 
IsAShieldszClassName ) )
    {
        
client_printidprint_chat"%s ( shield)"szClassName );
        
iWeaponID CSW_SHIELD;
        
iWeaponType 0;
    }

    else
    {
        
iWeaponID 0;
        
iWeaponType 0;
    
    } 
Client_print .. bla bla ... is checking me perfectly for all classes Shield And WeaponBox ,... but when i touch an armoury_entity Nothing is printed ... i do not know why ..


Edit: LOOl, i added also one in last else() and the szClassName it is: "armoury_entit" without 'y' , why? let me a second to see

I assume it because szClassaName [ size ] but why '14' is not ok? I mean armoury_entity it is '13' lengh size + One NULL Char it is not enough ? i need to put 15 .. i will come with edit


Edit: Yes, now is checking correctly the entity_armoury ... But it still not blocking it
__________________
Project: Among Us

Last edited by Craxor; 12-05-2016 at 07:57.
Craxor is offline
Send a message via ICQ to Craxor
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-06-2016 , 09:13   Re: help with CSPUM.
Reply With Quote #7

Hamlet tell my armoury_entity cannot be removed with call_think() or with Engfunc Remove entity, i need to 'hide' them .. but even like that if the cvar is '2' they will not be blocked when i touch them and also i forgot how he tell me and i can't found the reply i search everywhere ... some help ?
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-06-2016 , 09:54   Re: help with CSPUM.
Reply With Quote #8

You should be able to kill the ent.

Set the count to 0.. But you may need to do this each round, take a look at my armoury manager plugin
__________________

Last edited by Bugsy; 12-06-2016 at 09:57.
Bugsy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-06-2016 , 09:59   Re: help with CSPUM.
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
You should be able to kill the ent.

Set the count to 0.. But you may need to do this each round, take a look at my armoury manager plugin

What do you mean "set the count to 0" as you see i not even used the count in get_pdada_int ... however i will better look in your armoury manager because i can see there more about the entitty entity_armoury management how to delete, etc ...
__________________
Project: Among Us

Last edited by Craxor; 12-06-2016 at 10:27.
Craxor is offline
Send a message via ICQ to Craxor
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-06-2016 , 10:19   Re: help with CSPUM.
Reply With Quote #10

You don't need to use/have the count to set it to 0. Once this is done, the weapon will disappear, but like I said it may reappear at new round. Take a look at my plugin to check what I did.

set_pdata_int( ent , m_iCount , 0 , XoCArmoury )

Also not sure but the player is touching the ent so it may get picked up before it is set to 0 so this may be a bad idea. Just kill the entity. Maybe set to 0 then return PLUGIN_HANDLED?
__________________

Last edited by Bugsy; 12-06-2016 at 10:26.
Bugsy 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 13:00.


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