07.07.2016, 11:59
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.
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.
Luego, para comprobar si realmente funciona, lo que harй serб cambiar algunos valores, y sн, efectivamente funciona.
Ej.
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];
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)]
Ej.
pawn Code:
House[houseid][hStorage][2][0] = WEAPON_MP5;
House[houseid][hStorage][2][1] = 500;