SA-MP Forums Archive
loop + rep - 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: loop + rep (/showthread.php?tid=519181)



loop + rep - iBots - 13.06.2014

hey,well,i got a code,for cars,it checks if the vehicle id is owned by the player id you write,but here is the code of it:
pawn Код:
new id = PlayerInfo[playerid][pCar][0], id2 = PlayerInfo[playerid][pCar][1], id3 = PlayerInfo[playerid][pCar][2];
            if(veh != CarInfo[id][c_ID] && veh != CarInfo[id2][c_ID] && veh != CarInfo[id3][c_ID]){
            if(CarInfo[PlayerInfo[playerid][pKeys]][c_ID] != veh){
                return 1;
            }
        }
it checks if player's car 1 or 2 or 3 is the vehicle id,but i have changed it to 20,how can i loop them so if any car of his cars,from 0 to 20 is that vehicle id,it notices?


Re: loop + rep - Amrev - 13.06.2014

pawn Код:
for(new i=0;i<MAX_PLAYERS;i++)
{
            new id = PlayerInfo[i][pCar][0], id2 = PlayerInfo[i][pCar][1], id3 = PlayerInfo[i][pCar][2];
            if(veh != CarInfo[id][c_ID] && veh != CarInfo[id2][c_ID] && veh != CarInfo[id3][c_ID]){
            if(CarInfo[PlayerInfo[i][pKeys]][c_ID] != veh) return 1;
}



Re: loop + rep - iBots - 13.06.2014

read the post again


Re: loop + rep - Ciandlah - 13.06.2014

If you have changed the selection from 0 - 3 to 0 - 20 - You need to add the new ID's that it checks, for example.

veh != CarInfo[id][c_ID]
veh != CarInfo[id1][c_ID]
veh != CarInfo[id2][c_ID]
veh != CarInfo[id3][c_ID]
veh != CarInfo[id4][c_ID]
veh != CarInfo[id5][c_ID]
veh != CarInfo[id6][c_ID]
veh != CarInfo[id7][c_ID]
veh != CarInfo[id8][c_ID]


Re: loop + rep - iBots - 13.06.2014

is there any way to loop them all together,so it do be 1 line instead of 20?


Re: loop + rep - Ciandlah - 13.06.2014

You can, however I don't want to code something that you wont understand - If you try make one and post it below then ill fix it for ya


Re: loop + rep - iBots - 13.06.2014

lol no,i am not that noob to do not understand the code,just try to code it for me...


Re: loop + rep - Ciandlah - 13.06.2014

Well First You Will Have To Define The IDS anyway so good luck adding them

Then just change the second line to this

Quote:

if(veh < != CarInfo[id][c_ID] || veh > != CarInfo[id20][c_ID])