Raised This Month: $ Target: $400
 0% 

Linking an Entity to a Bool


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-07-2010 , 20:28   Linking an Entity to a Bool
Reply With Quote #1

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.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-07-2010 , 20:34   Re: Linking an Entity to a Bool
Reply With Quote #2

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.
__________________
fysiks is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-07-2010 , 20:38   Re: Linking an Entity to a Bool
Reply With Quote #3

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.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-07-2010 , 20:59   Re: Linking an Entity to a Bool
Reply With Quote #4

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 .
__________________
fysiks is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-07-2010 , 21:07   Re: Linking an Entity to a Bool
Reply With Quote #5

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.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-07-2010 , 21:10   Re: Linking an Entity to a Bool
Reply With Quote #6

maybe this thread can help

http://forums.alliedmods.net/showthread.php?t=54117
__________________
Bugsy is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-07-2010 , 21:19   Re: Linking an Entity to a Bool
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
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?
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-07-2010 , 21:44   Re: Linking an Entity to a Bool
Reply With Quote #8

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.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-07-2010 , 21:45   Re: Linking an Entity to a Bool
Reply With Quote #9

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
__________________
Bugsy is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-07-2010 , 21:53   Re: Linking an Entity to a Bool
Reply With Quote #10

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 );
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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