AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_Touch,can pick up only:m3,elite and other. (https://forums.alliedmods.net/showthread.php?t=82331)

xbatista 12-21-2008 11:22

Ham_Touch,can pick up only:m3,elite and other.
 
This is noweapon pickup from the ground and dropped weapons code.
How to do,player can pick up example: only m3,elite,m4a1,mac10.???Other weapons can not be picked up :mrgreen:




PHP Code:

 new amx_noweaponpickup 

PHP Code:

plugin init
                amx_noweaponpickup 
register_cvar("amx_noweaponpickup""1")
                
RegisterHam(Ham_Touch"weaponbox""hamTouch")
                
RegisterHam(Ham_Touch"armoury_entity""hamTouch")
                
RegisterHam(Ham_Touch"weapon_shield""hamTouch")
                
RegisterHam(Ham_Touch"grenade""hamTouch"

PHP Code:

public hamTouch(entid)
{
        if (!
get_pcvar_num(amx_noweaponpickup) || !is_user_connected(id) || !is_user_alive(id))
                return 
HAM_IGNORED
 
        
return HAM_SUPERCEDE



hleV 12-21-2008 11:36

Re: Ham_Touch,can pick up only:m3,elite and other.
 
I would suggest fakemeta.
Code:
#include <fakemeta>   public plugin_init()         register_forward(FM_Touch, "fwdTouch");   public fwdTouch(ent, id) {         if (!is_user_alive(id) || !pev_valid(ent))                 return FMRES_IGNORED;           new szMdl[32];         pev(ent, pev_model, szMdl, 31);           if (!equali(szMdl, "models/w_m3.mdl") &&         !equali(szMdl, "models/w_elite.mdl") &&         !equali(szMdl, "models/w_m4a1.mdl") &&         !equali(szMdl, "models/w_mac10.mdl"))                 return FMRES_SUPERCEDE;           return FMRES_IGNORED; }

xbatista 12-21-2008 11:42

Re: Ham_Touch,can pick up only:m3,elite and other.
 
OK !!! Going to test.

xbatista 12-21-2008 11:49

Re: Ham_Touch,can pick up only:m3,elite and other.
 
Tested.
Don't work.Picks up and other weapons :/

SchlumPF* 12-21-2008 12:28

Re: Ham_Touch,can pick up only:m3,elite and other.
 
hleV your way did not block the ent touching the plr, only the plr touching the ent + you superceded the plr tocuhing everything except the weapons you listed
im sure there is a better way with hamsandwich but i would need to test it :/ anyway im sure that this works

Code:
PHP Code:

#include <amxmodx>
#include <fakemeta>

new g_AllowedWeapons[][] =
{
    
"weapon_mac10",
    
"weapon_elite",
    
"weapon_m3",
    
"weapon_m4a1"
}

new 
g_iMaxPlayers;

public 
plugin_init( )
{
    
register_forwardFM_Touch"fwdTouch" );
    
g_iMaxPlayers get_maxplayers( );
}

// the plr can touch the ent AND the ent can touch the player so we need to supercede both
public fwdTouchtouchedtoucher )
{
    static 
plrent;
    
    
// find out whether the toucher or touched is the plr
    
if( toucher <= g_iMaxPlayers )
        
plr toucher;
    else if( 
touched <= g_iMaxPlayers )
        
plr touched;
    else 
// an ent touched an ent, no plr is involved
        
return FMRES_IGNORED;
        
    static 
classname[32];
    
peventpev_classnameclassname31 );
    
    
// check the ent for it's classname
    
if( equalclassname"weapon_") )
    {
        for(new 
i;sizeof(g_AllowedWeapons);i++)
        {
            if( 
equalclassname[7], g_AllowedWeapons[i][7] ) )
            {
                return 
FMRES_IGNORED;
            }

            return 
FMRES_SUPERCEDE;
        }
    }






Code:

ID  NAME                  SPEED  CLIP  AMMO  AID  ANAME            COST  ACOST  BUYNAME  BUYNAME2 
 1  weapon_p228            250    13    52    9  ammo_357sig        600      50  p228      228compact
    weapon_shield            0      0      0    0                    2200      0  shield             
 3  weapon_scout            260    10    90    2  ammo_762nato      2750      80  scout               
 4  weapon_hegrenade        250            1    12                      300      0  hegren             
 5  weapon_xm1014          240      7    32    5  ammo_buckshot    3000      65  xm1014    autoshotgun
 6  weapon_c4              250      0      1    14                        0      0                       
 7  weapon_mac10            250    30    100    6  ammo_45acp        1400      25  mac10               
 8  weapon_aug              240    30    90    4  ammo_556nato      3500      60  aug      bullpup   
 9  weapon_smokegrenade    250            1    13                      300      0  sgren               
10  weapon_elite            250    30    120    10  ammo_9mm          800      20  elites             
11  weapon_fiveseven        250    20    100    7  ammo_57mm          750      50  fn57      fiveseven 
12  weapon_ump45            250    25    100    6  ammo_45acp        1700      25  ump45               
13  weapon_sg550            210    30    90    4  ammo_556nato      4200      60  sg550    krieg550 
14  weapon_galil            240    35    90    4  ammo_556nato      2000      60  galil    defender 
15  weapon_famas            240    25    90    4  ammo_556nato      2250      60  famas    clarion   
16  weapon_usp              250    12    100    6  ammo_45acp        500      25  usp      km45     
17  weapon_glock18          250    20    120    10  ammo_9mm          400      20  glock    9x19mm   
18  weapon_awp              210    10    30    1  ammo_338magnum    4750    125  awp      magnum   
19  weapon_mp5navy          250    30    120    10  ammo_9mm          1500      20  mp5      smg       
20  weapon_m249            220    100    200    3  ammo_556natobox  5750      60  m249               
21  weapon_m3              230      8    32    5  ammo_buckshot    1700      65  m3        12gauge   
22  weapon_m4a1            230    30    90    4  ammo_556nato      3100      60  m4a1               
23  weapon_tmp              250    30    120    10  ammo_9mm          1250      20  tmp      mp       
24  weapon_g3sg1            210    20    90    2  ammo_762nato      5000      80  g3sg1    d3au1     
25  weapon_flashbang        250            2    11                      200      0  flash               
26  weapon_deagle          250      7    35    8  ammo_50ae          650      40  deagle    nighthawk 
27  weapon_sg552            235    30    90    4  ammo_556nato      3500      60  sg552    krieg552 
28  weapon_ak47            221    30    90    2  ammo_762nato      2500      80  ak47      cv47     
29  weapon_knife            250      0      0    0                        0      0                       
30  weapon_p90              245    50    100    7  ammo_57mm        2350      50  p90      c90


xbatista 12-21-2008 12:36

Re: Ham_Touch,can pick up only:m3,elite and other.
 
Going to test :wink:
And I know the weapon info :)
http://wiki.alliedmods.net/CS_Weapons_Information

xbatista 12-21-2008 12:42

Re: Ham_Touch,can pick up only:m3,elite and other.
 
Compiles bad...fwd_touch should return a value and a value that is never used: "plr"

SchlumPF* 12-21-2008 13:18

Re: Ham_Touch,can pick up only:m3,elite and other.
 
Quote:

Originally Posted by xbatista (Post 730908)
Compiles bad...fwd_touch should return a value and a value that is never used: "plr"

sry made a couple of mistakes cuz i had to hurry :/ this should work now

PHP Code:

#include <amxmodx>
#include <fakemeta>

new g_AllowedWeapons[][] =
{
    
"weapon_mac10",
    
"weapon_elite",
    
"weapon_m3",
    
"weapon_m4a1"
}

new 
g_iMaxPlayers;

public 
plugin_init( )
{
    
register_forwardFM_Touch"fwdTouch" );
    
g_iMaxPlayers get_maxplayers( );
}

// the plr can touch the ent AND the ent can touch the player so we need to supercede both
public fwdTouchtouchedtoucher )
{
    static 
ent;

    
// find out whether the toucher or touched is the plr
    
if( toucher <= g_iMaxPlayers )
        
ent touched;
    else if( 
touched <= g_iMaxPlayers )
        
ent toucher;
    else 
// an ent touched an ent, no plr is involved
        
return FMRES_IGNORED;
    
    static 
classname[32];
    
peventpev_classnameclassname31 );
    
    
// check the ent for it's classname
    
if( equalclassname"weapon_") )
    {
        for(new 
i;sizeof(g_AllowedWeapons);i++)
        {
            if( 
equalclassname[7], g_AllowedWeapons[i][7] ) )
            {
                return 
FMRES_IGNORED;
            }
            
            return 
FMRES_SUPERCEDE;
        }
    }
    
    return 
FMRES_IGNORED;



xbatista 12-21-2008 13:19

Re: Ham_Touch,can pick up only:m3,elite and other.
 
Going to test :mrgreen:

xbatista 12-21-2008 13:22

Re: Ham_Touch,can pick up only:m3,elite and other.
 
Tested: ZOMG :(( Still picks up other weapons :(


All times are GMT -4. The time now is 09:06.

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