[Help]Changing data in a array in a enumerator?
#1

Hey, I'm having trouble with setting parts of a array in a enumerator/array or whatever i have no clue.
I would like to know what am i doing wrong, is this even possible and if it is how to.

i based this example (which doesn't work of course) on the Sa-mp wiki's page on accessing data in a array

pawn Код:
#include <a_samp>

enum Test
{
    MyArray[5]
};


new MyTest[20][Test];

main()
{
    MyTest[0][MyArray[3]] = 2;
}
Thanks
Reply
#2

You can't have 3 dimensional arrays.
You will have to do this like this
pawn Код:
enum Test
{    
    MyArray0,
    MyArray1,
    MyArray2,
    MyArray3,
    MyArray4,
};
new MyTest[20][Test];

main()
{    
    MyTest[0][MyArray3] = 2;
}
Reply
#3

*sigh*
i was hoping i wouldn't need to do that (array1, array2 etc)

Thanks for the information.
Reply
#4

You can

pawn Код:
main()
{
    printf("sizeof:%d", sizeof( MyTest ))

    MyTest[0][MyArray][3] = 2;
    printf("%d", MyTest[0][MyArray][3])
}
Reply
#5

Quote:
Originally Posted by pen_theGun
Посмотреть сообщение
You can

pawn Код:
main()
{
    printf("sizeof:%d", sizeof( MyTest ))

    MyTest[0][MyArray][3] = 2;
    printf("%d", MyTest[0][MyArray][3])
}
Oh great i see, thank you so much .

pretty much solves it up
Reply
#6

Quote:
Originally Posted by CatFish
Посмотреть сообщение
*sigh*
i was hoping i wouldn't need to do that (array1, array2 etc)

Thanks for the information.
Sorry, i provided false information.
I thought that you need something like this
pawn Код:
enum Arrays
{
    MyArray[5][5], // This will be 3D array
};
i messed something up

Just do it like this

pawn Код:
enum Arrays
{
    MyArray[5],
};
new InfoArrays[5][Arrays];
main()
{
   InfoArrays[0][MyArray][0] = 2;
}
Reply
#7

here is my example
pawn Код:
enum example {
    name[40],//string
    Float:health,//float
    score,//intiger
    bool:isconnected//boolen
}
new Variable[MAX_PLAYERS][example];

public OnPlayerConnect(playerid)
{
    new pretendscore = 42;
    GetPlayerName(playerid,Variable[playerid][name],40);//string
    GetPlayerHealth(playerid,Variable[playerid][health]);//float
    Variable[playerid][score] = pretendscore;//integer
    Variable[playerid][isconnected] = true;//boolen
    new str[128];
    if(Variable[playerid][isconnected] == true){
        format(str,128,"%s has health of %.2f with a score of %d",Variable[playerid][name],Variable[playerid][health],Variable[playerid][score]);
    }
    else if(Variable[playerid][isconnected] == false){
        str = "you wont see this";
    }
    SendClientMessage(playerid,0x000001,str);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)