AlliedModders

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

The Specialist 12-24-2006 07:41

Using Entities
 
I was wondering if there was a good way to detect Wether a player was holding an entity ( a weapon box entity i created ), Other then checking models . The current way I am doing it , is by getting the users weapon , and if hes holding a regular weapon then hes not holding mine . which is a pain because I have to compare the 30 weapon types .

Simon Logic 12-25-2006 07:25

Re: Using Entities
 
Try to use entvar's attribute .owner of your entity. But this forces you to scan through all your existing specific weapons.

Simon Logic 12-25-2006 07:26

Re: Using Entities
 
PS. Never use modelindex because it's zeroed as it has been grabbed by a player.

Wilson [29th ID] 12-25-2006 12:10

Re: Using Entities
 
Code:
public get_weapon(id, weapon[]) {     new currentent = -1, gunid = 0;     // get origin     new Float:origin[3];     entity_get_vector(id,EV_VEC_origin,origin);         while((currentent = find_ent_in_sphere(currentent,origin,Float:1.0)) != 0) {         new classname[32];         entity_get_string(currentent,EV_SZ_classname,classname,31);             if(equal(classname,weapon))             gunid = currentent;         }     return gunid; }

The Specialist 12-25-2006 12:13

Re: Using Entities
 
Quote:

Originally Posted by Simon Logic (Post 419595)
PS. Never use modelindex because it's zeroed as it has been grabbed by a player.

Well Im doing the same thing to my entity weapon , Im studying the half life sdk source for weapons , and the models are 0'd simulate no weapon.

Ill try that code wilson thanks :wink:


All times are GMT -4. The time now is 22:20.

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