This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Function to Forbid Primary Weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mlk27
Veteran Member
Join Date: May 2008
Old 02-13-2009 , 22:54   Function to Forbid Primary Weapons
Reply With Quote #1

can anyone write me a *function* to strip and drop any primary weapons when they are used and block them from being picked up from ground..

Last edited by Mlk27; 02-15-2009 at 23:15. Reason: better explanation
Mlk27 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-13-2009 , 23:06   Re: Forbid Primary Weapons
Reply With Quote #2

Quote:
Originally Posted by Mlk27 View Post
can anyone write me a function to strip and drop any primary weapons on weapon pickup and FM_Touch?
See this link, hlev's method works great for not picking up weapons. You will need to figure out on your own a way to specify which weapons get ignored. If you can't figure it out send me a PM and I will help you.

http://forums.alliedmods.net/showthread.php?t=78113
__________________

Last edited by Bugsy; 02-13-2009 at 23:22.
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-14-2009 , 02:31   Re: Forbid Primary Weapons
Reply With Quote #3

Would be more efficient to use hamsandwich.

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

#define PLUGIN "Don't PickUp Primaries"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"

#define    m_rgpPlayerItems_Slot1    35

new g_iMaxPlayers

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
RegisterHam(Ham_Touch"weaponbox""WeaponBox_Touch")

    
g_iMaxPlayers get_maxplayers()
}

public 
WeaponBox_Touch(iEntid)
{
    if( 
id || id g_iMaxPlayers || !(pev(iEntpev_flags) & FL_ONGROUND) || !is_user_alive(id) )
    {
        return 
HAM_IGNORED
    
}

    static 
iWeapon
    iWeapon 
get_pdata_cbase(iEntm_rgpPlayerItems_Slot14)
    if( 
pev_valid(iWeapon) )
    {
        return 
HAM_SUPERCEDE
    
}

    return 
HAM_IGNORED

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Mlk27
Veteran Member
Join Date: May 2008
Old 02-14-2009 , 03:15   Re: Forbid Primary Weapons
Reply With Quote #4

connor thanks man but that seems to ony block weapon picked up but it doesnt drop or strip bought primary weapons
Mlk27 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-14-2009 , 03:58   Re: Forbid Primary Weapons
Reply With Quote #5

You haven't ask this clearly.
Needs more code, will do it later if nobody else has tried something, and if i can do it


-edit-
Seems that restrict plugin in default amxx package would be the best.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 02-14-2009 at 06:19.
ConnorMcLeod is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-14-2009 , 13:16   Re: Function to Forbid Primary Weapons
Reply With Quote #6

Here is working code; I originally had it coded it with FM_Touch but used ConnorMcLeods Ham forward instead for efficiency. The Ham_AddPlayerItem code is by danielkza. I'm sure there is an optimization that can be done.

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

#define PLUGIN "No Primary Weapons"
#define AUTHOR "bugsy\ConnorMcLeod\danielkza"
#define VERSION "0.1"

#define    m_rgpPlayerItems_Slot1    35

new g_iMaxPlayers;

new const 
g_PrimaryWeapons[33][] = 
{
    
"",
    
"",
    
"",
    
"weapon_scout",   
    
"",
    
"weapon_xm1014",
    
"",
    
"weapon_mac10",
    
"weapon_aug",
    
"",
    
"",
    
"",
    
"weapon_ump45",
    
"weapon_sg550",
    
"weapon_galil",
    
"weapon_famas",
    
"",
    
"",
    
"weapon_awp",
    
"weapon_mp5navy",
    
"weapon_m249",
    
"weapon_m3",
    
"weapon_m4a1",
    
"weapon_tmp",
    
"weapon_g3sg1",
    
"",
    
"",
    
"weapon_sg552",
    
"weapon_ak47",
    
"",
    
"weapon_p90",
    
"",
    
""
};

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
                               
    
RegisterHam(Ham_Touch"weaponbox""fw_Touch");
    
RegisterHam(Ham_AddPlayerItem,"player""fw_AddPlayerItem");

    
g_iMaxPlayers get_maxplayers();
}

public 
fw_AddPlayerItem(player,item)
{
    static 
szClassname[32];
    
    
pev(item,pev_classname,szClassname,charsmax(szClassname));
    
    if( 
IsPrimaryszClassname ) )
    {
        
//Use HAM_SUPERCEDE to make the weapon never get picked up and get removed from map when purchased
        
return HAM_SUPERCEDE;
        
        
//Use the below to let the player pickup the weapon but get instantly dropped. The weapon will remain
        //available for players to pickup. Must comment return HAM_SUPERCEDE above if using this method.
        //client_cmd(player , "drop %s" , szClassname);
    
}
    
    return 
HAM_IGNORED;
}


public 
fw_Touch(iEntid)
{
    if( !(
id g_iMaxPlayers) || !(pev(iEntpev_flags) & FL_ONGROUND) || !is_user_alive(id) )
        return 
HAM_IGNORED;
    
    static 
iWeapon;
    
iWeapon get_pdata_cbase(iEntm_rgpPlayerItems_Slot14);
    
    if( 
pev_valid(iWeapon) )
        return 
HAM_SUPERCEDE;
    
    return 
HAM_IGNORED;
}  

IsPrimary(szWeapon[])
{
    static 
i;
    for( 
33i++ )
        if( 
equalszWeapon g_PrimaryWeapons[i]) )
            return 
i;
    
    return 
0;

__________________

Last edited by Bugsy; 02-14-2009 at 13:32.
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-14-2009 , 13:53   Re: Function to Forbid Primary Weapons
Reply With Quote #7

With this method, player's money is still taken.
And you don't need to hook Touch.

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

#define PLUGIN "no primaries"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
RegisterHam(Ham_AddPlayerItem"player""Player_AddPlayerItem")
}

public 
Player_AddPlayerItem(idiWeapon)
{
    if( 
ExecuteHam(Ham_Item_ItemSlotiWeapon) == )
    {
        
SetHamReturnInteger(0)
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Mlk27
Veteran Member
Join Date: May 2008
Old 02-15-2009 , 20:02   Re: Function to Forbid Primary Weapons
Reply With Quote #8

@bugsy

thanks..i uncommented the line to drop weapon instead cause with 'return HAM_SUPERCEDE' make players pick weapons and that leave no weapons on ground..

your code works but its not like i want..when i tested it, i still got to picked up weapons on ground at first then they got dropped..when i tried to pick the dropped weapons again, the code blocked it..ummm thats great but i don't understand why weapons are initially still pickup able when ham_touch already take care of that?

can you make it so the weapons lying on ground ara not pickupable at all..and if players buy or are given with primary weapons, drop those weapons and block them from being picked up..

Last edited by Mlk27; 02-15-2009 at 20:04.
Mlk27 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-15-2009 , 20:33   Re: Function to Forbid Primary Weapons
Reply With Quote #9

Quote:
Originally Posted by Mlk27 View Post
@bugsy

thanks..i uncommented the line to drop weapon instead cause with 'return HAM_SUPERCEDE' make players pick weapons and that leave no weapons on ground..

your code works but its not like i want..when i tested it, i still got to picked up weapons on ground at first then they got dropped..when i tried to pick the dropped weapons again, the code blocked it..ummm thats great but i don't understand why weapons are initially still pickup able when ham_touch already take care of that?

can you make it so the weapons lying on ground ara not pickupable at all..and if players buy or are given with primary weapons, drop those weapons and block them from being picked up..
My code should drop the weapon when purchased and then not be picked up if you walk over the weapon. Did you comment out HAM_SUPERCEDE?
__________________
Bugsy is offline
Mlk27
Veteran Member
Join Date: May 2008
Old 02-15-2009 , 20:57   Re: Function to Forbid Primary Weapons
Reply With Quote #10

yeh. i commented out ham_supercede because i dont want weapons to be taken away from ground when players step on those weapons.

Just completely block weapons on ground from being pick up and drop weapons when players buy them

Last edited by Mlk27; 02-15-2009 at 21:00.
Mlk27 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 15:45.


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