[ Problema ] Con loops - 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: [ Problema ] Con loops (
/showthread.php?tid=337704)
[ Problema ] Con loops -
spell - 27.04.2012
Hola , estoy haciendo un GM y tengo un problema con los loops, que solamente modifican a '0', por ejemplo un comando de respawn solamente respawnea al veh id 1, o un comando para dar vida/combustible o lo que sea solamente le modifica al id 0. Ejemplos:
for(new v;v<=MAX_VEHICLES;v++) {
VGas[v] = 100;
}
o sino:
CMD:respawngeneral(playerid,params[])
{
for(new i = 1; i <= MAX_VEHICLES; i++)
{
SetVehicleToRespawn(i);
new MSG[126];
format(MSG,sizeof(MSG)," > "#CGRIS"Todos los vehнculos, han sido respawneados por "#CINFO"%s ( ID: %d )",NombreJugador(playerid),playerid);
MensajeTodos(-1,MSG);
return 1;
}
return 1;
}
Ese comando supuestamente respawnea todos, pero respawnea al auto id 0 nada mas :S
CMD
ajatodos(playerid,params[])
{
Loop(i,MAX_PLAYERS)
{
ApplyAnimation(i, "PAULNMAC", "wank_loop", 4.0, 1, 0, 0, 1, 0,true);
PlayerPlaySound(i, 1056, 0, 0, 0);
return 1;
}
return 1;
}
ese comando pajea al id cero, en vez de pajear a todos :S
Alguna soluciуn? Tambiйn uso sscanf, tiene algo uque ver?
PD:No se como poner los cуdigos en el foro para que se vean estilo pawn.
Respuesta: [ Problema ] Con loops -
iKeN - 27.04.2012
El problema era el 'return 1' dentro del loop.
pawn Код:
CMD:respawngeneral(playerid,params[])
{
for(new i; i <= MAX_VEHICLES; i++)SetVehicleToRespawn(i);
new MSG[126];
format(MSG,sizeof(MSG)," > "#CGRIS"Todos los vehнculos, han sido respawneados por "#CINFO"%s ( ID: %d )",NombreJugador(playerid),playerid);
MensajeTodos(-1,MSG);
return 1;
}
CMD:pajatodos(playerid,params[])
{
Loop(i,MAX_PLAYERS)
{
ApplyAnimation(i, "PAULNMAC", "wank_loop", 4.0, 1, 0, 0, 1, 0,true);
PlayerPlaySound(i, 1056, 0, 0, 0);
}
return 1;
}
Re: [ Problema ] Con loops -
spell - 27.04.2012
Ahh si era eso, muchas gracias