[Tutorial] Soluciуn a Array multidimensional en Enum.
#1

Hola, digamos que yo quiero hacer un lugar de almacenamiento donde los jugadores puedan guardar armas. Si quiero almacenar cinco armas y su respectiva municiуn, me gustarнa aсadir un simple y sencillo array multidimensional, їpero quй pasa? no funciona.

Ej.
pawn Code:
enum eHouse
{
    hCreated,
    Float:hEnter[3],
    Float:hExit[3],
    hInterior,
    hOwner[MAX_PLAYER_NAME],
    hValue,
    hLock,
    hStorage[5][2],
    hPickup,
    Text3D:hLabel
};
new House[50][eHouse];
Para solucionar esto vamos a remplazar un par de cosas para lograr simular utilizar nuestra variable con sus respectivos arrays, ya que esta funciуn no convierte realmente a 'hStorage' en multidimensional, simplemente lo hace parecer.

Ej.
pawn Code:
const hStorage_size1 = 5;
const hStorage_size2 = 2;
const sizeof_hStorage = hStorage_size1 * hStorage_size2;
enum eHouse
{
    hCreated,
    Float:hEnter[3],
    Float:hExit[3],
    hInterior,
    hOwner[MAX_PLAYER_NAME],
    hValue,
    hLock,
    hStorage[sizeof_hStorage],
    hPickup,
    Text3D:hLabel
};
new House[50][eHouse];

#define hStorage][%1][%2] hStorage][((%1)*hStorage_size2)+(%2)]
Luego, para comprobar si realmente funciona, lo que harй serб cambiar algunos valores, y sн, efectivamente funciona.

Ej.
pawn Code:
House[houseid][hStorage][2][0] = WEAPON_MP5;
House[houseid][hStorage][2][1] = 500;
Reply


Messages In This Thread
Soluciуn a Array multidimensional en Enum. - by KennySec - 07.07.2016, 11:59
Re: Soluciуn a Array multidimensional en Enum. - by Girl - 08.07.2016, 12:21

Forum Jump:


Users browsing this thread: 1 Guest(s)