SA-MP Forums Archive
[Help]Changing data in a array in a enumerator? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help]Changing data in a array in a enumerator? (/showthread.php?tid=257460)



[Help]Changing data in a array in a enumerator? - CatFish - 26.05.2011

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


Re: [Help]Changing data in a array in a enumerator? - WooTFTW - 26.05.2011

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;
}



Re: [Help]Changing data in a array in a enumerator? - CatFish - 26.05.2011

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

Thanks for the information.


Re: [Help]Changing data in a array in a enumerator? - pen_theGun - 26.05.2011

You can

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

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



Re: [Solved]Changing data in a array in a enumerator? - CatFish - 26.05.2011

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


Re: [Help]Changing data in a array in a enumerator? - WooTFTW - 26.05.2011

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;
}



Re: [Help]Changing data in a array in a enumerator? - (SF)Noobanatior - 26.05.2011

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;
}