SA-MP Forums Archive
AddVehicleComponent not showing after respawn [HELP] - 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: AddVehicleComponent not showing after respawn [HELP] (/showthread.php?tid=620580)



AddVehicleComponent not showing after respawn [HELP] - catal4n - 31.10.2016

Alright so the problem is when i mod a car, it doesn't matter if transfender or another modshop, it saves when i park the car, but when i use /respawn or if the car broke and respawns the mods are not showing.

Here is the OnVehicleSpawn
Код:
public OnVehicleSpawn(vehicleid)
{

	if(vehicleid != 509 && vehicleid != 481 && vehicleid != 510)
	{
	    SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
		foreach(Player, i)
		{
		    if(vehicleid == PlayerInfo[i][pVeh])
		    {
		        if(PlayerInfo[i][vLocked]) SetVehicleParamsEx(vehicleid, 0, 0, 0, 1, 0, 0, 0);
	                ChangeVehicleColor(PlayerInfo[i][pVeh], PlayerInfo[i][vC1], PlayerInfo[i][vC2]);
				for(new x=0; x<14; i++)
				{
					AddVehicleComponent(PlayerInfo[i][pVeh], PlayerInfo[i][pVehMod][x]);
				}
		    }
		    if(vehicleid == PlayerInfo[i][pVVeh])
		    {
		        if(PlayerInfo[i][vVLocked]) SetVehicleParamsEx(vehicleid, 0, 0, 0, 1, 0, 0, 0);
	                ChangeVehicleColor(PlayerInfo[i][pVVeh], PlayerInfo[i][vVC1], PlayerInfo[i][vVC2]);
				for(new x=0; x<14; i++)
				{
                    AddVehicleComponent(PlayerInfo[i][pVVeh], PlayerInfo[i][pVVehMod][x]);
				}
		    }
		    if(vehicleid == PlayerInfo[i][pBVeh])
		    {
		        if(PlayerInfo[i][vBLocked]) SetVehicleParamsEx(vehicleid, 0, 0, 0, 1, 0, 0, 0);
                       ChangeVehicleColor(PlayerInfo[i][pBVeh], PlayerInfo[i][vBC1], PlayerInfo[i][vBC2]);
				for(new x=0; x<14; i++)
				{
				    AddVehicleComponent(PlayerInfo[i][pBVeh], PlayerInfo[i][pBVehMod][x]);
				}
		    }
		}
		if(IsTruckerVehicle(vehicleid))
		{
		    TruckPackages[vehicleid] = -1;
		}
		if(Siren[vehicleid])
		{
			Siren[vehicleid] = 0;
	        DestroyDynamicObject(SirenObject[vehicleid]);
	        DestroyDynamicObject(LightObject1[vehicleid]);
        }
    }
	return 1;
}



Re: AddVehicleComponent not showing after respawn [HELP] - X337 - 31.10.2016

Add this code in your script.
Код:
public OnVehicleMod(playerid, vehicleid, componentid)
{
    if(vehicleid == PlayerInfo[playerid][pVeh])
        PlayerInfo[playerid][pVehMod][GetVehicleComponentType(componentid)] = componentid;
    if(vehicleid == PlayerInfo[playerid][pVVeh])
        PlayerInfo[playerid][pVVehMod][GetVehicleComponentType(componentid)] = componentid;
    if(vehicleid == PlayerInfo[playerid][pBVeh])
    	PlayerInfo[playerid][pBVehMod][GetVehicleComponentType(componentid)] = componentid;
    
	return 1;
}
That code will assign the componentid of the mods into vehicle mods variable


Re: AddVehicleComponent not showing after respawn [HELP] - catal4n - 31.10.2016

I tryied but is still not working.


Re: AddVehicleComponent not showing after respawn [HELP] - catal4n - 01.11.2016

I think the problem is still from OnVehicleSpawn i am not pretty sure.


Re: AddVehicleComponent not showing after respawn [HELP] - catal4n - 01.11.2016

Anyone got an idea?


Re: AddVehicleComponent not showing after respawn [HELP] - Sew_Sumi - 01.11.2016

Read the forum rules please... 24 hour bumps only.


Re: AddVehicleComponent not showing after respawn [HELP] - catal4n - 02.11.2016

Bump.


Re: AddVehicleComponent not showing after respawn [HELP] - Sew_Sumi - 03.11.2016

Try using printf statements to show what is being "saved" as it may not be saving.

Or have you checked the file/db that it's saving to?


Re: AddVehicleComponent not showing after respawn [HELP] - catal4n - 03.11.2016

The problem is that the mod are saving i've tryied to save the car and restart the server. Car mods are saving but if i use /respawn to respawn all cars or just the car only the mods disspears.. also even if the car blows or if i throw it in the water.


Re: AddVehicleComponent not showing after respawn [HELP] - Sew_Sumi - 03.11.2016

Quote:
Originally Posted by catal4n
Посмотреть сообщение
The problem is that the mod are saving i've tryied to save the car and restart the server. Car mods are saving but if i use /respawn to respawn all cars or just the car only the mods disspears.. also even if the car blows or if i throw it in the water.
How exactly do you know it's saving? You haven't exactly answered what I asked...


Have you actually checked that the information is being saved to the players account?