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

Global array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ShufflexDD
Senior Member
Join Date: Apr 2011
Location: :noitaɔo˩
Old 10-19-2012 , 13:04   Global array
Reply With Quote #1

I have to use this code:
Code:
new String:players[SQL_GetRowCount(query)];
as you can see, I set length of array by count of rows in sql.
This code in OnPluginStart, but I need a global array(I can't set it in global area 'cause I don't know how many rows in sql).
Although I can declare an array in global area with fixed length of array, but it's bad.
So how to figure it out?
__________________

⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈
Check this website and find out how many functions
it has working with game server together.
ShufflexDD is offline
Send a message via ICQ to ShufflexDD Send a message via Skype™ to ShufflexDD
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 10-19-2012 , 13:10   Re: Global array
Reply With Quote #2

If you want to make it global, set the String size to some maximum you know you won't exceed.

E.g. If the string holds a player's name, set the maximum length to MAX_NAME_LENGTH.
__________________
11530 is offline
ShufflexDD
Senior Member
Join Date: Apr 2011
Location: :noitaɔo˩
Old 10-19-2012 , 13:21   Re: Global array
Reply With Quote #3

it's an array of strings.
I just hoped there is exist another way & better way to do it.
Also I'll be able to use while if it's possible.
__________________

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

Last edited by ShufflexDD; 10-19-2012 at 13:23.
ShufflexDD is offline
Send a message via ICQ to ShufflexDD Send a message via Skype™ to ShufflexDD
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 10-19-2012 , 13:28   Re: Global array
Reply With Quote #4

For a global array of strings use a 2-dimensional array. For example, for an array of players' names use:

new String:g_szPlayersNames[MAXPLAYERS+1][MAX_NAME_LENGTH];
__________________

Last edited by 11530; 10-19-2012 at 13:32.
11530 is offline
ShufflexDD
Senior Member
Join Date: Apr 2011
Location: :noitaɔo˩
Old 10-19-2012 , 13:36   Re: Global array
Reply With Quote #5

In array I store steamid's of vip players. I do not need to use 2D arrays.
but thx for helping
__________________

⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈⇈
Check this website and find out how many functions
it has working with game server together.
ShufflexDD is offline
Send a message via ICQ to ShufflexDD Send a message via Skype™ to ShufflexDD
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 10-19-2012 , 13:46   Re: Global array
Reply With Quote #6

Quote:
Originally Posted by ShufflexDD View Post
it's an array of strings.
Quote:
Originally Posted by ShufflexDD View Post
I do not need to use 2D arrays.
That's a contradiction. An array of strings is a 2D array (since a string is considered an array itself). Anyway, use a maximum size of 21 for a SteamID.
__________________
11530 is offline
ShufflexDD
Senior Member
Join Date: Apr 2011
Location: :noitaɔo˩
Old 10-19-2012 , 14:06   Re: Global array
Reply With Quote #7

may be I'm wrong, I just want to store e.g. 2 steamid's in array
Code:
players[1] = "STEAM_0:0:1";
players[2] = "STEAM_0:0:2";
I know that strings is already array of letters, so I have to make 'em 2D?
__________________

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

Last edited by ShufflexDD; 10-19-2012 at 14:10.
ShufflexDD is offline
Send a message via ICQ to ShufflexDD Send a message via Skype™ to ShufflexDD
ShufflexDD
Senior Member
Join Date: Apr 2011
Location: :noitaɔo˩
Old 10-19-2012 , 14:08   Re: Global array
Reply With Quote #8

yep, you're right, thx

stupid pawn
__________________

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

Last edited by ShufflexDD; 10-19-2012 at 14:14.
ShufflexDD is offline
Send a message via ICQ to ShufflexDD Send a message via Skype™ to ShufflexDD
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 10-19-2012 , 16:11   Re: Global array
Reply With Quote #9

Quote:
Originally Posted by ShufflexDD View Post
stupid pawn
pawn can't be stupid, only the coder. I'm happy that that Pawn isn't that ressource hungry like some other languages.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 10-19-2012 at 16:12.
berni is offline
ShufflexDD
Senior Member
Join Date: Apr 2011
Location: :noitaɔo˩
Old 10-20-2012 , 05:31   Re: Global array
Reply With Quote #10

Quote:
Originally Posted by berni View Post
pawn can't be stupid, only the coder. I'm happy that that Pawn isn't that ressource hungry like some other languages.
pawn is bad language(in contrast to the others), strings are array, every array I need to define it's size.(it's not all )
one advantage it is small(probably 'cause of this it is used by sourcemod)
__________________

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

Last edited by ShufflexDD; 10-20-2012 at 05:32.
ShufflexDD is offline
Send a message via ICQ to ShufflexDD Send a message via Skype™ to ShufflexDD
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 01:11.


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