Vehicle Modifications
#1

Basically I've scripted it so that players can save modifications, bumper, spoiler etc to their vehicle. Everything works, accept when the car blows up, it doesn't seem to put the mods back on their vehicle.

When they log in, it adds the modifications to their vehicle with a function that I've made

Code:
AddVehicleModifications(playerid);
That's under the selection where it creates the players vehicle when they log in.

Like I said everything is working. But when the vehicle gets blown up and respawns, the modifications are no longer on their vehicle..

Code:
	PlayerInfo[playerid][pHouseCarID] = CreateVehicle(housecar,PlayerInfo[playerid][pHouseCarX],PlayerInfo[playerid][pHouseCarY],PlayerInfo[playerid][pHouseCarZ],PlayerInfo[playerid][pHouseCarFacing],PlayerInfo[playerid][pHouseCarColor],PlayerInfo[playerid][pHouseCarColor2],180000);
	AddVehicleModifications(playerid);
Code:
public AddVehicleModifications(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pSpoiler]);
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pHood]);
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pRoof]);
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pSideskirt]);
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pLamps]);
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pExhaust]);
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pWheels]);
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pBumperF]);
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pBumperR]);
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pVentR]);
		AddVehicleComponent(PlayerInfo[playerid][pHouseCarID],PlayerInfo[playerid][pVentL]);
	}
	return 1;
}
Can anyone help me figure out what I need to do in order for the modifications to add themselves back to the vehicle after it respawns?

I've tried a function on "OnVehicleSpawn". However, it does nothing.
Reply
#2

Use loop in OnVehicleSpawn

Example:
pawn Code:
Loop(i)
{
    if(vehicleid == PlayerInfo[i][pHouseCarID])
    {
        AddVehicleModifications(i);
        break;
    }
}
Reply
#3

Quote:
Originally Posted by Jefff
View Post
Use loop in OnVehicleSpawn

Example:
pawn Code:
Loop(i)
{
    if(vehicleid == PlayerInfo[i][pHouseCarID])
    {
        AddVehicleModifications(i);
        break;
    }
}
Replace "Loop(i)" with something like

Code:
	for(new i=0;i<MAX_PLAYERS;i++)
	{
?
Reply
#4

Nevermind. it worked. Hardcore bro thanks man. Rep+1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)