2d array with different value types
#1

Hi all,

I need to create a 2d array with different variable types within it. That doesn't really explain what Im trying to do very well, but hopefully my attempt below may describe what im trying to do.

Код:
//I want an array which has both and integer value and a string value inside of it. 
myArray[0] =>[0]=>1
myArray[0] =>[1]=>"This string"

myArray[1] =>[0]=>2
myArray[1] =>[1]=>"Another string"
I know the above isn't PAWN code obviously, however I hope you can see the jyst of what I want.

Thanks in advance for any help.
Reply
#2

Enumerators

https://sampforum.blast.hk/showthread.php?tid=318307
Reply
#3

Yep. Enumerators.

Код:
enum MyEnumerator
{
    enumInteger,
    enumString[32]
};
new MyArray[][MyEnumerator] = {
    {1, "This string"},
    {2, "Another string"}
};

MyArray[0][enumInteger] => 1
MyArray[1][enumString] => "Another string"
Reply
#4

If you are going serial wise, you can make use of the index id itself.

pawn Код:
myArray[0] =>"This string"
(index => 0 + 1 => 1)

myArray[1] =>"Another string"
(index => 1 + 1 => 2)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)