SA-MP Forums Archive
Creating vehicles D: - 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: Creating vehicles D: (/showthread.php?tid=549493)



Creating vehicles D: - TheLittleFucker - 07.12.2014

I'm creating vehicles and giving the vehicles certain number plates and components, but whenever the vehicle respawns none components will respawn with it. The number plate will stay, but other components will, ex: switch rims and nos.

Will rep if you can help me


Код:
AddStaticVehicle(415, 302.6047,-1430.4603,23.7242,121.2631, 0, 0, 60);
AddVehicleComponent(18, 1080);
AddVehicleComponent(18, 1010);
SetVehicleNumberPlate(18, "Test");



Re: Creating vehicles D: - DrumYum - 07.12.2014

You must save components by yourself and then load in when vehicle respawns, in OnVehicleSpawn.

Example:
Код:
new bool: VehicleNitro[MAX_VEHICLES];

public OnPlayerCommand(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/nitro"))
	{
		if(!IsPlayerInAnyVehicle(playerid) || GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You can't add nitro!");
		
		VehicleNitro[GetPlayerVehicleID(playerid)] = true;
		AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
		return true;
	}
	return false;
}

public OnVehicleSpawn(vehicleid)
{
	if(VehicleNitro[vehicleid]) AddVehicleComponent(vehicleid, 1010);
	return true;
}



Re: Creating vehicles D: - ATGOggy - 07.12.2014

This is how to do it:
PHP код:
new vehicle=AddStaticVehicle(415302.6047,-1430.4603,23.7242,121.26310060);
AddVehicleComponent(vehicle1080);
AddVehicleComponent(vehicle1010);
SetVehicleNumberPlate(vehicle"Test");