OnUnoccupiedVehicleUpdate

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 23:22, 14 August 2014
PT (Talk | contribs)
(fix an small error i let on past)
← Previous diff
Revision as of 21:35, 16 August 2014
Ikkentim (Talk | contribs)

Next diff →
Line 18: Line 18:
{{Param|new_y|The new Y coordinate of the vehicle. This parameter was added in 0.3z. Leave it out if using an earlier version.}} {{Param|new_y|The new Y coordinate of the vehicle. This parameter was added in 0.3z. Leave it out if using an earlier version.}}
{{Param|new_z|The new Z coordinate of the vehicle. This parameter was added in 0.3z. Leave it out if using an earlier version.}} {{Param|new_z|The new Z coordinate of the vehicle. This parameter was added in 0.3z. Leave it out if using an earlier version.}}
-{{Param|vel_x|The new vel X coordinate of the vehicle. This parameter was added in 0.3z R4. Leave it out if using an earlier version.}}+{{Param|vel_x|The new X velocity of the vehicle. This parameter was added in 0.3z R4. Leave it out if using an earlier version.}}
-{{Param|vel_y|The new vel Y coordinate of the vehicle. This parameter was added in 0.3z R4. Leave it out if using an earlier version.}}+{{Param|vel_y|The new Y velocity of the vehicle. This parameter was added in 0.3z R4. Leave it out if using an earlier version.}}
-{{Param|vel_z|The new vel Z coordinate of the vehicle. This parameter was added in 0.3z R4. Leave it out if using an earlier version.}}+{{Param|vel_z|The new Z velocity of the vehicle. This parameter was added in 0.3z R4. Leave it out if using an earlier version.}}
{{Returns|Returning '''0''' in this callback will stop the vehicle syncing its position to other players.}} {{Returns|Returning '''0''' in this callback will stop the vehicle syncing its position to other players.}}

Revision as of 21:35, 16 August 2014



OnUnoccupiedVehicleUpdate was added in SA-MP 0.3c This callback was added in SA-MP 0.3c R3 and will not work in earlier versions!


Description:

This callback is called every time an unoccupied vehicle updates the server with its status, for example when a player nudges a vehicle on their client, it is synced to the server (and then other players).


Image:32px-Circle-style-warning.png

Important
Note

This callback is called very frequently per second per unoccupied vehicle. You should refrain from implementing intensive calculations or intensive file writing/reading operations in this callback.


Image:32px-Circle-style-warning.png

Important
Note

In SA-MP 0.3c - SA-MP 0.3x, this callback does not have the respective parameters (Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z). They were only added in SA-MP 0.3z, so for backwards compatibility, remember this.


Description:

This callback is called when a player updates the position of a vehicle they're not driving. This can happen outside of the vehicle or when the player is a passenger of a vehicle that has no driver.


Parameters:
(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
vehicleidThe vehicleid that the callback is processing
playeridThe playerid that the callback is processing (the playerid affecting the vehicle)
passenger_seatThe passenger seat of the playerid moving the vehicle. 0 if they're not in the vehicle.
new_xThe new X coordinate of the vehicle. This parameter was added in 0.3z. Leave it out if using an earlier version.
new_yThe new Y coordinate of the vehicle. This parameter was added in 0.3z. Leave it out if using an earlier version.
new_zThe new Z coordinate of the vehicle. This parameter was added in 0.3z. Leave it out if using an earlier version.
vel_xThe new X velocity of the vehicle. This parameter was added in 0.3z R4. Leave it out if using an earlier version.
vel_yThe new Y velocity of the vehicle. This parameter was added in 0.3z R4. Leave it out if using an earlier version.
vel_zThe new Z velocity of the vehicle. This parameter was added in 0.3z R4. Leave it out if using an earlier version.


Return Values:

Returning 0 in this callback will stop the vehicle syncing its position to other players.


  • seat numbers: 0 if they're not in the vehicle, 1 for front-right passenger, rear row: 2 left and 3 right = rear seats passengers for 4-door vehicle. NEVER sent as a driver, this is not same as data in GetPlayerVehicleSeat
Tip

Image:Light_bulb_icon.png

GetVehiclePos will give the old coordinates of the vehicle before this update.



Example Usage:

public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
{
    GetVehiclePos(vehicleid, new_x, new_y, new_z);
 
    if(!IsPlayerInRangeOfPoint(playerid, 10, new_x, new_y, new_z))
    {
        // something
    }
	return 1;
}