How do I print it several times? (As many times as files) - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: How do I print it several times? (As many times as files) (
/showthread.php?tid=188610)
How do I print it several times? (As many times as files) -
Kyle_Olsen - 08.11.2010
Hi there.
I want the code below to be posted as many times as it is files in the folder Vehicles (1 time is only Vehicle_1.ini 2 times if Vehicle_1.ini and Vehicle_2.ini exists and so on) and have the right stuff for all of it, is there an easy way to do this? (exept from making the codes several times)
Code:
new vehfile1[256];
format(vehfile1, sizeof(vehfile1), "Vehicles/Vehicle_1.ini");
if(dini_Exists(vehfile1))
{
new VehInfo1;
VehInfo1 = dini_Int(vehfile1, "Owner");
new VehInfo2;
VehInfo2 = dini_Int(vehfile1, "Faction");
new VehInfo3;
VehInfo3 = dini_Int(vehfile1, "X");
new VehInfo4;
VehInfo4 = dini_Int(vehfile1, "Y");
new VehInfo5;
VehInfo5 = dini_Int(vehfile1, "Z");
new VehInfo6;
VehInfo6 = dini_Int(vehfile1, "Zangle");
new VehInfo7;
VehInfo7 = dini_Int(vehfile1, "Locked");
new VehInfo8;
VehInfo8 = dini_Int(vehfile1, "Plate");
new VehInfo9;
VehInfo9 = dini_Int(vehfile1, "Model");
new VehInfo10;
VehInfo10 = dini_Int(vehfile1, "Color1");
new VehInfo11;
VehInfo11 = dini_Int(vehfile1, "Color2");
CreateVehicle(VehInfo9, VehInfo3, VehInfo4, VehInfo5, VehInfo6, VehInfo10, VehInfo11, 10800);
print("Vehicle 1 initiated");
}
Re: How do I print it several times? (As many times as files) -
rbN. - 08.11.2010
EDIT: Oh, I now get it.. Use loops..
#define MAX_CARS (amount of cars you got)
for (new i = 0; i < MAX_CARS; i++)
{
}
^ explanation: i = 0, and when i is lower then MAX_CARS, then i goes up. So if MAX_CARS is 4, it does 0, 1, 2, 3.
Re: How do I print it several times? (As many times as files) -
Kyle_Olsen - 08.11.2010
Thanks man!