<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Blaack</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Blaack"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Blaack"/>
	<updated>2026-04-21T05:47:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SCamera&amp;diff=81857</id>
		<title>SCamera</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SCamera&amp;diff=81857"/>
		<updated>2025-03-21T10:43:44Z</updated>

		<summary type="html">&lt;p&gt;Blaack: added automatization system in fines value (table speedFines).&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle/&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
This function creates a speed camera in-game, fines speeding vehicles, and notifies the driver and take money from player based on vehicle speed.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 function sCamera(modelId, x, y, z, speed, between) &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
*  modelId: The model ID of the camera object to be created.&lt;br /&gt;
*  x, y, z: The coordinates where the camera object will be placed in the game world.&lt;br /&gt;
*  speed: The speed limit that vehicles should not exceed.&lt;br /&gt;
*  between: The maximum distance from the camera at which a vehicle can be detected.&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
The sCamera function creates a camera object at a specified location in the game world. It then sets up a timer to check the speed of all vehicles in the game every second. If a vehicle is found to be exceeding the defined speed limit and is within a certain distance from the camera, the driver of the vehicle is fined. The fine is calculated based on the vehicle’s speed, and a message is displayed to the driver informing them of the fine.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
The function creates a speed camera in-game, fines speeding vehicles, and notifies the driver and take money from player based on vehicle speed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sCamera(modelId, x, y, z, speed, between)&lt;br /&gt;
    local camera = createObject(modelId, x, y, z)&lt;br /&gt;
&lt;br /&gt;
    local speedLimit = speed&lt;br /&gt;
&lt;br /&gt;
    local speedCheckTimer = setTimer(&lt;br /&gt;
        function()&lt;br /&gt;
            local vehicles = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
            for i, vehicle in ipairs(vehicles) do&lt;br /&gt;
                local vx, vy, vz = getElementVelocity(vehicle)&lt;br /&gt;
                local vehicleSpeed = (vx^2 + vy^2 + vz^2)^(0.5) * 180&lt;br /&gt;
                local x1, y1, z1 = getElementPosition(vehicle)&lt;br /&gt;
                local x2, y2, z2 = getElementPosition(camera)&lt;br /&gt;
                local distance = getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2)&lt;br /&gt;
                if vehicleSpeed &amp;gt; speedLimit and distance &amp;lt; between then&lt;br /&gt;
                    local driver = getVehicleOccupant(vehicle, 0)&lt;br /&gt;
                    if driver then&lt;br /&gt;
                        local fine = 0&lt;br /&gt;
                        local speedFines = {&lt;br /&gt;
                            {maxSpeed = 10, fine = 150},&lt;br /&gt;
                            {maxSpeed = 20, fine = 350},&lt;br /&gt;
                            {maxSpeed = 50, fine = 1250},&lt;br /&gt;
                            {maxSpeed = math.huge, fine = 2250},&lt;br /&gt;
                        }&lt;br /&gt;
                        for _, value in ipairs(speedFines) do&lt;br /&gt;
                            if vehicleSpeed &amp;lt;= value.maxSpeed then&lt;br /&gt;
                                fine = value.fine&lt;br /&gt;
                            end&lt;br /&gt;
                        end&lt;br /&gt;
                        takePlayerMoney(driver, fine)&lt;br /&gt;
                        fadeCamera(driver, false, 0.4 , 255,255,255)&lt;br /&gt;
                        setTimer(fadeCamera, 250, 1, driver, true, 1.0)&lt;br /&gt;
                        outputChatBox(&amp;quot;You were caught speeding by a traffic enforcement camera! You've been fined $&amp;quot; .. fine .. &amp;quot;.&amp;quot;, driver, 255, 0, 0)&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end,&lt;br /&gt;
        1000, 0 &lt;br /&gt;
    )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
The function creates a speed camera in-game, fines speeding vehicles, and notifies the driver and take money from player based on vehicle speed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Create a speed camera at coordinates (-710.23791503906, 688.37194824219, 17.034782409668) with a speed limit of 70 and a detection range of 15 units&lt;br /&gt;
sCamera(1286, -710.23791503906, 688.37194824219, 17.034782409668, 70, 15)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By : [https://forum.multitheftauto.com/profile/52553-khaledx/ KhaledX]&lt;/div&gt;</summary>
		<author><name>Blaack</name></author>
	</entry>
</feed>