Example: I drive nrg-500 with 156km/h and then I spawn my Infernus and it drive forward with same (156km/h) speed.
Код:
stock SpawnPlayerVehicle(playerid,ModelID)
{
new Float:xPos,Float:yPos,Float:zPos,Float:Ang,Float:xVel,Float:yVel,Float:zVel;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleVelocity(playerid,xVel,yVel,zVel);
}
else
{
GetPlayerVelocity(playerid,xVel,yVel,zVel);
}
GetPlayerPos(playerid,xPos,yPos,zPos);
GetPlayerFacingAngle(playerid,Ang);
DestroyVehicle(Player[playerid][Vehicle]);
Player[playerid][Vehicle] = CreateVehicle(ModelID,xPos,yPos,zPos + 1,Ang,-1,-1,0);
SetVehicleVirtualWorld(Player[playerid][Vehicle],GetPlayerVirtualWorld(playerid));
PutPlayerInVehicle(playerid,Player[playerid][Vehicle],0);
SetVehicleVelocity(Player[playerid][Vehicle],xVel,yVel,zVel);
SetPlayerVelocity(playerid,xVel,yVel,zVel);
format(String,sizeof(String),"~w~Here is your ~r~%s",GetVehicleName(ModelID));
GameTextForPlayer(playerid,String,5000,3);
PlayerPlaySound(playerid,1056,0,0,0);
return 1;
}
Please post edited working(tested) code because I have a lot of maps which I need this. Please help.