AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Return csw_ weapon (https://forums.alliedmods.net/showthread.php?t=298666)

EFFx 06-19-2017 13:13

Return csw_ weapon
 
My search knowledge didn't find one thread that returns csw_ weapon tag. Someone have it in hands?

PRoSToTeM@ 06-19-2017 13:33

Re: Return csw_ weapon
 
What do you mean?

HamletEagle 06-19-2017 13:52

Re: Return csw_ weapon
 
get_user_weapon? get_weaponid?

EFFx 06-19-2017 14:57

Re: Return csw_ weapon
 
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?

Natsheh 06-19-2017 14:59

Re: Return csw_ weapon
 
If your using amxmodx version 1.8.3 these bitsums already defined as const in the include

EFFx 06-19-2017 15:11

Re: Return csw_ weapon
 
You mean SECONDARY and PRIMARY? If so, where? Any 1.8.3?

OciXCrom 06-19-2017 16:02

Re: Return csw_ weapon
 
Look at the cstrike consts inc file.

EFFx 06-19-2017 16:19

Re: Return csw_ weapon
 
I only saw cs_get_primweapons() or something similat at it. I didn't see nothing else.

PRoSToTeM@ 06-19-2017 18:11

Re: Return csw_ weapon
 
Code:
PickupWeapon(player, weaponbox) {     if ((pev(weaponbox, pev_flags) & FL_ONGROUND) == 0) {         return;     }         new slot = GetWeaponboxSlot(weaponbox);     if (slot == 0) {         return;     }         const m_rgpPlayerItems = 1468/4;     const m_rgpPlayerItems_diff = 1488/4 - m_rgpPlayerItems;     new weapon = get_pdata_cbase(player, m_rgpPlayerItems + slot, m_rgpPlayerItems_diff);     if (weapon > 0) {         if (!bool:ExecuteHamB(Ham_CS_Item_CanDrop, weapon)) {             return;         }                 new classname[32];         pev(weapon, pev_classname, classname, charsmax(classname));         engclient_cmd(player, "drop", classname);     }         ExecuteHamB(Ham_Touch, weaponbox, player); } GetWeaponboxSlot(weaponbox) {     const SlotCount = 6;     for (new i = 1; i < SlotCount; i++) {         const m_rgpPlayerItems = 136/4;         const m_rgpPlayerItems_diff = 152/4 - m_rgpPlayerItems;         if (get_pdata_cbase(weaponbox, m_rgpPlayerItems + i, m_rgpPlayerItems_diff) > 0) {             return i;         }     }         return 0; }

Craxor 06-19-2017 18:23

Re: Return csw_ weapon
 
What about Counter_Strike pu manager :P :D ???


All times are GMT -4. The time now is 23:08.

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