Consulta - Variables. -
Unrea1 - 21.07.2015
Hola,
Mi siguiente duda estб relacionado con lo siguiente (sobre variables asd[playerid][asd2]):
Le explicarй mбs o menos lo que quiero hacer, tengo 552 variables en un enum por ejemplo;
Quote:
enum jObj
{
jObjeto1,
jObjeto2,
jObjeto3,
// y asн sucesivamente...
};
new PObjetos[MAX_PLAYERS][jObj];
|
y el cуdigo a lo que quiero hacer:
Quote:
new NameO[64];
for(new ID = 1; ID < 552; ID++)
{
format(NameO, sizeof(NameO), "Objeto%i", ID);
cache_get_field_content(0, NameO, content);
PlayerInfo[extraid][AQUI] = strval(content); // AQUН ES DONDE NO SE QUE PONER PARA QUE EJECUTE DE UNA VEZ jObjeto1, jObjeto2, y asн...
}
|
Lo que quiero hacer es enumerar todas esas variables en un loop como lo mostrй en el cуdigo anterior pero no sй como, ojalб me den una mano, gracias!
Re: Consulta - Variables. -
SickAttack - 21.07.2015
pawn Код:
for(new pInfo:i; i < pInfo; i ++) PlayerInfo[extraid][i] = strval(content);
pInfo siendo tu enumerador.
Re: Consulta - Variables. -
Unrea1 - 21.07.2015
Quote:
Originally Posted by SickAttack
pawn Код:
for(new pInfo:i; i < pInfo; i ++) PlayerInfo[extraid][i] = strval(content);
pInfo siendo tu enumerador.
|
Bien, їy si por ejemplo tengo mбs cosas en el mismo enum, que se podrнa hacer? Gracias.
Respuesta: Consulta - Variables. -
Treyfus - 21.07.2015
En tu caso
CREO que serнa algo asн:
pawn Код:
new NameO[64];
for(new ID = 1; ID < 552; ID++)
{
format(NameO, sizeof(NameO), "Objeto%i", ID);
cache_get_field_content(0, NameO, content);
PlayerInfo[extraid][PObjetos[playerid][ID]] = strval(content); //
}
Re: Consulta - Variables. -
SickAttack - 21.07.2015
Quote:
Originally Posted by LatinZ
Bien, їy si por ejemplo tengo mбs cosas en el mismo enum, que se podrнa hacer? Gracias.
|
Lo que puse ahi, pasara por todos los elementos en la lista.
Re: Consulta - Variables. -
Unrea1 - 21.07.2015
Quote:
Originally Posted by Treyfus
En tu caso CREO que serнa algo asн:
pawn Код:
new NameO[64]; for(new ID = 1; ID < 552; ID++) { format(NameO, sizeof(NameO), "Objeto%i", ID); cache_get_field_content(0, NameO, content); PlayerInfo[extraid][PObjetos[playerid][ID]] = strval(content); // }
|
Eso claramente darб error por que " no tengo definido ID " en el enum...
Quote:
Originally Posted by SickAttack
Lo que puse ahi, pasara por todos los elementos en la lista.
|
Si lo sй, pero el caso es que querнa saber como excluir las demбs variables en el mismo enum; solo enumerando a los jObjeto...
Re: Consulta - Variables. -
SickAttack - 21.07.2015
Quote:
Originally Posted by LatinZ
Si lo sй, pero el caso es que querнa saber como excluir las demбs variables en el mismo enum; solo enumerando a los jObjeto...
|
Con sus indeces.
pawn Код:
for(new pInfo:i; i < pInfo; i ++)
{
if(i == 5 || i == 7) continue;
PlayerInfo[extraid][i] = strval(content);
}
O, seguramente lo que necesitas:
pawn Код:
for(new pInfo:i; i < pInfo; i ++)
{
if(i > 5) break;
PlayerInfo[extraid][i] = strval(content);
}
Re: Consulta - Variables. -
spell - 21.07.2015
pawn Код:
new NameO[64];
for(new ID = 1; ID < 552; ID++) {
format(NameO, sizeof(NameO), "Objeto%i", ID);
cache_get_field_content(0, NameO, content);
PObjetos[extraid][jObj:ID] = strval(content);
}
Re: Consulta - Variables. -
Unrea1 - 21.07.2015
Quote:
Originally Posted by spell
pawn Код:
new NameO[64]; for(new ID = 1; ID < 552; ID++) { format(NameO, sizeof(NameO), "Objeto%i", ID); cache_get_field_content(0, NameO, content); PObjetos[extraid][jObj:ID] = strval(content); }
|
Es mбs o menos lo que quiero. Pero...
warning 213: tag mismatch
Код:
new NameObj[64];
for(new ID = 1; ID < 552; ID++) {
format(NameObj, sizeof(NameObj), "Objeto%i", ID);
cache_get_field_content(0, NameObj, content);
PlayerInfo[extraid][jObjeto:ID] = strval(content); // WARNING.
}
Re: Consulta - Variables. -
SickAttack - 21.07.2015
Quote:
Originally Posted by LatinZ
Es mбs o menos lo que quiero. Pero...
warning 213: tag mismatch
Код:
new NameObj[64];
for(new ID = 1; ID < 552; ID++) {
format(NameObj, sizeof(NameObj), "Objeto%i", ID);
cache_get_field_content(0, NameObj, content);
PlayerInfo[extraid][jObjeto:ID] = strval(content); // WARNING.
}
|
pawn Код:
new NameObj[64];
for(new ID = 0; ID < 552; ID++) {
format(NameObj, sizeof(NameObj), "Objeto%i", ID);
cache_get_field_content(0, NameObj, content);
PObjetos[extraid][jObj:ID] = strval(content);
}