Vehicle Component help. -
RayPoda - 22.06.2009
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
//=============[Vehicle Components on State Change]=================
if (newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if (vehicleid == quad1)
{
AddVehicleComponent(quad1, 1010);
AddVehicleComponent(quad1, 1074);
}
if (vehicleid == sultan1)
{
AddVehicleComponent(sultan1, 1010);
AddVehicleComponent(sultan1, 1169);
AddVehicleComponent(sultan1, 1140);
AddVehicleComponent(sultan1, 1139);
AddVehicleComponent(sultan1, 1029);
AddVehicleComponent(sultan1, 1031);
AddVehicleComponent(sultan1, 1030);
}
if (vehicleid == quad2)
{
AddVehicleComponent(quad2, 1010);
AddVehicleComponent(quad2, 1074);
}
if (vehicleid == sultan2)
{
AddVehicleComponent(sultan2, 1010);
AddVehicleComponent(sultan2, 1169);
AddVehicleComponent(sultan2, 1140);
AddVehicleComponent(sultan2, 1139);
AddVehicleComponent(sultan2, 1029);
AddVehicleComponent(sultan2, 1031);
AddVehicleComponent(sultan2, 1030);
}
}
if (newstate == PLAYER_STATE_ONFOOT)
{
new vehicleid = GetPlayerVehicleID(playerid);
if (vehicleid == quad1)
{
RemoveVehicleComponent(quad1, 1010);
RemoveVehicleComponent(quad1, 1074);
}
if (vehicleid == sultan1)
{
RemoveVehicleComponent(sultan1, 1010);
RemoveVehicleComponent(sultan1, 1169);
RemoveVehicleComponent(sultan1, 1140);
RemoveVehicleComponent(sultan1, 1139);
RemoveVehicleComponent(sultan1, 1029);
RemoveVehicleComponent(sultan1, 1031);
RemoveVehicleComponent(sultan1, 1030);
}
if (vehicleid == quad2)
{
RemoveVehicleComponent(quad2, 1010);
RemoveVehicleComponent(quad2, 1074);
}
if (vehicleid == sultan2)
{
RemoveVehicleComponent(sultan2, 1010);
RemoveVehicleComponent(sultan2, 1169);
RemoveVehicleComponent(sultan2, 1140);
RemoveVehicleComponent(sultan2, 1139);
RemoveVehicleComponent(sultan2, 1029);
RemoveVehicleComponent(sultan2, 1031);
RemoveVehicleComponent(sultan2, 1030);
}
}
return 1;
}
Well, that is my code, and when you enter the vehicles the components get added on, but when you exit.. they don't get removed. I don't know why, If anyone of you could help me, that would be wonderful. Thank you.
P.S: Sorry that the indenting is messed up, that's not how it is in my script.
Re: Vehicle Component help. -
Grim_ - 22.06.2009
Just do
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(vehicleid == quad1)
{
RemoveVehicleComponent(vehicleid, componentid);
}
return 1;
}
Re: Vehicle Component help. -
RayPoda - 22.06.2009
Doesn't help much. I want to make it work for ALL vehicles that have components added to them when i get in them.
Re: Vehicle Component help. -
Grim_ - 22.06.2009
Just keep checking if the vehiclei equals the variable, if it does, remove the component.
Re: Vehicle Component help. -
RayPoda - 22.06.2009
Alright thanks.
EDIT: I've just tried OnPlayerVehicleExit and it works great. Thanks for the help, bro.
Re: Vehicle Component help. -
Grim_ - 22.06.2009
No problem, glad I could help
Re: Vehicle Component help. -
Haron - 22.06.2009
make sure that player is a driver
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(vehicleid == quad1 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
RemoveVehicleComponent(vehicleid, componentid);
}
return 1;
}