AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Linking an Entity to a Bool (https://forums.alliedmods.net/showthread.php?t=118110)

wrecked_ 02-07-2010 20:28

Linking an Entity to a Bool
 
How would I link a bool to an entity?

For example, to set the player's id with a bool, I'd do
PHP Code:

new b_IsCool[33]

b_IsCool[id] = true 

What would I need to make the size of the array for if I was doing this?
I'd need something like this
PHP Code:

new b_DeagleIsLarger[111// What would I set for the array size here?

b_DeagleIsLarger[e_Deagle] = true // I assume I'd just put the entity id in the brackets here. 

Any help is appreciated.

fysiks 02-07-2010 20:34

Re: Linking an Entity to a Bool
 
Just find the range of possible values of what you are using it for. If the biggest value is 100 then you would need to dimension the array with 101.

wrecked_ 02-07-2010 20:38

Re: Linking an Entity to a Bool
 
I'm aware of the fact that I need to get the maximum value of what I need, but I'm unsure as to how to find it. For example, if I was trying to link this to a deagle, would I need to set the value to the maximum amount of weapons? Or would I set it to the maximum amount of deagles, etc.

fysiks 02-07-2010 20:59

Re: Linking an Entity to a Bool
 
If you mean that you need one for every deagle that has been spawned then it would need to be at least the number of deagles. But, I don't think that would work even. The entitiy number could be some huge number like 2639 (exagerated???; idk). If that was the case then you would need to dimension it very large.

Better yet, I think you should use some sort of lookup table of all the deagles that exist. This way you would only need to dimension for how many deagles exist at any one point in time. I don't know the finer details of how it would work this way but it's an idea.

If you tell us what you are trying to do then there might be better hope for the best solution for you.

P.S. I might not be the best person to ask either :).

wrecked_ 02-07-2010 21:07

Re: Linking an Entity to a Bool
 
What I'm trying to do is get each pistol and set different properties to the different pistols in the map. So, what I'd probably need to do is get the amount and set the entities to have different properties using bools.

So I'd do something like
PHP Code:

new b_HasSpeed[ENTITY_AMOUNT]
new 
b_IsGlowing[ENTITY_AMOUNT]
new 
b_HasGravity[ENTITY_AMOUNT]

// Get the entity ID's for each gun through pevs, etc.

// Now set the properties
b_HasSpeed[e_USPEnt] = true
b_IsGlowing
[e_DeagleEnt] = true
b_HasGravity
[e_GlockEnt] = true

/* And so on with the entities.
Keep in mind this is an example, but very similar to what I'm trying to do&*/ 

Thanks for the help.

Bugsy 02-07-2010 21:10

Re: Linking an Entity to a Bool
 
maybe this thread can help

http://forums.alliedmods.net/showthread.php?t=54117

wrecked_ 02-07-2010 21:19

Re: Linking an Entity to a Bool
 
Quote:

Originally Posted by Bugsy (Post 1082187)

Hmmmm, that helps a little bit, but isn't there a way to find the amount of entities of a single weapon itself? Perhaps through a for loop?

fysiks 02-07-2010 21:44

Re: Linking an Entity to a Bool
 
Kinda offtopic:
You could get down to one array by using the bits of the array entries for the properties.

PHP Code:

#define IS_GLOWING (1<<0)
//...

if(properties[deagle1] & IS_GLOWING)
{
    
// ...
}
if( 
/*...*/ )
{
    
//...


limited to 32 properties.

Bugsy 02-07-2010 21:45

Re: Linking an Entity to a Bool
 
yea, loop from maxplayers+1 to glb_maxentities and check to see if the entity is valid and if its the weapon you are looking for. use cs_get_weapon_id to check what type of weapon the entity is; the func returns the weapon index CSW_ const

Exolent[jNr] 02-07-2010 21:53

Re: Linking an Entity to a Bool
 
You should use pev values.
Code:
#define HasSpeed(%1) pev(%1, pev_iuser1) #define SetSpeed(%1,%2) set_pev(%1, pev_iuser1, %2) // ... SetSpeed( e_USPEnt, true );


All times are GMT -4. The time now is 07:25.

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