SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Thread Tools Display Modes
Old 11/01/2015, 03:40 PM   #1
Big Clucker
Join Date: Oct 2013
Posts: 171
Reputation: 11
Default Array loop

Hi, i need help with looping arrays.
So when i have 50 Objects and i want to do like this:
pawn Code:
Object[0] = CreateObject...
Object[50] = CreateObject...

And Later i want
pawn Code:
if(IsPlayerInRangeOfPoint(i, 1, ObjectX[0], ObjectY[0], ObjectZ[0]))
else if(IsPlayerInRangeOfPoint(i, 1, ObjectX[1], ObjectY[1], ObjectZ[1]))
else if(IsPlayerInRangeOfPoint(i, 1, ObjectX[50], ObjectY[50], ObjectZ[50]))

So it's very boring and can i use loop to do this?
finelaq is offline   Reply With Quote
Old 11/01/2015, 04:10 PM   #2
Big Clucker
Join Date: Nov 2014
Posts: 161
Reputation: 19
Default Re: Array loop

for(new i = 0; i < sizeof(Object); i++) // 'Object' is your array
     new Float:X, Float:Y, Float:Z;
     GetObjectPos(Object[i], X, Y, Z);
     if(IsPlayerInRangeOfPoint(playerid, 1, X, Y, Z);
Divergent is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Array + Loop Manyula Scripting Help 6 04/07/2014 10:59 PM
[Help] Loop in array bugsy94 Scripting Help 16 13/02/2014 12:37 PM
Array w/ Strings Loop MsgtHill Scripting Help 4 07/11/2013 03:26 PM
Returning Vehicle ID in an array (with loop) causes 'not continueing' Jochemd Help Archive 11 15/05/2011 02:40 PM

All times are GMT. The time now is 05:57 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.