AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Finding Weapon Entities (https://forums.alliedmods.net/showthread.php?t=10863)

Votorx 03-03-2005 11:50

Finding Weapon Entities
 
How can I find weapon entities that are on the floor? For instance, I'm trying to find out if the client is close enough to a m4a1 (classname "weapon_m4a1", I think) to do something. Its not working and I don't know why. Maybe I have the wrong classname, what IS the right classname for a dropped m4a1 (or any other weapon) or an easier way to find a dropped weapon without find_ent_in_sphere().[/i]

twistedeuphoria 03-03-2005 12:16

Classname of any dropped weapon is "weaponbox" I believe. You just have to figure out what the model name is (I would look in the server's basedir in the models directory) then you cna use find_ent_by_class or some such and then figure out if they're close enough.

I think that's right.

Votorx 03-03-2005 21:16

Huh...Weapon box...I'll try it out then.

xeroblood 03-03-2005 21:46

armoury_entity

It would have an index to indicate which weapon it is, but I am not exactly sure how to grab it in amx.. maybe an offset value, but I have never experimented with it... Also, here is the listing for it found in the Expert FGDs for making maps...

Code:

@PointClass iconsprite("sprites/CS/Armoury.spr") size(-16 -16 0, 16 16 16) = armoury_entity : "Items in the armoury"
[
        item(choices)  : "Item" : 0 =
        [
                0: "weapon_mp5"
                1: "weapon_tmp"
                2: "weapon_p90"
                3: "weapon_mac10"
                4: "weapon_ak47"
                5: "weapon_sg552"
                6: "weapon_m4a1"
                7: "weapon_aug"
                8: "weapon_scout"
                9: "weapon_g3sg1"
                10: "weapon_awp"
                11: "weapon_m3"
                12: "weapon_xm1014"
                13: "weapon_m249"
                14: "weapon_flashbang"
                15: "weapon_hegrenade"
                16: "item_kevlar"
                17: "item_assaultsuit"
                18: "weapon_smokegrenade"
        ]
        count(integer) : "Count" : 1
]

I dont know, maybe that helps?

Twilight Suzuka 03-03-2005 23:13

You could just catch it AFTER spawn, when they are weapon_*'s.

Johnny got his gun 03-04-2005 04:50

You have to tell *dropped* weapons from weapons that are onground as they are compiled into the map.

Classname "weaponbox" is a dropped weapon.
Classname "armoury_entity" is an onground weapon.

You could loop through the weaponboxes but then you're not always sure which weapon entity it is tied to (I haven't found out a way). Instead you can loop through all weapon_m4a1 for instance, and check its EV_ENT_owner. If it's above get_maxplayers() it will be a weaponbox entity, and thus, a dropped weapon.

For onground, compiled weapons you could just loop through the armoury_entity:s and check their EV_SZ_model. There is no weapon entity ever tied to an armoury_entity.

To check if you are near the m4a1 then just compare the origin of the weaponbox.

Votorx 03-04-2005 11:56

Does the weaponbox have the same key values as armoury_entity?
And, when looking at an fgd file, how can I tell which are the values and which are the actual keys?

Like here
Code:

item(choices)  : "Item" : 0 =
item (not "Item") is the key? and (choices) (whichever weapon_*) is the key value? So If I were to create an entity with the classname "armoury_entity) and gave the key "item" the value "weapon_m4a1" then this would create that weapon on the floor or whatever origin I give it after DispatchSpawn() right?


All times are GMT -4. The time now is 14:00.

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