SetVehicleSirens: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 32: Line 32:
This example adds a siren then sets the vehicle siren in the center of the car. (Not sure if it works...)
This example adds a siren then sets the vehicle siren in the center of the car. (Not sure if it works...)
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler("onVehicleEnter",root,function(player,seat)
addEventHandler("onVehicleEnter", root, function(player, seat)
   if(player)and(seat==0)then
   if (player) and (seat == 0) then
       addVehicleSirens(source,1,2)
       addVehicleSirens(source, 1, 2)
      setVehicleSirens(source,1,0,0,0,100,0,100)
   end
   end
end)
end)
addEventHandler("onVehicleExit",root,function(player,seat)
 
   if(player)and(seat==0)then
addEventHandler("onVehicleExit", root, function(player, seat)
   if (player) and (seat == 0) then
       removeVehicleSirens(source)
       removeVehicleSirens(source)
   end
   end

Revision as of 17:42, 23 September 2020

This function changes the properties of a vehicles siren point.

[[{{{image}}}|link=|]] Note: Although you may be able to add sirens to any vehice, this function may not work. This function fails on certain vehicle models (https://wiki.multitheftauto.com/wiki/Vehicle_IDs#Lua_table_of_vehicles_that_doesn.27t_support_siren_lights).

Syntax

bool setVehicleSirens ( vehicle theVehicle, int sirenPoint, float posX, float posY, float posZ, float red, float green, float blue, [float alpha = 255, float minAlpha = 0.0] )

OOP Syntax Help! I don't understand this!

Method: vehicle:setSirens(...)
Counterpart: getVehicleSirens


Required Arguments

  • theVehicle: The vehicle to modify
  • sirenPoint: The siren point to modify
  • posX: The x position of this siren point from the center of the vehicle
  • posY: The y position of this siren point from the center of the vehicle
  • posZ: The z position of this siren point from the center of the vehicle
  • red: The amount of red from 0 to 255
  • green: The amount of green from 0 to 255
  • blue: The amount of blue from 0 to 255

Optional Arguments

  • alpha: The alpha of the siren from 0 to 255
  • minAlpha: The minimum alpha of the light during day time

Returns

Returns true if the siren point was successfully changed on the vehicle, false otherwise.

Example

Click to collapse [-]
Server

This example adds a siren then sets the vehicle siren in the center of the car. (Not sure if it works...)

addEventHandler("onVehicleEnter", root, function(player, seat)
   if (player) and (seat == 0) then
      addVehicleSirens(source, 1, 2)
   end
end)

addEventHandler("onVehicleExit", root, function(player, seat)
   if (player) and (seat == 0) then
      removeVehicleSirens(source)
   end
end)

Requirements

Minimum server version 1.3.0-9.03968
Minimum client version 1.3.0-9.03968

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.3.0-9.03968" client="1.3.0-9.03968" />

See Also