Raised This Month: $32 Target: $400
 8% 

What's difference between...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ByPass
New Member
Join Date: Dec 2018
Old 12-29-2018 , 17:27   What's difference between...
Reply With Quote #1

What's the difference between this:

PHP Code:
new a[32];

public 
some_func()
{
    
a[id] = create_entity("info_target");

And this:

PHP Code:
new a[32][1];

public 
some_func()
{
    
a[id][0] = create_entity("info_target");

Could you explain it to me?

NOTE: It should be noted that from where I see it, there is no difference, but I may be wrong...

Last edited by ByPass; 12-29-2018 at 17:29.
ByPass is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-29-2018 , 17:35   Re: What's difference between...
Reply With Quote #2

You create array and 2d array.

*edit
Ok, I misread, it should be new a[32][2];
Because if you create [array], you set array size. Array index start from 0.



Code:
new a[32];

a[0]
a[1]
a[2]
a[3]
a[4]
a[5]
...
Code:
new a[32][2];

a[0][0]
a[0][1]
a[1][0]
a[1][1]
a[2][0]
a[2][1]
a[3][0]
a[3][1]
...



here picture 3D
g_variable[1][3][0] = 1337
Attached Thumbnails
Click image for larger version

Name:	map.png
Views:	215
Size:	12.8 KB
ID:	173002  

Last edited by Bacardi; 12-29-2018 at 17:52.
Bacardi is offline
ByPass
New Member
Join Date: Dec 2018
Old 12-29-2018 , 18:09   Re: What's difference between...
Reply With Quote #3

That means that for each player of the 32 players can be created 2 different entities or just one?

PHP Code:

#define MAX_PLAYERS 32
#define MAX_ENTITIES_PER_PLAYER 2

new a[MAX_PLAYERS][MAX_ENTITIES_PER_PLAYER];

a[id][0] = create_entity("info_target"); // entity 1
a[id][1] = create_entity("info_target"); // entity 2 
And those two entities do not affect each other?

The thing is that I want to create an array for each player where I can store an undetermined number of entities.

Last edited by ByPass; 12-29-2018 at 18:11.
ByPass is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 12-29-2018 , 18:11   Re: What's difference between...
Reply With Quote #4

Quote:
Originally Posted by ByPass View Post
That means that for each player of the 32 players can be created 2 different entities or just one?

PHP Code:

new a[32][2];

a[id][0] = create_entity("info_target"); // entity 1
a[id][1] = create_entity("info_target"); // entity 2 
And those two entities do not affect each other?
In your case, two.
__________________
edon1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-29-2018 , 21:00   Re: What's difference between...
Reply With Quote #5

Quote:
Originally Posted by ByPass View Post
The thing is that I want to create an array for each player where I can store an undetermined number of entities.
Either you have to set MAX_ENTITIES_PER_PLAYER to a large number and make sure you have code to deal with the situation where you run out or you have to get tricky with a bunch of dynamic arrays. I'd recommend former.
__________________
fysiks is offline
ByPass
New Member
Join Date: Dec 2018
Old 12-29-2018 , 22:27   Re: What's difference between...
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
Either you have to set MAX_ENTITIES_PER_PLAYER to a large number and make sure you have code to deal with the situation where you run out or you have to get tricky with a bunch of dynamic arrays. I'd recommend former.
Sure, I've the concept well established, what I would like to know is if it's appropriate to do it that way:

Create an array of each player, where for each player at least 4 entities (of any kind or nature) can be created.

PHP Code:
// Something like this:

new entities[32][4];

public 
some_func(id)
{
     
entities[id][0] = create_entity("env_model");
     
entities[id][1] = create_entity("info_target");
     
entities[id][2] = create_entity("env_sprite");
     
entities[id][3] = create_entity("func_breakable");

I would also like to know if doing it in this way the configuration of the entities will affect each other.

That is, I want to know if they could "mix" or "affect" each other ...
ByPass is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-30-2018 , 01:32   Re: What's difference between...
Reply With Quote #7

Quote:
Originally Posted by ByPass View Post
I would also like to know if doing it in this way the configuration of the entities will affect each other.

That is, I want to know if they could "mix" or "affect" each other ...
That has nothing to do with how you store the entity number. It will depend on how the entities them selves behave and what you do with them.
__________________
fysiks is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-30-2018 , 06:12   Re: What's difference between...
Reply With Quote #8

There is a bit diffs which is you can achieve it using 1dArray, making it 2d array is just useless by adding one cell to each row.


If you have another question start a new thread...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-30-2018 at 06:12.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply


Thread Tools
Display Modes

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 20:14.


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