SA-MP Forums Archive
Unreachable code...why? - 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: Unreachable code...why? (/showthread.php?tid=579391)



Unreachable code...why? - OGKush - 26.06.2015

It's so frustrating...I made all that code good,why the hell doesn't work?

So,I made 377 houses on my server,I put 1000 cuz I'll make more and here's the frustrating part...If I'm near of one house,in returns that message with the ID of the house...if I'm not near of any house,it says me this "SERVER:Unknown command!",instead of the message "-1" from the last return.Why?

CMD:inrange(playerid,params[])
{
new str[10];
for(new i=1;i<=1000;i++)
{
if(IsPlayerInRangeOfPoint(playerid,1.0,house_spawn _x[i],house_spawn_y[i],house_spawn_z[i]))
{
format(str,10,"%i",i);
return SendClientMessage(playerid,-1,str);
}
}
return SendClientMessage(playerid,-1,"-1");
}


Re: Unreachable code...why? - Larceny - 26.06.2015

What's the size of the arrays: house_spawn _x, ,house_spawn_y and ,house_spawn_z?


Re: Unreachable code...why? - OGKush - 26.06.2015

Ohhh...thanks,man,you're a hero!) I wasn't concentrate and I forgot them 500,but then I tried with 1000,doesn't worked...and I put 1100 and works!) Probably it works with 1001 minimum,because I don't use the 0 index...thanks again! I was thinking it doesn't mater the array size in the for loop!