18.09.2012, 00:03
PHP код:
stock SpawnVehicleForPlayer(vehicleid, playerid)
{
if(SpawnedVehicle[playerid] != 0)
{
//Check, if player spawned any vehicle
DestroyVehicle(SpawnedVehicle[playerid]);
//Destroy it
}
new Float:X, Float:Y, Float:Z, Float:Angle;
//Variable to save playerґs X,Y,Z and angle
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
//Get player positions and save it to variables
GetPlayerFacingAngle(playerid, Float:Angle);
//Get player facing angle and save it to variable
SpawnedVehicle[playerid] = CreateVehicle(vehicleid, X, Y, Z + 2.0, Angle + 90.0, -1, -1, 600);
//Spawn vehicle with random color in front of player
SetVehicleVirtualWorld(SpawnedVehicle[playerid], GetPlayerVirtualWorld(playerid));
//Set vehicle virtual world to player virtual world
LinkVehicleToInterior(SpawnedVehicle[playerid], GetPlayerInterior(playerid));
//Set vehicle interior to player interior
PutPlayerInVehicle(playerid, SpawnedVehicle[playerid], 0);
//Put player to spawned vehicle as driver
}