Raised This Month: $51 Target: $400
 12% 

Global array


Post New Thread Reply   
 
Thread Tools Display Modes
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-22-2012 , 01:33   Re: Global array
Reply With Quote #21

Quote:
Originally Posted by Doc-Holiday View Post
using dynamic arrays...

Code:
CreateArray

Syntax:
native Handle:CreateArray(blocksize=1, startsize=0);

Usage:
 blocksize        The number of cells each member of the array can hold.  For example, 32 cells is equivalent to: new Array[X][32]
 startsize        Initial size of the array.  Note that data will NOT be auto-intialized.
PHP Code:
new Handle:g_SteamIdArray;

g_SteamIdArray CreateArray(21); //<-- Number of cells each member can have..
PushArrayString(g_SteamIdArray SteamIdGoesHere); //<--- To set a string value 
You forgot the difference between cell and byte. 21 bytes would require 6 cells.
__________________
FaTony is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-22-2012 , 02:19   Re: Global array
Reply With Quote #22

Quote:
Originally Posted by FaTony View Post
You forgot the difference between cell and byte. 21 bytes would require 6 cells.
Incidentally, this is what the ByteCountToCells function is for.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
ShufflexDD
Senior Member
Join Date: Apr 2011
Location: :noitaɔo˩
Old 10-22-2012 , 11:21   Re: Global array
Reply With Quote #23

right example please, I'm too confused

kinda got it
Code:
CreateArray(ByteCountToCells(21));
Or use ByteCountToCells once to get value is enough?

@Doc-Holiday, I found it in 2 post above yours
__________________

⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈
Check this website and find out how many functions
it has working with game server together.

Last edited by ShufflexDD; 10-22-2012 at 11:31.
ShufflexDD is offline
Send a message via ICQ to ShufflexDD Send a message via Skype™ to ShufflexDD
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-22-2012 , 15:21   Re: Global array
Reply With Quote #24

Quote:
Originally Posted by ShufflexDD View Post
right example please, I'm too confused

kinda got it
Code:
CreateArray(ByteCountToCells(21));
Or use ByteCountToCells once to get value is enough?

@Doc-Holiday, I found it in 2 post above yours
you were asking for an example....... lol so i showed you how to use it and yes according to the way the post are after mine the above code would create what you want. however the wiki shows

new Array[X][32];
is the same as
CreateArray(32);

Wouldnt you be able to simply

PHP Code:
g_array CreateArray(21);

PushArrayString(g_arrayszSteamId); 
Doc-Holiday is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-22-2012 , 15:29   Re: Global array
Reply With Quote #25

Quote:
Originally Posted by Doc-Holiday View Post
you were asking for an example....... lol so i showed you how to use it and yes according to the way the post are after mine the above code would create what you want. however the wiki shows

new Array[X][32];
is the same as
CreateArray(32);
A few things:
1. new Array[X][32] will give you tag errors if you try to use Strings with it.
2. new String:Array[X][32] creates an array that takes up 1/4 the space that new Array[X][32] does. Same with CreateArray(ByteCountToCells(32)) versus CreateArray(32) because ByteCountToCells(32) returns 8. Just as important, ByteCountToCells may change at a later date if a 64-bit version of srcds appears and SourcePawn starts using 64-bit cells, meaning that you shouldn't hard-code 8 there either.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 10-22-2012 at 15:31.
Powerlord is offline
ShufflexDD
Senior Member
Join Date: Apr 2011
Location: :noitaɔo˩
Old 10-22-2012 , 15:36   Re: Global array
Reply With Quote #26

oh, pawn. So many problems from nothing...




for example php, it isn't ideal language too, but there is no difficulties with the same arrays
__________________

⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈
Check this website and find out how many functions
it has working with game server together.

Last edited by ShufflexDD; 10-22-2012 at 15:40.
ShufflexDD is offline
Send a message via ICQ to ShufflexDD Send a message via Skype™ to ShufflexDD
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-22-2012 , 18:12  
Reply With Quote #27

Quote:
Originally Posted by Powerlord View Post
A few things:
1. new Array[X][32] will give you tag errors if you try to use Strings with it.
2. new String:Array[X][32] creates an array that takes up 1/4 the space that new Array[X][32] does. Same with CreateArray(ByteCountToCells(32)) versus CreateArray(32) because ByteCountToCells(32) returns 8. Just as important, ByteCountToCells may change at a later date if a 64-bit version of srcds appears and SourcePawn starts using 64-bit cells, meaning that you shouldn't hard-code 8 there either.
Yes i meant to put the string tag. And thanks for explaining it for me
Doc-Holiday is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-23-2012 , 01:04   Re: Global array
Reply With Quote #28

Quote:
Originally Posted by ShufflexDD View Post
for example php, it isn't ideal language too, but there is no difficulties with the same arrays

Don't even start on php. The most horrible language I've ever seen.
me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
__________________
FaTony is offline
ShufflexDD
Senior Member
Join Date: Apr 2011
Location: :noitaɔo˩
Old 10-23-2012 , 04:45   Re: Global array
Reply With Quote #29

Quote:
Originally Posted by FaTony View Post

Don't even start on php. The most horrible language I've ever seen.
me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
I've readed it, because of this I wrote
Quote:
Originally Posted by ShufflexDD View Post
it isn't ideal language too
But in in comparison with pawn, it's like night and day. No one lang is ideal.
Also tell me please which language you like.
__________________

⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈
Check this website and find out how many functions
it has working with game server together.

Last edited by ShufflexDD; 10-23-2012 at 04:50.
ShufflexDD is offline
Send a message via ICQ to ShufflexDD Send a message via Skype™ to ShufflexDD
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-23-2012 , 04:58   Re: Global array
Reply With Quote #30

Quote:
Originally Posted by ShufflexDD View Post
I've readed it, because of this I wrote


But in in comparison with pawn, it's like night and day. No one lang is ideal.
Also tell me please which language you like.
C++ but we are off topic now.
__________________
FaTony 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 03:01.


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