Raised This Month: $ Target: $400
 0% 

Return csw_ weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 06-19-2017 , 14:57   Re: Return csw_ weapon
Reply With Quote #1

Oh shit, when I was posting that my internet crashed and how did it post? Sorry guys. I fixed it using cs_get_weapon_id().

To be more specific, I was trying to check if I have a primary/secondary weapon depending of which weapon I'm trying to pickup from the ground and drop it for pickup the dropped weapon.

I mean:

Prostotem@'s code:

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

const XO_CWEAPONBOX =                4
new const m_rgpPlayerItems_CWeaponBox[6] =    {34,35,...}

const 
PRIMARY_WEAPONS =                (<< CSW_AK47)|(<< CSW_AUG)|(<< CSW_GALIL)|(<< CSW_SCOUT) |(<< CSW_SG550)|(<< CSW_SG552)|(<< CSW_FAMAS)|(<< CSW_AWP)|(<< CSW_M4A1)|(<< CSW_G3SG1)|(<< CSW_M249)|(<< CSW_MP5NAVY)|(<< CSW_MAC10)|(<< CSW_P90)|(<< CSW_M3)|(<< CSW_XM1014)|(<< CSW_UMP45)|(<< CSW_TMP)
const 
SECONDARY_WEAPONS =            (<< CSW_DEAGLE)|(<< CSW_USP)|(<< CSW_GLOCK18)|(<< CSW_ELITE)|(<< CSW_FIVESEVEN)|(<< CSW_P228)

new 
g_hSync

public plugin_init() 
{
    
register_plugin("Thor Weapon Pickup""1.0""EFFx/ProSToTeM@")
    
    
register_forward(FM_CmdStart"CmdStart", ._post=true)
    
    
g_hSync CreateHudSyncObj()
}

public 
CmdStart(playeruserCmdHandlerandomSeed
{
    if(!
is_user_alive(player))
        return

    if(
get_uc(userCmdHandleUC_Buttons) & IN_USE
    
&& !(entity_get_int(playerEV_INT_oldbuttons) & IN_USE)) 
    {
        
OnUsePress(player)
    }
}

OnUsePress(player
{    
    
enum _:WboxInfo 
    
{
        
WboxInfo_Ent,
        
WboxInfo_Owner
    
}
    
    new Array:
wboxInfos ArrayCreate(WboxInfo)
    static 
wboxInfo[WboxInfo]
    for(new 
iWbox 0; (iWbox find_ent_by_class(iWbox"weaponbox")) != 0;) 
    {
        
wboxInfo[WboxInfo_Ent] = iWbox
        wboxInfo
[WboxInfo_Owner] = entity_get_edict(iWboxEV_ENT_owner)
        
ArrayPushArray(wboxInfoswboxInfo)
        
        
entity_set_int(iWboxEV_INT_solidSOLID_BBOX)
        
entity_set_edict(iWboxEV_ENT_owner0)
        
RelinkEntity(iWbox)
        
entity_set_vector(iWboxEV_VEC_sizeFloat:{1.00.00.0})
    }
    
    const 
iMaxDistance 76
    
static iHitEntiHitGroup
    get_user_aiming
(playeriHitEntiHitGroupiMaxDistance)
    
    new 
iHitWbox 0iWeaponID 0
    
if(iHitEnt != 0
    {
        
iWeaponID GetWeaponBoxWeaponType(iHitEnt)
        
        static 
szClassName[MAX_PLAYERS]
        
entity_get_string(iHitEntEV_SZ_classnameszClassNamecharsmax(szClassName))
        if(
equal(szClassName"weaponbox")) 
        {
            
iHitWbox iHitEnt
            
            
static szWeapon[MAX_PLAYERS], szOwnerName[MAX_PLAYERS], iRGB[3], szHudFormat[50]
            
get_weaponname(iWeaponIDszWeaponcharsmax(szWeapon))
            
get_user_name(wboxInfo[WboxInfo_Owner], szOwnerNamecharsmax(szOwnerName))
            
            
replace(szWeaponcharsmax(szWeapon), "weapon_""")
            
strtoupper(szWeapon)
            
            if(
is_user_connected(wboxInfo[WboxInfo_Owner]))
            {
                switch(
get_user_team(wboxInfo[WboxInfo_Owner]))
                {
                    case 
1:
                    {
                        
iRGB = {220300}
                    }
                    case 
2:
                    {
                        
iRGB = {0100200}
                    }
                    default:
                    {
                        
iRGB = {255255255}
                    }
                }
            }
            else
            {
                
iRGB = {255255255}
            }
            
            if(
player == wboxInfo[WboxInfo_Owner])
            {
                
formatex(szHudFormatcharsmax(szHudFormat), "%s"szWeapon)
            }
            else
            {
                
formatex(szHudFormatcharsmax(szHudFormat), "%s's %s"szOwnerNameszWeapon)
            }
            
            
set_hudmessage(iRGB[0], iRGB[1], iRGB[2], 0.700.8001.04.0)
            
ShowSyncHudMsg(playerg_hSync"You got %s"szHudFormat)
        }
    }
    
    new 
wboxCount ArraySize(wboxInfos)
    for(new 
0wboxCounti++) 
    {
        static 
wboxInfo[WboxInfo]
        
ArrayGetArray(wboxInfosiwboxInfo)
        new 
iWbox wboxInfo[WboxInfo_Ent]
        
        
entity_set_edict(iWboxEV_ENT_ownerwboxInfo[WboxInfo_Owner])
        
entity_set_int(iWboxEV_INT_solidSOLID_TRIGGER)
        
RelinkEntity(iWbox)
    }
    
ArrayDestroy(wboxInfos)
    
    if(
iHitWbox != 0
    {
        new 
iWeaponByte = (<< iWeaponID)
        if(
iWeaponByte & (PRIMARY_WEAPONS SECONDARY_WEAPONS))
        {
            new 
bool:bIsPrimary bool:(iWeaponByte PRIMARY_WEAPONS)
            if(
pev(playerpev_weapons) & (_:bIsPrimary) ? PRIMARY_WEAPONS SECONDARY_WEAPONS)
            {
                
dropWeapons(player, (bIsPrimary) ? 2)
            }
        }
        
        
ExecuteHamB(Ham_TouchiHitWboxplayer)
    }
}

RelinkEntity(ent
{
    static 
Float:origin[3]
    
entity_get_vector(entEV_VEC_originorigin)
    
entity_set_origin(entorigin)
}

GetWeaponBoxWeaponType(ent

    new 
weapon
    
for(new 1<= 5i++) 
    { 
        
weapon get_pdata_cbase(entm_rgpPlayerItems_CWeaponBox[i], XO_CWEAPONBOX)
        if(
weapon 0
        { 
            return 
cs_get_weapon_id(weapon)
        } 
    } 
    
    return 
0


dropWeapons(idiType)
{
    new 
iWeapons[MAX_PLAYERS], szWeaponName[MAX_PLAYERS], iWeaponiWeaponsCountiWeaponByte
    get_user_weapons
(idiWeaponsiWeaponsCount)

    for(new 
iiWeaponsCounti++)
    {
        if(!
iWeaponsCount)
            continue
            
        
iWeapon iWeapons[i]
        
iWeaponByte = (<< iWeapon)
        
        
get_weaponname(iWeaponszWeaponNamecharsmax(szWeaponName))
        switch(
iType)
        {
            case 
1:
            {
                if(
iWeaponByte PRIMARY_WEAPONS)
                {
                    
client_cmd(id"drop ^"%s^""szWeaponName)
                }
            }
            case 
2:
            {
                if(
iWeaponByte SECONDARY_WEAPONS)
                {
                    
client_cmd(id"drop ^"%s^""szWeaponName)
                }
            }
        }
    }

Here:

PHP Code:
    if(iHitWbox != 0
    {
        new 
iWeaponByte = (<< iWeaponID)
        if(
iWeaponByte & (PRIMARY_WEAPONS SECONDARY_WEAPONS))
        {
            new 
bool:bIsPrimary bool:(iWeaponByte PRIMARY_WEAPONS)
            if(
pev(playerpev_weapons) & (_:bIsPrimary) ? PRIMARY_WEAPONS SECONDARY_WEAPONS)
            {
                
dropWeapons(player, (bIsPrimary) ? 2)
            }
        }
        
        
ExecuteHamB(Ham_TouchiHitWboxplayer)
    } 
The problem was here

PHP Code:
new iWeaponByte = (<< iWeaponID
I was trying to use CSW_ here but I didn't knew how. I readed cstrike.inc and found out how. But I got another problem. When I'm too close to the dropped weapon and press E, I'd drop my weapon and pick it up normally. But If i'm a little bit far away, I only drop my weapon and don't pick the dropped the weapon up. Why?
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 06-19-2017 at 15:04.
EFFx 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 23:08.


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