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

help with CSPUM.


Post New Thread Reply   
 
Thread Tools Display Modes
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-09-2016 , 11:23   Re: help with CSPUM.
Reply With Quote #21

Quote:
Originally Posted by HamletEagle View Post
PHP Code:
containigKeyList] , szWeaponArg 
r, u, p, l are contained in gKeyList[i]. Your check needs to be improved.
Maybe if i check the equality of each string in part ?
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-09-2016 , 11:36   Re: help with CSPUM.
Reply With Quote #22

You can use equali for sure. The keys are not hard and there is a list, so no issue for the end user.
__________________

Last edited by HamletEagle; 12-09-2016 at 11:36.
HamletEagle is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-09-2016 , 18:11   Re: help with CSPUM.
Reply With Quote #23

I fixed your addkey() function a bit to avoid the nvault_lookup() call and to scan the key list before doing anything. It will also only add valid keys to the bitsum/vault. If a user tries to add 'gren', it will add the first found in the list that has 'gren' in it (hegrenade). On the 2nd attempt, it will say 'hegrenade' is already on the list. What would be cleaner is to scan the entire list for dupes and force the user to only enter a unique key value. You can work on that part. You should apply the below logic to your remkey() function.
PHP Code:
public addkeyid level cid 

    if( !
cmd_accessid level cid ) ) 
        return 
PLUGIN_HANDLED
    
    new 
szWeaponArg13 ] , szModelFile12 14 ] , iFoundIndex = -1
    
    
read_argv1szWeaponArgcharsmaxszWeaponArg ) );
    
    for( new 
sizeof gKeyList ) ; i++ ) 
    { 
        if ( 
gKeyList][ ] && ( containigKeyList] , szWeaponArg ) > -) ) 
        { 
            if ( 
gBlockWeapons & ( << ) )
            {
                
client_printid print_console "'%s' is already saved in the pick up manager list." gKeyList] ); 
                return 
PLUGIN_HANDLED
            }
            else if ( !( 
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 
    { 
        
gBlockWeapons |= ( << iFoundIndex ); 

        
formatexszModelFile charsmaxszModelFile ) , gModelFile gKeyListiFoundIndex ] ); 
        
nvault_setgNewVault szModelFile "1" ); 
        
        
client_printid print_console "You successfully added '%s' to the list!" gKeyListiFoundIndex ] ); 
    } 
    
    return 
PLUGIN_HANDLED

__________________

Last edited by Bugsy; 12-09-2016 at 18:16.
Bugsy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-09-2016 , 19:07   Re: help with CSPUM.
Reply With Quote #24

So , insteand of using nvault_lookup() you've replace with checking if is in the bitfield no?

Just a little to make my logic, in your else if ( ) { ... there it is also returning if is NOT in bitfield not only the condition you've put with gIgnoreWeapon, i'm right?


The only thing that i do not understand it it is here:
PHP Code:
if ( gKeyList][ ] && ( containigKeyList] , szWeaponArg ) > -) ) 
What suppose to do gKeyList[i][0] ? you check if is not an empty spaces or what? why [0] ? It is the start or what .. i really have no idea what's means.
__________________
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-09-2016 , 19:09   Re: help with CSPUM.
Reply With Quote #25

Quote:
Originally Posted by Craxor View Post
So , insteand of using nvault_lookup() you've replace with checking if is in the bitfield no?
Yes. All of your current blocked weapons are in the bitfield. It's pointless to call a native when you can just check the bitfield.

Quote:
Originally Posted by Craxor View Post
Just a little to make my logic, in your else if ( ) { ... there it is also returning if is NOT in bitfield not only the condition you've put with gIgnoreWeapon, i'm right?
I removed the ignore weapon check and instead used just check the first character to see if it's empty. May be slightly more efficient, while not noticeable.
Quote:
Originally Posted by Craxor View Post
The only thing that i do not understand it it is here:
PHP Code:
if ( gKeyList][ ] && ( containigKeyList] , szWeaponArg ) > -) ) 
See above comments. If ( ( theres a weapon in this slot ) AND ( arg exists in a key ) )

Quote:
Originally Posted by Craxor View Post
What suppose to do gKeyList[i][0] ? you check if is not an empty spaces or what? why [0] ? It is the start or what .. i really have no idea what's means.
Your ignore list contained only those indexes where a weapon does not exist (""), so instead of doing the bit-wise &, I figured I'd just check if there is a weapon in that slot. IMO, you should not hard-code any ignore weapons.

I created a function for you to get the weapon index. It will either return weapon not found, duplicates found, or the weapon index. Instead of posting your plugin multiple times, I will modify what is posted here. Your addkey function should be good to go, try to apply similar to remkey().
__________________

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

So to my question, is doing the same thing as IgnoreWeapons .. now about your function , yes is better like that Thanks bugsy .. let my test now to see if is working weell
__________________
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-10-2016 , 08:03   Re: help with CSPUM.
Reply With Quote #27

Quote:
Originally Posted by Craxor View Post
So to my question, is doing the same thing as IgnoreWeapons .. now about your function , yes is better like that Thanks bugsy .. let my test now to see if is working weell
Yes it does the same, I'll add comments later to help u understand
__________________
Bugsy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-10-2016 , 08:38   Re: help with CSPUM.
Reply With Quote #28

Bugsy i have problems in adding to remkey your fucntion, i tried like that:
PHP Code:

    iFoundIndex 
GetWeaponIndexszWeaponArg );
    
    if( 
iFoundIndex == GWI_NotFound )
    {
        
client_printidprint_console"This weapon '%s' is not saved yet or not exist, type amx_cspum_blockedlist to see all the keys blocked!"szWeaponArg );
        return 
PLUGIN_HANDLED;

    } 

Wich is not working if i put 'x' or 'd' or a letter wich contain from the blocked weapons, btw, also i made a new function to show all the blocked weapons:
PHP Code:
public blockedlistidlevelcid )
{
    if( !
cmd_accessid levelcid) )
        return 
PLUGIN_HANDLED;

    
client_printid print_console " ~~ All blocked weapons ~~~ " );

    for( new 
0sizeofgKeyList ); i++ )
    {
        if ( 
gKeyList][ ] && !( gIgnoreWeapons & ( << ) ) && ( gBlockWeapons & ( << ) ) )
                
client_printid print_console "%s"gKeyList] );
    }
    return 
PLUGIN_HANDLED;



About the problem , i cannot check with GWI_Notfound return if no index founded, Gwi duplicate return if chars from the contrained string are founded , but i want to avoid that, i want to force admin put the whole key... so i'm confuse, however, the whole code:
SMA
__________________
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-10-2016 , 11:29   Re: help with CSPUM.
Reply With Quote #29

Quote:
Originally Posted by Craxor View Post
Wich is not working if i put 'x' or 'd' or a letter wich contain from the blocked weapons, btw, also i made a new function to show all the blocked weapons:
PHP Code:
public blockedlistidlevelcid )
{
    if( !
cmd_accessid levelcid) )
        return 
PLUGIN_HANDLED;

    
client_printid print_console " ~~ All blocked weapons ~~~ " );

    for( new 
0sizeofgKeyList ); i++ )
    {
        if ( 
gKeyList][ ] && !( gIgnoreWeapons & ( << ) ) && ( gBlockWeapons & ( << ) ) )
                
client_printid print_console "%s"gKeyList] );
    }
    return 
PLUGIN_HANDLED;

You do not need to check both gKeyList[ i ][ 0 ] AND !( gIgnoreWeapons & ( 1 << i ) ) since they are the same thing. The only exception is if you wanted to hard-code an actual weapon on the ignore list. Currently you use this to only skip over the blank keys. Checking gKeyList[ i ][ 0 ] is enough.

Quote:
Originally Posted by Craxor View Post
About the problem , i cannot check with GWI_Notfound return if no index founded, Gwi duplicate return if chars from the contrained string are founded , but i want to avoid that, i want to force admin put the whole key... so i'm confuse, however, the whole code:
Now that the code has been fixed to handle if no match is found or a dupe was found, you can allow partial weapon keyword usage, which I think is more user friendly. If someone is careless enough to try to block say hegrenade by using 'grenade' and it picks the wrong one, that is their fault. As long as they specify enough of the name ('m4a','smoke','heg',ak', etc), it will work perfectly.

Here is a fixed remkey() function (untested) and the FindWeaponIndex() function, with comments.
PHP Code:
public remkeyidlevelcid 

    if( !
cmd_accessidlevelcid) ) 
        return 
PLUGIN_HANDLED
    
    new 
szWeaponArg13 ] , szModelFile12 sizeofgModelFile ) ] , iFoundIndex iEntity

    
read_argvszWeaponArg charsmaxszWeaponArg ) );
    
    
//Do not do your formatting here. You do not want to attempt to format the weapon based on what the user
    //typed. You want to use that to find the full weapon name in the list. Once that is found, do your formatex() 
    //with the full weapon name from the list.
    //formatex( szModelFile , charsmax( szModelFile ) , gModelFile , szWeaponArg ); 

    
iFoundIndex GetWeaponIndexszWeaponArg );
    
    
//You should use a switch here, same that is done in the add function.
    /*if( iFoundIndex == GWI_NotFound )
    {
        client_print( id, print_console, "This weapon '%s' is not saved yet or not exist, type amx_cspum_blockedlist to see all the keys blocked!", szWeaponArg );
        return PLUGIN_HANDLED;

    } */

    
switch ( iFoundIndex )
    {
        case 
GWI_NotFound:
        {
            
client_printid print_console"Unable to find the key '%s', type amx_cspum_keylist for all keys available to insert." szWeaponArg ); 
            return 
PLUGIN_HANDLED
        }
        case 
GWI_Duplicate:
        {    
            
client_printid print_console"Duplicate weapons were found. Please be more specific with the weapon you want to add." szWeaponArg ); 
            return 
PLUGIN_HANDLED
        }
        default:
        {
            
//Instead of checking if it already exists as is done in the add command, check if it 
            //does NOT exist so you can tell the user its not in the list therefore cannot be removed..
            
if ( !( gBlockWeapons & ( << iFoundIndex ) ) )
            {
                
client_printid print_console "'%s' is not currently in the pick up manager list." gKeyListiFoundIndex ] ); 
                return 
PLUGIN_HANDLED
            }
        }
    }

    if ( 
BlockType:get_pcvar_numgiTypeCvar ) == BT_Remove )
    {
        
//Restore all armoury_entity's of this weapon type that have a 0 count.
        
while ( ( iEntity find_ent_by_classiEntity "armoury_entity" ) ) )
        {
            if ( ( 
g_ArmouryTypesArmouryEntities:get_pdata_intiEntity m_iType XoCArmoury ) ][ WeaponIndex ] == iFoundIndex ) && ( get_pdata_intiEntity m_iCount XoCArmoury ) == ) )
            {
                
set_pdata_intiEntity m_iCount XoCArmoury );
                
set_peviEntity pev_effects , ( peviEntity pev_effects ) & ~EF_NODRAW ) );
                
set_peviEntity pev_solid SOLID_TRIGGER );
            }
        }
    }
    
    
gBlockWeapons &= ~( << iFoundIndex ); 
    
    
//Replace szWeaponArg with the full weapon name from the keylist since we have the weapon index that the user specified.
    
formatexszModelFile charsmaxszModelFile ) , gModelFile gKeyListiFoundIndex /*szWeaponArg*/ ); 
    
nvault_removegNewVault szModelFile ); 

    
//Replace szWeaponArg with the full weapon name (same as above)
    
client_printid print_console"You succesfully removed '%s' from the list!"gKeyListiFoundIndex /*szWeaponArg*/ );

    return 
PLUGIN_HANDLED


GetWeaponIndex( const szKeyword[] )
{
    
//Start iFound value at GWI_NotFound. This way it returns this if nothing is found in the key list.
    
new iFound GWI_NotFound;
    
    
//Loop through the full key list (starting at 1 since 0 is empty)
    
for ( new iWeapon iWeapon sizeofgKeyList ) ; iWeapon++ )
    {
        
//Check if keyword is containted in current weapon name
        
if ( containigKeyListiWeapon ] , szKeyword ) > -)
        {
            
//Match found but this is not the first time a match was found since the iFound value was changed
            //from GWI_NotFound already. This means it is a duplicate, return as duplicate.
            
if ( iFound GWI_NotFound )
            {
                
iFound GWI_Duplicate;
                break;
            }
            else
            {
                
//Match found and htis is the first time since iFound = GWI_NotFound, set to weapon index.
                
iFound iWeapon;
            }
        }
    }
    
    return 
iFound;

__________________

Last edited by Bugsy; 12-10-2016 at 11:36.
Bugsy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-10-2016 , 11:50   Re: help with CSPUM.
Reply With Quote #30

JUST PERFECT.

Now i add also the kevlar to block it, thanks you so much bugsy! <3
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
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 16:23.


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