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

Stock for drop weapon. Need help >"<


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
5c0r-|3i0
Veteran Member
Join Date: Nov 2008
Location: Việt Nam
Old 05-01-2009 , 21:07   Stock for drop weapon. Need help >"<
Reply With Quote #1

I'm tryin' to make a stock that drops players' weapons and keep backpack ammo in that. But seems it's now a little complicated . I need a stock that
1) Drop primary weapon .
2) Drop secondary weapon .
3) Drop both .
Thanks in advance .
5c0r-|3i0 is offline
padilha007
Senior Member
Join Date: Jul 2008
Old 05-01-2009 , 21:16   Re: Stock for drop weapon. Need help >"<
Reply With Quote #2

This help you?

PHP Code:
new const m_rgpPlayerItems_plr[] = {268269};

268 primary weapon
269 
secondary weapon
270 
knife
271 
FlashHeSmoke
272 
C4 

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

new const m_rgpPlayerItems_plr[] = {268269};

public 
plugin_init()
{
    
// Your code
}

public 
stripweapon(id)
    
ham_strip_weapon(id)

stock ham_strip_weapon(id)
{
    for(new 
ii<sizeof(m_rgpPlayerItems_plr); i++)
    {
        new 
iWeapon;
        
iWeapon get_pdata_cbase(idm_rgpPlayerItems_plr[i], 5);
        while( 
pev_validiWeapon ) )
        {
            new 
szWeapon[20];
            
pev(iWeaponpev_classnameszWeaponcharsmax(szWeapon));
        
            new 
wId get_weaponid(szWeapon);
            if(!
wId) return 0;

            new 
wEnt;
            while((
wEnt engfunc(EngFunc_FindEntityByString,wEnt,"classname",szWeapon)) && pev(wEnt,pev_owner) != id) {}
            if(!
wEnt) return 0;

            if(
get_user_weapon(id) == wIdExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);

            if(!
ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
            
ExecuteHamB(Ham_Item_Kill,wEnt);

            
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
        }
    }

    return 
1;

__________________

padilha007 is offline
5c0r-|3i0
Veteran Member
Join Date: Nov 2008
Location: Việt Nam
Old 05-01-2009 , 21:29   Re: Stock for drop weapon. Need help >"<
Reply With Quote #3

I think I need a stock that makes players drop weapons and leave it on the ground . Your code just remove weapons from players , right ??
But thanks a lot ^^!. Already +k !
5c0r-|3i0 is offline
padilha007
Senior Member
Join Date: Jul 2008
Old 05-01-2009 , 22:38   Re: Stock for drop weapon. Need help >"<
Reply With Quote #4

sorry man =x ( From zp )

PHP Code:
// CS Offsets
#if cellbits == 32
const OFFSET_CSTEAMS 114
const OFFSET_CSMONEY 115
const OFFSET_NVGOGGLES 129
const OFFSET_ZOOMTYPE 363
const OFFSET_CSDEATHS 444
const OFFSET_AWM_AMMO  377 
const OFFSET_SCOUT_AMMO 378
const OFFSET_PARA_AMMO 379
const OFFSET_FAMAS_AMMO 380
const OFFSET_M3_AMMO 381
const OFFSET_USP_AMMO 382
const OFFSET_FIVESEVEN_AMMO 383
const OFFSET_DEAGLE_AMMO 384
const OFFSET_P228_AMMO 385
const OFFSET_GLOCK_AMMO 386
const OFFSET_FLASH_AMMO 387
const OFFSET_HE_AMMO 388
const OFFSET_SMOKE_AMMO 389
const OFFSET_C4_AMMO 390
const OFFSET_CLIPAMMO 51
#else
const OFFSET_CSTEAMS 139
const OFFSET_CSMONEY 140
const OFFSET_NVGOGGLES 155
const OFFSET_ZOOMTYPE 402
const OFFSET_CSDEATHS 493
const OFFSET_AWM_AMMO  426
const OFFSET_SCOUT_AMMO 427
const OFFSET_PARA_AMMO 428
const OFFSET_FAMAS_AMMO 429
const OFFSET_M3_AMMO 430
const OFFSET_USP_AMMO 431
const OFFSET_FIVESEVEN_AMMO 432
const OFFSET_DEAGLE_AMMO 433
const OFFSET_P228_AMMO 434
const OFFSET_GLOCK_AMMO 435
const OFFSET_FLASH_AMMO 46
const OFFSET_HE_AMMO 437
const OFFSET_SMOKE_AMMO 438
const OFFSET_C4_AMMO 439
const OFFSET_CLIPAMMO 65
#endif

// Weapon bitsums
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
const 
SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)

const 
OFFSET_LINUX // offsets 5 higher in Linux builds

public plugin_init()
{
    
// Your code
}

// Drop primary/secondary weapons
stock drop_weapons(iddropwhat)
{
    
// Get user weapons
    
static weapons[32], numiweaponid
    num 
// reset passed weapons count (bugfix)
    
get_user_weapons(idweaponsnum)
    
    
// Loop through them and drop primaries or secondaries
    
for (0numi++)
    {
        
// Prevent re-indexing the array
        
weaponid weapons[i]
        
        if ((
dropwhat == && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
        {
            
// Get the weapon entity
            
static wname[32], weapon_ent
            get_weaponname
(weaponidwnamesizeof wname 1)
            
weapon_ent fm_find_ent_by_owner(-1wnameid);
            
            
// Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
            
set_pev(weapon_entPEV_ADDITIONAL_AMMOfm_get_user_bpammo(idweaponid))
            
            
// Player drops the weapon and looses his bpammo
            
engclient_cmd(id"drop"wname)
            
fm_set_user_bpammo(idweaponid0)
        }
    }
}

// Find entity by its owner (from fakemeta_util)
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) {}
    
    return 
entity;
}

// Set User BP Ammo
stock fm_set_user_bpammo(idweaponamount)
{
    static 
offset
    
    
switch(weapon)
    {
        case 
CSW_AWPoffset OFFSET_AWM_AMMO;
        case 
CSW_SCOUT,CSW_AK47,CSW_G3SG1offset OFFSET_SCOUT_AMMO;
        case 
CSW_M249offset OFFSET_PARA_AMMO;
        case 
CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552offset OFFSET_FAMAS_AMMO;
        case 
CSW_M3,CSW_XM1014offset OFFSET_M3_AMMO;
        case 
CSW_USP,CSW_UMP45,CSW_MAC10offset OFFSET_USP_AMMO;
        case 
CSW_FIVESEVEN,CSW_P90offset OFFSET_FIVESEVEN_AMMO;
        case 
CSW_DEAGLEoffset OFFSET_DEAGLE_AMMO;
        case 
CSW_P228offset OFFSET_P228_AMMO;
        case 
CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITEoffset OFFSET_GLOCK_AMMO;
        case 
CSW_FLASHBANGoffset OFFSET_FLASH_AMMO;
        case 
CSW_HEGRENADEoffset OFFSET_HE_AMMO;
        case 
CSW_SMOKEGRENADEoffset OFFSET_SMOKE_AMMO;
        case 
CSW_C4offset OFFSET_C4_AMMO;
        default: return;
    }
    
    
set_pdata_int(idoffsetamountOFFSET_LINUX)

PHP Code:
drop_weapons(id1) - primary weapon
drop_weapons
(id2) - secondary weapon

drop_weapons
(id1); drop_weapons(id2) - drop both 
__________________

padilha007 is offline
5c0r-|3i0
Veteran Member
Join Date: Nov 2008
Location: Việt Nam
Old 05-01-2009 , 22:48   Re: Stock for drop weapon. Need help >"<
Reply With Quote #5

WoW. Thanks a lot !!
5c0r-|3i0 is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 05-02-2009 , 13:27   Re: Stock for drop weapon. Need help >"<
Reply With Quote #6

you should use #defines instead of that many constants
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-02-2009 , 14:08   Re: Stock for drop weapon. Need help >"<
Reply With Quote #7

Quote:
Originally Posted by SchlumPF* View Post
you should use #defines instead of that many constants
Why?
__________________
xPaw is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-02-2009 , 14:12   Re: Stock for drop weapon. Need help >"<
Reply With Quote #8

Constants use up memory, whereas #defines are replaced with their value upon compilation.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Old 05-02-2009, 14:13
Dores
This message has been deleted by Dores.
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-02-2009 , 14:27   Re: Stock for drop weapon. Need help >"<
Reply With Quote #9

Don't use defines. It's fine with consts.
__________________
joaquimandrade is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 05-02-2009 , 14:51   Re: Stock for drop weapon. Need help >"<
Reply With Quote #10

C'mon, make up your minds guys! I need to know which to use..
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores 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 01:55.


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