Raised This Month: $ Target: $400
 0% 

Weapon Menu API


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
QuickDroLLL
Senior Member
Join Date: Dec 2021
Location: AMX Mod X Land
Old 08-17-2022 , 17:39   Re: Weapon Menu API
Reply With Quote #1

nice one !

i have realy cool idea like adding native thats add limit per player its will be cool and more advanced

Last edited by QuickDroLLL; 08-17-2022 at 17:43.
QuickDroLLL is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 08-22-2022 , 12:38   Re: Weapon Menu API
Reply With Quote #2

Quote:
Originally Posted by QuickDroLLL View Post
nice one !

i have realy cool idea like adding native thats add limit per player its will be cool and more advanced
You can do something like this:
PHP Code:
#include <amxmodx>
#include <weapon>

const MAX_WEAPON_LENGTH 64;

new 
g_iWeaponLimitMAX_WEAPON_LENGTH ];
new 
g_iPlayerLimitMAX_PLAYERS ][ MAX_WEAPON_LENGTH ];

public 
plugin_init( )
{
    
register_plugin"Weapons Api: Limit""1.0""Supremache"  )
}

public 
weapon_select_preid iWeaponID )
{
    new 
iWpnLimit g_iWeaponLimitiWeaponID ];
    
    if( 
iWpnLimit && g_iPlayerLimitid ][ iWeaponID ] >= iWpnLimit )
    {
        
add_weapon_text"\r(%d/%d)"g_iPlayerLimitid ][ iWeaponID ], iWpnLimit );
        return 
WEAPON_UNAVAILABLE;
    }
    
    return 
WEAPON_AVAILABLE;
}

public 
weapon_select_postid iWeaponID )
{
    
g_iPlayerLimitid ][ iWeaponID ]++;
}


public 
plugin_natives( )
{
    
register_native("set_wpn_limit""_set_wpn_limit" )
    
register_native("get_user_limit""_get_user_limit" )
    
register_native("get_wpn_limit""_get_wpn_limit" )
}

public 
_get_user_limitiPluginiParams )
{
    new 
id get_param), iWeaponID get_param);
    
    if( !
is_valid_weaponiWeaponID ) )
    {
        
log_errorAMX_ERR_NATIVE"Invalid weapon id (%d)"iWeaponID )
        return 
WEAPON_INVALID;
    }
    
    return 
g_iPlayerLimitid ][ iWeaponID ];
}


public 
_set_wpn_limitiPluginiParams )
{
    new 
iWeaponID get_param), iWeaponLimit get_param);
    
    if( !
is_valid_weaponiWeaponID ) )
    {
        
log_errorAMX_ERR_NATIVE"Invalid weapon id (%d)"iWeaponID )
        return 
WEAPON_INVALID;
    }
    
    if( !
iWeaponLimit )
    {
        
log_error(AMX_ERR_NATIVE"Invalid Limit (%d)"iWeaponLimit )
        return 
0;
    }
    
    
g_iWeaponLimitiWeaponID ] = iWeaponLimit;
    
    return 
1;
}



public 
_get_wpn_limitiPluginiParams )
{
    new 
iWeaponID get_param);
    
    if( !
is_valid_weaponiWeaponID ) )
    {
        
log_errorAMX_ERR_NATIVE"Invalid weapon id (%d)"iWeaponID )
        return 
WEAPON_INVALID;
    }
    
    return 
g_iWeaponLimitiWeaponID ];

@Natsheh, Replaced, thanks.
__________________
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; 09-10-2022 at 02:50.
Supremache 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 06:29.


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