Looping problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Looping problem (
/showthread.php?tid=503397)
Looping problem -
Dusan01 - 29.03.2014
Hi guys, i have problem with looping.
here is code:
Код:
for(new i = 0; i < sizeof(PI); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, PI[i][pPozx], PI[i][pPozy], PI[i][pPozz]))
{
SCM(playerid,-1,"Works!");
return 1;
}
else return SCM(playerid,-1,"Not near");
}
and i have file Ass_0.ini
and Ass_1.ini
and when i come to x,y,z of Ass_0 it says works!
and when i come to x,y,z of Ass_1 it dont work just print Not Near
Re: Looping problem -
Pottus - 29.03.2014
Pretty obvious that code can only ever do one loop because of the return in the else
Re: Looping problem -
Dusan01 - 29.03.2014
Quote:
Originally Posted by [uL]Pottus
Pretty obvious that code can only ever do one loop because of the return in the else
|
so how can i make it to work perfect?
Re: Looping problem -
Lidor124 - 29.03.2014
Quote:
Originally Posted by Dusan01
so how can i make it to work perfect?
|
There you go:
Код:
for(new i = 0; i < sizeof(PI); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, PI[i][pPozx], PI[i][pPozy], PI[i][pPozz]))
{
SCM(playerid,-1,"Works!");
}
else
{
SCM(playerid,-1,"Not near");
}
return 1;
}
Re: Looping problem -
iBeast - 29.03.2014
here is code:
pawn Код:
for(new i = 0; i < sizeof(PI); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, PI[i][pPozx], PI[i][pPozy], PI[i][pPozz]))
{
SCM(playerid,-1,"Works!");
} else return SCM(playerid,-1,"Not near");
}
^That might help.
P.S using SCM instead of SendClientMessage is a bad scripting habit.
EDIT: Meh! I was slow D:
Re: Looping problem -
Dusan01 - 29.03.2014
@Lidor124
Yes but when im near file Ass_0 it just print Works, but when im near Ass_1 i first print not near the works :S
Re: Looping problem -
Pottus - 29.03.2014
These guys solutions are all retarded.
pawn Код:
for(new i = 0; i < sizeof(PI); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, PI[i][pPozx], PI[i][pPozy], PI[i][pPozz]))
return SCM(playerid,-1,"Works!");
}
return SCM(playerid,-1,"Not near");
Re: Looping problem -
Dusan01 - 29.03.2014
Quote:
Originally Posted by [uL]Pottus
These guys solutions are all retarded.
pawn Код:
for(new i = 0; i < sizeof(PI); i++) { if(IsPlayerInRangeOfPoint(playerid, 5.0, PI[i][pPozx], PI[i][pPozy], PI[i][pPozz])) return SCM(playerid,-1,"Works!"); } return SCM(playerid,-1,"Not near");
|
Thanks bro REP+