SA-MP Forums Archive
Server won't add components to vehicles on respawn. - 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: Server won't add components to vehicles on respawn. (/showthread.php?tid=397041)



Server won't add components to vehicles on respawn. - 9903286 - 03.12.2012

When a car is respawned it check it the vehicle id is equal to any of the players cars, and if it is, it's supposed to spawn it and add all mods to it. It spawns it, but do not add any components.
This is the code i've got so far:

Код:
public OnVehicleSpawn(vehicleid)
{
	for(new i=0;i<MAX_PLAYERS;i++)
	{
		if(vehicleid == PlayerCar[i])
		{
			printf("Found %d:s car with id: %d", i, vehicleid);
		    new file[256],
		    name[MAX_PLAYER_NAME+1],
		    vehicleid,
			spoiler,
			hood,
			roof,
			sideskirt,
			lamps,
			nitro,
			exhaust,
			wheels,
			stereo,
			hydraulics,
			frontbumper,
			rearbumper,
			ventright,
			ventleft;
			
   			GetPlayerName(i, name, sizeof(name));
		    format(file, sizeof(file), "%s.car", name);

			spoiler = dini_Int(file, "CARMODTYPE_SPOILER");
			hood = dini_Int(file, "CARMODTYPE_HOOD");
			roof = dini_Int(file, "CARMODTYPE_ROOF");
			sideskirt = dini_Int(file, "CARMODTYPE_SIDESKIRT");
			lamps = dini_Int(file, "CARMODTYPE_LAMPS");
			nitro = dini_Int(file, "CARMODTYPE_NITRO");
			exhaust = dini_Int(file, "CARMODTYPE_EXHAUST");
			wheels = dini_Int(file, "CARMODTYPE_WHEELS");
			stereo = dini_Int(file, "CARMODTYPE_STEREO");
			hydraulics = dini_Int(file, "CARMODTYPE_HYDRAULICS");
			frontbumper = dini_Int(file, "CARMODTYPE_FRONT_BUMPER");
			rearbumper = dini_Int(file, "CARMODTYPE_REAR_BUMPER");
			ventright = dini_Int(file, "CARMODTYPE_VENT_RIGHT");
			ventleft = dini_Int(file, "CARMODTYPE_VENT_LEFT");
		    
	     	if(spoiler != 0) {
				AddVehicleComponent(PlayerCar[i], spoiler);
				printf("Installed spoiler: %d", spoiler);
			}
	    	if(hood != 0) {
				AddVehicleComponent(PlayerCar[i], hood);
				printf("Installed hood: %d", hood);
			}
	    	if(roof != 0) {
				AddVehicleComponent(PlayerCar[i], roof);
				printf("Installed roof: %d", roof);
			}
	    	if(sideskirt != 0) {
				AddVehicleComponent(PlayerCar[i], sideskirt);
				printf("Installed sideskirt: %d", sideskirt);
			}
	    	if(lamps != 0) {
				AddVehicleComponent(PlayerCar[i], lamps);
				printf("Installed lamps: %d", lamps);
			}
	    	if(nitro != 0) {
				AddVehicleComponent(PlayerCar[i], nitro);
				printf("Installed nitro: %d", nitro);
			}
	    	if(exhaust != 0) {
				AddVehicleComponent(PlayerCar[i], exhaust);
				printf("Installed exhaust: %d", exhaust);
			}
	    	if(wheels != 0) {
				AddVehicleComponent(PlayerCar[i], wheels);
				printf("Installed wheels: %d", wheels);
			}
	    	if(stereo != 0) {
				AddVehicleComponent(PlayerCar[i], stereo);
				printf("Installed stereo: %d", stereo);
			}
	    	if(hydraulics != 0) {
				AddVehicleComponent(PlayerCar[i], hydraulics);
				printf("Installed hydraulics: %d", hydraulics);
			}
	    	if(frontbumper != 0) {
				AddVehicleComponent(PlayerCar[i], frontbumper);
				printf("Installed frontbumper: %d", frontbumper);
			}
	    	if(rearbumper != 0) {
				AddVehicleComponent(PlayerCar[i], rearbumper);
				printf("Installed rearbumper: %d", rearbumper);
			}
	    	if(ventright != 0) {
				AddVehicleComponent(PlayerCar[i], ventright);
				printf("Installed ventright: %d", ventright);
			}
	    	if(ventleft != 0) {
				AddVehicleComponent(PlayerCar[i], ventleft);
				printf("Installed ventleft: %d", ventleft);
			}
		}
	}
}
EDIT: Nevermind, it seems the problem was in the OnVehicleDeath.