SA-MP Forums Archive
Give back my components! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Give back my components! (/showthread.php?tid=237015)



Give back my components! - Riddick94 - 08.03.2011

Код:
 	components[0] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_SPOILER);
	components[1] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_HOOD);
	components[2] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_ROOF);
	components[3] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_SIDESKIRT);
    components[4] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_LAMPS);
    components[5] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_NITRO);
    components[6] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_EXHAUST);
    components[7] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_WHEELS);
    components[8] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_STEREO);
    components[9] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_STEREO);
    components[10] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_HYDRAULICS);
    components[11] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_REAR_BUMPER);
    components[12] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_VENT_RIGHT);
    components[13] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_VENT_LEFT);
    
    RemoveVehicleComponent(vehicleid, components[0]);
    RemoveVehicleComponent(vehicleid, components[1]);
    RemoveVehicleComponent(vehicleid, components[2]);
    RemoveVehicleComponent(vehicleid, components[3]);
    RemoveVehicleComponent(vehicleid, components[4]);
    RemoveVehicleComponent(vehicleid, components[5]);
    RemoveVehicleComponent(vehicleid, components[6]);
    RemoveVehicleComponent(vehicleid, components[7]);
    RemoveVehicleComponent(vehicleid, components[8]);
    RemoveVehicleComponent(vehicleid, components[9]);
    RemoveVehicleComponent(vehicleid, components[10]);
    RemoveVehicleComponent(vehicleid, components[11]);
    RemoveVehicleComponent(vehicleid, components[12]);
    RemoveVehicleComponent(vehicleid, components[13]);
    
    AddVehicleComponent(vehicleid, components[0]);
    AddVehicleComponent(vehicleid, components[1]);
    AddVehicleComponent(vehicleid, components[2]);
    AddVehicleComponent(vehicleid, components[3]);
    AddVehicleComponent(vehicleid, components[4]);
    AddVehicleComponent(vehicleid, components[5]);
    AddVehicleComponent(vehicleid, components[6]);
    AddVehicleComponent(vehicleid, components[7]);
    AddVehicleComponent(vehicleid, components[8]);
    AddVehicleComponent(vehicleid, components[9]);
    AddVehicleComponent(vehicleid, components[10]);
    AddVehicleComponent(vehicleid, components[11]);
    AddVehicleComponent(vehicleid, components[12]);
    AddVehicleComponent(vehicleid, components[13]);
Why not giving back my components? : /


Re: Give back my components! - Davz*|*Criss - 08.03.2011

Post full code.


Re: Give back my components! - Riddick94 - 08.03.2011

That's full.. ? you need new components[14]; ? lol. I need to give back components after vehicle respawn, that's all.

edit://
I tried with:
Код:
 	components[0] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_SPOILER));
	components[1] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_HOOD));
	components[2] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_ROOF));
	components[3] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_SIDESKIRT));
    components[4] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_LAMPS));
    components[5] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_NITRO));
    components[6] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_EXHAUST));
    components[7] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_WHEELS));
    components[8] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_STEREO));
    components[9] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_STEREO));
    components[10] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_HYDRAULICS));
    components[11] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_REAR_BUMPER));
    components[12] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_VENT_RIGHT));
    components[13] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), GetVehicleComponentType(CARMODTYPE_VENT_LEFT));
But nothing..


Re: Give back my components! - Davz*|*Criss - 08.03.2011

No man, i could not understand until you post full fs on www.pastebin.com, That would be easier to correct.


Re: Give back my components! - Riddick94 - 08.03.2011

Just.. save my components and put them back. You don't need to see my full code. It's only save and load.


Re: Give back my components! - Davz*|*Criss - 08.03.2011

Hmm which vehicle are you trying to add those components?


Re: Give back my components! - Davz*|*Criss - 08.03.2011

https://sampwiki.blast.hk/wiki/Function:AddVehicleComponent
https://sampwiki.blast.hk/wiki/GetVehicleComponentInSlot
https://sampwiki.blast.hk/wiki/RemoveVehicleComponent

This could help you.


Re: Give back my components! - Davz*|*Criss - 08.03.2011

Try this

pawn Код:
public OnVehicleSpawn(vehicleid)
{
    RemoveVehicleComponent(vehicleid, components[0]);
    RemoveVehicleComponent(vehicleid, components[1]);
    RemoveVehicleComponent(vehicleid, components[2]);
    RemoveVehicleComponent(vehicleid, components[3]);
    RemoveVehicleComponent(vehicleid, components[4]);
    RemoveVehicleComponent(vehicleid, components[5]);
    RemoveVehicleComponent(vehicleid, components[6]);
    RemoveVehicleComponent(vehicleid, components[7]);
    RemoveVehicleComponent(vehicleid, components[8]);
    RemoveVehicleComponent(vehicleid, components[9]);
    RemoveVehicleComponent(vehicleid, components[10]);
    RemoveVehicleComponent(vehicleid, components[11]);
    RemoveVehicleComponent(vehicleid, components[12]);
    RemoveVehicleComponent(vehicleid, components[13]);
    return 1;
}
Then this?

pawn Код:
public OnVehicleSpawn(vehicleid)
{
    AddVehicleComponent(vehicleid, components[0]);
    AddVehicleComponent(vehicleid, components[1]);
    AddVehicleComponent(vehicleid, components[2]);
    AddVehicleComponent(vehicleid, components[3]);
    AddVehicleComponent(vehicleid, components[4]);
    AddVehicleComponent(vehicleid, components[5]);
    AddVehicleComponent(vehicleid, components[6]);
    AddVehicleComponent(vehicleid, components[7]);
    AddVehicleComponent(vehicleid, components[8]);
    AddVehicleComponent(vehicleid, components[9]);
    AddVehicleComponent(vehicleid, components[10]);
    AddVehicleComponent(vehicleid, components[11]);
    AddVehicleComponent(vehicleid, components[12]);
    AddVehicleComponent(vehicleid, components[13]);
    return 1;
}



Re: Give back my components! - Stigg - 08.03.2011

Quote:
Originally Posted by Davz*|*Criss
Посмотреть сообщение
Try this

pawn Код:
public OnVehicleSpawn(vehicleid)
{
    RemoveVehicleComponent(vehicleid, components[0]);
    RemoveVehicleComponent(vehicleid, components[1]);
    RemoveVehicleComponent(vehicleid, components[2]);
    RemoveVehicleComponent(vehicleid, components[3]);
    RemoveVehicleComponent(vehicleid, components[4]);
    RemoveVehicleComponent(vehicleid, components[5]);
    RemoveVehicleComponent(vehicleid, components[6]);
    RemoveVehicleComponent(vehicleid, components[7]);
    RemoveVehicleComponent(vehicleid, components[8]);
    RemoveVehicleComponent(vehicleid, components[9]);
    RemoveVehicleComponent(vehicleid, components[10]);
    RemoveVehicleComponent(vehicleid, components[11]);
    RemoveVehicleComponent(vehicleid, components[12]);
    RemoveVehicleComponent(vehicleid, components[13]);
    return 1;
}
He wants to put back the components, not remove them.


Re: Give back my components! - Stigg - 08.03.2011

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
Код:
 	components[0] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_SPOILER);
	components[1] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_HOOD);
	components[2] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_ROOF);
	components[3] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_SIDESKIRT);
    components[4] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_LAMPS);
    components[5] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_NITRO);
    components[6] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_EXHAUST);
    components[7] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_WHEELS);
    components[8] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_STEREO);
    components[9] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_STEREO);
    components[10] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_HYDRAULICS);
    components[11] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_REAR_BUMPER);
    components[12] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_VENT_RIGHT);
    components[13] = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_VENT_LEFT);
    
    RemoveVehicleComponent(vehicleid, components[0]);
    RemoveVehicleComponent(vehicleid, components[1]);
    RemoveVehicleComponent(vehicleid, components[2]);
    RemoveVehicleComponent(vehicleid, components[3]);
    RemoveVehicleComponent(vehicleid, components[4]);
    RemoveVehicleComponent(vehicleid, components[5]);
    RemoveVehicleComponent(vehicleid, components[6]);
    RemoveVehicleComponent(vehicleid, components[7]);
    RemoveVehicleComponent(vehicleid, components[8]);
    RemoveVehicleComponent(vehicleid, components[9]);
    RemoveVehicleComponent(vehicleid, components[10]);
    RemoveVehicleComponent(vehicleid, components[11]);
    RemoveVehicleComponent(vehicleid, components[12]);
    RemoveVehicleComponent(vehicleid, components[13]);
    
    AddVehicleComponent(vehicleid, components[0]);
    AddVehicleComponent(vehicleid, components[1]);
    AddVehicleComponent(vehicleid, components[2]);
    AddVehicleComponent(vehicleid, components[3]);
    AddVehicleComponent(vehicleid, components[4]);
    AddVehicleComponent(vehicleid, components[5]);
    AddVehicleComponent(vehicleid, components[6]);
    AddVehicleComponent(vehicleid, components[7]);
    AddVehicleComponent(vehicleid, components[8]);
    AddVehicleComponent(vehicleid, components[9]);
    AddVehicleComponent(vehicleid, components[10]);
    AddVehicleComponent(vehicleid, components[11]);
    AddVehicleComponent(vehicleid, components[12]);
    AddVehicleComponent(vehicleid, components[13]);
Why not giving back my components? : /
Are you saving the components to file ?
That how i do my modded vehicles.