AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to make a string array? *i forgot (https://forums.alliedmods.net/showthread.php?t=93028)

Owyn 05-23-2009 12:10

how to make a string array? *i forgot
 
i need an array to store a individual string for every player, so i can campare it with other strings and use it like string_array[id] = string1; or a simular way, i looked thru my codes and.. do i have to use ArrayGetString() and like that just for this purpose?

Bugsy 05-23-2009 12:16

Re: how to make a string array? *i forgot
 
Quote:

Originally Posted by .Owyn. (Post 833126)
i need an array to store a individual string for every player, so i can campare it with other strings and use it like string_array[id] = string1; or a simular way, i looked thru my codes and.. do i have to use ArrayGetString() and like that just for this purpose?

To create an array of strings just make a 2 dimensional array. The first dimension is the number of strings you want to hold and the second dimension must be sized large enough for the largest possible string you wish to hold.

Suppose you want to put the following in an array:
Hello
this
is
an
array

new szArray[5][6];

Dimension 1 = 5 for 5 words
Dimension 2 = 6 because longest words are hello\array, each 5 chars in length + 1 for null so 6.

To store data in them, pass it as you would with a normal string except include the array element you wish to use.

new szAuthID[33][33];
get_user_authid( id , szAuthID[id] , 32 );

Hunter-Digital 05-23-2009 12:16

Re: how to make a string array? *i forgot
 
PHP Code:

new playerNames[33][32

?

edit: bugsy was faster and wrote more detailed =)

Owyn 05-23-2009 12:24

Re: how to make a string array? *i forgot
 
Bugsy,
thx *_*


All times are GMT -4. The time now is 01:28.

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