AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get the weapon your aiming at (https://forums.alliedmods.net/showthread.php?t=47032)

Martin1 11-07-2006 16:19

Get the weapon your aiming at
 
Is there a way to get the weapon your aiming at the floor. Im trying to make a plugin that allows you to have more than 1 weapon by making it so when you press the key , it tells the script to remember what weapon it was, then add to the players hand that weapon.

VEN 11-08-2006 04:20

Re: Get the weapon your aiming at
 
You can use for example fm_get_aim_origin from the Fakemeta Utilities and check with fm_find_ent_in_sphere if there are entities close to the aim point (set the short radius for that).

If so - check whether it's a weaponbox entity (classname). If so - get the linked weapon_* entity (classname). You can use for example fm_find_ent_by_integer(-1, pev_owner, weaponbox_entity_index_here) for that.

Then you should check whether the player already have this weapon or not. You can use for example
fm_find_ent_by_owner(-1, weapon_entity_classname, player_index) for that.

Also check if the weapon isn't a C4. In CS a player will be able to collect it mannually anyway, also this will avoid breaking of some specific things.

If so - give the found weapon to a player. You can use for example fm_give_item(player_index, weapon_entity_classname) for that.

Then all you have to do is delete the weaponbox and entity that linked to it. Don't try to delete them with default methods, it may crash your server. Use dllfunc(DLLFunc_Think, weaponbox_entity_index) for that.


All times are GMT -4. The time now is 06:58.

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