SA-MP Forums Archive
Spawn all the cars that should be spawned - 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: Spawn all the cars that should be spawned (/showthread.php?tid=308177)



Spawn all the cars that should be spawned - HondaCBR - 02.01.2012

Hell on my server cars which are spawned have Spawned=1, inside the UID.ini file.
I want to perform a check on gamemodeini. So that every car with Spawned=1 will be spawned. I got told this could cause a server lag but as its on gamemodeini there will not be anyone in the game yet is that right?

I came up with this but IDK what to add so it chceks trhough files 1000.ini, 1001.ini and so on until there is no files to check trhough. And so it doesnt use playerid as it needs to add the cars to map.
pawn Код:
new CarFile[35];
    for(new i = 1000; i < M_VEHICLES; i++)
    {
        format(CarFile,sizeof(CarFile),"Auta/%d.ini",i);
        if(dini_Int(CarFile,"Spawned") == 1)
        {
            Car[playerid][VehicleGameID] = CreateVehicle(dini_Int(CarFile,"ModelID"),dini_Float(CarFile,"X"),dini_Float(CarFile,"Y"),dini_Float(CarFile,"Z"),dini_Float(CarFile,"A"),dini_Int(CarFile,"Color1"),dini_Int(CarFile,"Color2"),-1);
            ChangeVehiclePaintjob(Car[playerid][VehicleGameID],dini_Int(CarFile,"Paintjob"));
            SetVehicleHealth(Car[playerid][VehicleGameID],dini_Float(CarFile,"Health"));
            UpdateVehicleDamageStatus(Car[playerid][VehicleGameID],dini_Int(CarFile,"Panels"),dini_Int(CarFile,"Doors"),dini_Int(CarFile,"Lights"),dini_Int(CarFile,"Tires"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"SPOILER"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"HOOD"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"ROOF"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"SIDESKIRT"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"LAMPS"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"NITRO"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"EXHAUST"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"WHEELS"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"STEREO"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"HYDRAULICS"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"FRONT_BUMPER"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"REAR_BUMPER"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"VENT_RIGHT"));
            AddVehicleComponent(Car[playerid][VehicleGameID],dini_Int(CarFile,"VENT_LEFT"));
        }
    }