Raised This Month: $ Target: $400
 0% 

Solved [Help] Drop weapon if user is under level 10


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 05-11-2020 , 19:15   Re: [Help] Drop weapon if user is under level 10
Reply With Quote #1

Quote:
Originally Posted by Bugsy View Post
I agree with thEsp, instead of picking up and dropping, just block the pickup, it is super easy. This would apply to weaponbox and armoury_entity.

This is a very rough example that will block picking up weapons, you can add more logic/conditions to it. E.g. only if the weapon is on the ground, type of weapon, only particular players, only in certain scenarios, etc.
PHP Code:
#include <amxmodx>
#include <engine>

public plugin_init() 
{
    
register_touch"weaponbox" "player" "PlayerTouchWeaponbox" );
}

public 
PlayerTouchWeaponboxiEntity iPlayer )
{
    return 
PLUGIN_HANDLED;

Hm, can you give me 1 example ? the native is get_user_level(id)
elmedin is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-11-2020 , 19:23   Re: [Help] Drop weapon if user is under level 10
Reply With Quote #2

Do you have an array that stores weapon levels?
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-11-2020 , 20:05   Re: [Help] Drop weapon if user is under level 10
Reply With Quote #3

Here's the framework, you just need to fill in the weapon level function, and delete my get_user_level() since you have your own. I have the get user level and get weapon level returning dummy values for testing purposes.

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <engine>

new const Version[] = "0.1";

#define MAX_PLAYERS 32

#define XO_CWEAPONBOX 4

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

enum WeaponInfo
{
    
WeaponBoxIndex,
    
ReturnType
}

new 
g_iLastTouchedMAX_PLAYERS ][ WeaponInfo ];

public 
plugin_init() 
{
    
register_plugin"Weapon Pickup Level" Version "0.1" );
    
    
register_touch"weaponbox" "player" "PlayerTouchWeaponbox" );
}

public 
PlayerTouchWeaponboxiEntity iPlayer )
{    
    if ( 
g_iLastTouchediPlayer ][ WeaponBoxIndex ] == iEntity )
    {
        return 
g_iLastTouchediPlayer ][ ReturnType ];
    }
    else
    {
        
g_iLastTouchediPlayer ][ WeaponBoxIndex ] = iEntity;
        return ( 
g_iLastTouchediPlayer ][ ReturnType ] = ( ( get_user_leveliPlayer ) < get_weapon_levelcs_get_weaponbox_typeiEntity ) ) ) ? PLUGIN_HANDLED PLUGIN_CONTINUE ) );
    }


public 
get_user_levelid )
{
    return 
7;
}

public 
get_weapon_leveliCSWeaponIndex )
{
    
//iCSWeaponIndex holds CSW_ weapon index.

    
return 6;
}

cs_get_weaponbox_typeiWeaponBox )
{
    new 
iWeaponEntity iWeaponID;
    
    for ( new 
<= i++ )
    {
        if ( ( 
iWeaponEntity get_pdata_cbaseiWeaponBox m_rgpPlayerItems_CWeaponBox] , XO_CWEAPONBOX ) ) > )
        {
            
iWeaponID cs_get_weapon_idiWeaponEntity );
            break;
        }
    }
    
    return 
iWeaponID;

__________________
Bugsy is offline
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 05-11-2020 , 20:50   Re: [Help] Drop weapon if user is under level 10
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
Here's the framework, you just need to fill in the weapon level function, and delete my get_user_level() since you have your own. I have the get user level and get weapon level returning dummy values for testing purposes.

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <engine>

new const Version[] = "0.1";

#define MAX_PLAYERS 32

#define XO_CWEAPONBOX 4

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

enum WeaponInfo
{
    
WeaponBoxIndex,
    
ReturnType
}

new 
g_iLastTouchedMAX_PLAYERS ][ WeaponInfo ];

public 
plugin_init() 
{
    
register_plugin"Weapon Pickup Level" Version "0.1" );
    
    
register_touch"weaponbox" "player" "PlayerTouchWeaponbox" );
}

public 
PlayerTouchWeaponboxiEntity iPlayer )
{    
    if ( 
g_iLastTouchediPlayer ][ WeaponBoxIndex ] == iEntity )
    {
        return 
g_iLastTouchediPlayer ][ ReturnType ];
    }
    else
    {
        
g_iLastTouchediPlayer ][ WeaponBoxIndex ] = iEntity;
        return ( 
g_iLastTouchediPlayer ][ ReturnType ] = ( ( get_user_leveliPlayer ) < get_weapon_levelcs_get_weaponbox_typeiEntity ) ) ) ? PLUGIN_HANDLED PLUGIN_CONTINUE ) );
    }


public 
get_user_levelid )
{
    return 
7;
}

public 
get_weapon_leveliCSWeaponIndex )
{
    
//iCSWeaponIndex holds CSW_ weapon index.

    
return 6;
}

cs_get_weaponbox_typeiWeaponBox )
{
    new 
iWeaponEntity iWeaponID;
    
    for ( new 
<= i++ )
    {
        if ( ( 
iWeaponEntity get_pdata_cbaseiWeaponBox m_rgpPlayerItems_CWeaponBox] , XO_CWEAPONBOX ) ) > )
        {
            
iWeaponID cs_get_weapon_idiWeaponEntity );
            break;
        }
    }
    
    return 
iWeaponID;

Thanks <3
elmedin is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 05-12-2020 , 17:40   Re: [Help] Drop weapon if user is under level 10
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Here's the framework, you just need to fill in the weapon level function, and delete my get_user_level() since you have your own. I have the get user level and get weapon level returning dummy values for testing purposes.

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <engine>

new const Version[] = "0.1";

#define MAX_PLAYERS 32

#define XO_CWEAPONBOX 4

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

enum WeaponInfo
{
    
WeaponBoxIndex,
    
ReturnType
}

new 
g_iLastTouchedMAX_PLAYERS ][ WeaponInfo ];

public 
plugin_init() 
{
    
register_plugin"Weapon Pickup Level" Version "0.1" );
    
    
register_touch"weaponbox" "player" "PlayerTouchWeaponbox" );
}

public 
PlayerTouchWeaponboxiEntity iPlayer )
{    
    if ( 
g_iLastTouchediPlayer ][ WeaponBoxIndex ] == iEntity )
    {
        return 
g_iLastTouchediPlayer ][ ReturnType ];
    }
    else
    {
        
g_iLastTouchediPlayer ][ WeaponBoxIndex ] = iEntity;
        return ( 
g_iLastTouchediPlayer ][ ReturnType ] = ( ( get_user_leveliPlayer ) < get_weapon_levelcs_get_weaponbox_typeiEntity ) ) ) ? PLUGIN_HANDLED PLUGIN_CONTINUE ) );
    }


public 
get_user_levelid )
{
    return 
7;
}

public 
get_weapon_leveliCSWeaponIndex )
{
    
//iCSWeaponIndex holds CSW_ weapon index.

    
return 6;
}

cs_get_weaponbox_typeiWeaponBox )
{
    new 
iWeaponEntity iWeaponID;
    
    for ( new 
<= i++ )
    {
        if ( ( 
iWeaponEntity get_pdata_cbaseiWeaponBox m_rgpPlayerItems_CWeaponBox] , XO_CWEAPONBOX ) ) > )
        {
            
iWeaponID cs_get_weapon_idiWeaponEntity );
            break;
        }
    }
    
    return 
iWeaponID;

I have a question, is it possible for example to create a specific API and then configure inside your code NATIVE and set it a certain level for PICK UP?
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
elmedin
Senior Member
Join Date: Nov 2013
Location: Bruh
Old 05-11-2020 , 21:08   Re: [Help] Drop weapon if user is under level 10
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
Do you have an array that stores weapon levels?
Yes, i do have the array that stores weapons in the weapon menu + levels which for me it was a pain in the ass cause im an amature


HTML Code:
if (zp_get_user_level(id) < ArrayGetCell(i_lvl , ItemId))
	{
		Show_MainEquipMenu(id)
		client_printc(id , "%L" , id , "ZX_NOT_AT_LVL")
		return ITEM_DISABLED
	} //this is the array that i use in the main weapon plugin

Last edited by elmedin; 05-11-2020 at 21:21.
elmedin 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 17:14.


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