Duda: foreach YSI. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (
https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: Duda: foreach YSI. (
/showthread.php?tid=584187)
Duda: foreach YSI. -
Unrea1 - 02.08.2015
Hola,
quisiera saber si йsta ejecuciуn es vбlida para saber si йsto es lo que me estб causando crash:
Quote:
foreach (new i : Player)
{
foreach(new j : Bot)
{
/* codigo */...
}
}
|
Lo coloquй asн por que la iteraciуn Character no me sirve, por que no me reconoce los NPCґs (las funciones que quiero hacer con ellos) y los jugadores pues si les va bien, pero repito, lo hice asн para hacer que el NPC haga las funciones que le asigno. Gracias.
Respuesta: Duda: foreach YSI. -
Johansitho - 03.08.2015
A mн se me crasheaba el servidor si hacнa eso, Pero lo solucionй asн:
PHP код:
for(new v = 0; v < MAX_VEHICLES; v++)
{
//etc etc
foreach(Player, i)
{
//etc etc...
}
}
Primero el for( etc... Y luego foreach
Re: Duda: foreach YSI. -
Onfroi - 03.08.2015
Quote:
Originally Posted by LatinZ
Hola,
quisiera saber si йsta ejecuciуn es vбlida para saber si йsto es lo que me estб causando crash:
Lo coloquй asн por que la iteraciуn Character no me sirve, por que no me reconoce los NPCґs (las funciones que quiero hacer con ellos) y los jugadores pues si les va bien, pero repito, lo hice asн para hacer que el NPC haga las funciones que le asigno. Gracias.
|
foreach no detecta NPCs
pawn Код:
foreach(new i: Player)
{
if(IsPlayerNPC(i))
{
// codigo
}
}
Re: Duda: foreach YSI. -
Unrea1 - 03.08.2015
Quote:
Originally Posted by Onfroi
foreach no detecta NPCs
pawn Код:
foreach(new i: Player) { if(IsPlayerNPC(i)) { // codigo } }
|
pawn Код:
Iterators:
Player - List of all players connected.
Bot - List of all bots (npcs) connected.
NPC - Alias of Bot.
Character - All players and bots.
Por eso hago la duda...