SA-MP Forums Archive
vehicle spawn facing angle - 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: vehicle spawn facing angle (/showthread.php?tid=612347)



vehicle spawn facing angle - kbalor - 16.07.2016

Can someone please help me fix this one. I'm trying to spawn my vehicle to the same angle as the player.

Код:
function CarSpawner( playerid, model )
{
    	new
			Float:x,
			Float:y,
			Float:z,
			Float:angle
		;

	 	GetPlayerPos( playerid, x, y, z );
	 	GetPlayerFacingAngle( playerid, angle );

		if ( PlayerInfo[ playerid ][ pCar ] != -1 )
			CarDeleter( PlayerInfo[ playerid ][ pCar ] );
	    new
			vehicleid = CreateVehicle( model, x, y, z, angle, -1, -1, -1 )
		;
		SetVehicleVirtualWorld( vehicleid, GetPlayerVirtualWorld( playerid ) );
		LinkVehicleToInterior( vehicleid, GetPlayerInterior( playerid ) );
		PutPlayerInVehicle( playerid, vehicleid, 0 );
		SetVehicleNumberPlate( vehicleid, "{00FF00}R{FF0000}F{00FF00}S" );
		ChangeVehicleColor( vehicleid, 0,7 );
        PlayerInfo[ playerid ][ pCar ] = vehicleid;
		DestroyVehicle( SecV[playerid] );
        Delete3DTextLabel(pCar3D[ SecV[playerid] ]);
		return ( 1 );
}

function CarDeleter( vehicleid )
{
    foreach( Player, i )
	{
        new
			Float:X,
			Float:Y,
			Float:Z
		;

    	if ( IsPlayerInVehicle( i, vehicleid ) )
		{
    	    RemovePlayerFromVehicle( i );
    	    GetPlayerPos( i, X, Y, Z);
	    }
	    SetVehicleParamsForPlayer( vehicleid, i, 0, 1 );
	}
	VehRes (vehicleid);
    return ( 1 );
}



Re: vehicle spawn facing angle - Matz - 16.07.2016

Код:
function CarSpawner( playerid, model )
{
    	new
			Float:x,
			Float:y,
			Float:z,
			Float:angle
		;

	 	GetPlayerPos( playerid, x, y, z );
	 	GetPlayerFacingAngle( playerid, angle );

		if ( PlayerInfo[ playerid ][ pCar ] != -1 )
			CarDeleter( PlayerInfo[ playerid ][ pCar ] );
	    new
			vehicleid = CreateVehicle( model, x, y, z, angle, -1, -1, -1 )
		;
		SetVehicleVirtualWorld( vehicleid, GetPlayerVirtualWorld( playerid ) );
		LinkVehicleToInterior( vehicleid, GetPlayerInterior( playerid ) );
		PutPlayerInVehicle( playerid, vehicleid, 0 );
SetVehicleZAngle(vehicleid, angle);
		SetVehicleNumberPlate( vehicleid, "{00FF00}R{FF0000}F{00FF00}S" );
		ChangeVehicleColor( vehicleid, 0,7 );
        PlayerInfo[ playerid ][ pCar ] = vehicleid;
		DestroyVehicle( SecV[playerid] );
        Delete3DTextLabel(pCar3D[ SecV[playerid] ]);
		return ( 1 );
}



Re: vehicle spawn facing angle - kbalor - 16.07.2016

EDIT:

MATZ Problem. It's not working. It keeps spawning at the angle N. North minimap.

EDIT2:
On foot it doesn't work
But when i'm inside the vehicle then I spawned a veh then its good.


Re: vehicle spawn facing angle - Matz - 16.07.2016

Quote:
Originally Posted by kbalor
Посмотреть сообщение
EDIT:

MATZ Problem. It's not working. It keeps spawning at the angle N. North minimap.

EDIT2:
On foot it doesn't work
But when i'm inside the vehicle then I spawned a veh then its good.
Angle gets updated if player is in the vehicle, so yes


Re: vehicle spawn facing angle - kbalor - 16.07.2016

oh thanks I got it. Also the problem was there's an special vehicle that doesn't link with the CarSpawner function that is why it keeps facing the North. Ill figure it out +rep


Re: vehicle spawn facing angle - kbalor - 17.07.2016

Problem still exists. When im in vehicle and I spawned a new one it didn't pick my current facing angle.

Код:
function CarSpawner( playerid, model )
{
    	new Float:x,Float:y,Float:z, Float:angle;

	 	GetPlayerPos( playerid, x, y, z );
	 	GetPlayerFacingAngle( playerid, angle );

		if ( PlayerInfo[ playerid ][ pCar ] != -1 )
			CarDeleter( PlayerInfo[ playerid ][ pCar ] );
	    new vehicleid = CreateVehicle( model, x, y, z, angle, -1, -1, -1 );
  		SetVehiclePos(vehicleid, x, y, z);
        SetVehicleZAngle(vehicleid, angle);
        
		SetVehicleVirtualWorld( vehicleid, GetPlayerVirtualWorld( playerid ) );
		LinkVehicleToInterior( vehicleid, GetPlayerInterior( playerid ) );
		PutPlayerInVehicle( playerid, vehicleid, 0 );
		SetVehicleNumberPlate( vehicleid, "{00FF00}R{FF0000}F{00FF00}S" );
        PlayerInfo[ playerid ][ pCar ] = vehicleid;
		DestroyVehicle( SecV[playerid] );
        Delete3DTextLabel(pCar3D[ SecV[playerid] ]);
		return ( 1 );
}