AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to get Armoury Entity Weapon ID ( CSW_* ) ? (https://forums.alliedmods.net/showthread.php?t=240109)

souvikdas95 05-09-2014 09:20

How to get Armoury Entity Weapon ID ( CSW_* ) ?
 
How to get Armoury Entity Weapon ID ( CSW_* ) ?

I am trying Ham_touch for armoury_entity but how to resolve the entity into its Weapon ID?

For WeaponBox types, we have fm_get_weaponbox_type () but that doesn't work on Maps where weapons are dropped by default ( no owner ). eg. aa_dima2, $1000$, etc. Only Once we pickup the weapon and drop it back, that this function responds to it on Touch.

( In Simple Words, If I want to touch an already dropped weapons on certain maps, I should be able to get its weapon id even before picking it up )

I was thinking of somehow temporarily faking weaponbox for armoury_entity. But I don't know how to do so.

Thanks!

hleV 05-09-2014 09:34

Re: How to get Armoury Entity Weapon ID ( CSW_* ) ?
 
Code:
/* Get what weapon type (CSW_*) an armoury_entity is.  */ native cs_get_armoury_type(index);

souvikdas95 05-09-2014 10:05

Re: How to get Armoury Entity Weapon ID ( CSW_* ) ?
 
can you tell me the difference b/w cs_get_weapon_id(index) and cs_get_armoury_type(index). I mean, difference in usage. eg. Can I directly use cs_get_weapon_id(index) with weapon entities having class "weaponbox" ?

aron9forever 05-09-2014 12:27

Re: How to get Armoury Entity Weapon ID ( CSW_* ) ?
 
Quote:

Originally Posted by souvikdas95 (Post 2135546)
can you tell me the difference b/w cs_get_weapon_id(index) and cs_get_armoury_type(index). I mean, difference in usage. eg. Can I directly use cs_get_weapon_id(index) with weapon entities having class "weaponbox" ?

cs_get_armoury_type(index) returns type of weapon that's "armoury_entity"
cs_get_weapon_id(index) returns type of weapon

the answer to your question that should solve all questions is that weapons on the ground on maps like fy_snow are armoury_entity(is that even spelled right?) from mapping knowledge, so you will need to use it to detect weapons that are on the ground(if it's the only one you want to detect)

use cs_get_weapon_id(index) if you want to detect all weapons including the ones that spawn on the ground at newround

souvikdas95 05-09-2014 13:02

Re: How to get Armoury Entity Weapon ID ( CSW_* ) ?
 
@aron9forever - Then what is this -_- :

PHP Code:

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


Couldn't I simply use cs_get_weapon_id ( ent ) instead of using this function?

What I think is, it's based on the class of weapons. Armoury Entity is what we get in maps where weapons are spawned on the ground. Once we pick it up, it turns into Weaponbox type ( as tested from Ham_Touch ). So I will have to make 2 different checks for that.

hleV 05-09-2014 13:05

Re: How to get Armoury Entity Weapon ID ( CSW_* ) ?
 
The function above is for "weaponbox" entity.
cs_get_armoury_type() is for "armoury_entity" entity.

aron9forever 05-09-2014 13:19

Re: How to get Armoury Entity Weapon ID ( CSW_* ) ?
 
Quote:

Originally Posted by souvikdas95 (Post 2135635)
@aron9forever - Then what is this -_- :

PHP Code:

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


Couldn't I simply use cs_get_weapon_id ( ent ) instead of using this function?

What I think is, it's based on the class of weapons. Armoury Entity is what we get in maps where weapons are spawned on the ground. Once we pick it up, it turns into Weaponbox type ( as tested from Ham_Touch ). So I will have to make 2 different checks for that.

you're losing me with all these questions, your original post does not explain what you want, all it says is you want to get the CSW_* of a weapon, well then cs_get_weapon_id ( index ) is the answer.

the correct way to get the CSW_* equivalent of the weapon a player touches then use the snippet taken from connormcleod.

his snippet goes all the way trough checking what weapon was picked up by index, then transforming said index and returning it as a CSW_*

cs_get_armoury_type(index) is for an entity, index as in entity index not as in weapon index, a weapon is an entity when it's on the ground, but it's armoury only when it was spawned with the map
once the gun is in your hand it's no longer an entity, you are the entity holding the gun(I think, I'm not sure of this one)

meTaLiCroSS 05-09-2014 14:18

Re: How to get Armoury Entity Weapon ID ( CSW_* ) ?
 
There're 3 different things.

1) A "weaponbox" entity
2) An "armoury_entity" entity
3) A "weapon_*" entity

A weaponbox it's an entity that carries a weapon_* entity on it.
An armoury_entity it's an entity which just gives a new weapon (defined on a member(offset)) when touching it
A weapon_* entity it's the weapon attached to the player. (it doesn't have model)


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

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