Jump to content

Traffic Speed Camera [Adapted for Altis]


LoSantos_YT
 Share

Recommended Posts

I'm not a developer to begin with, but I do like to try things like this.

What this script does is to detect if a vehicle has exceeded the speed in an area with a speed camera, if so it takes money with a ticket.
Sorry if you don't understand the script annotations, I am Spanish and I program in Spanish too so they are not in English.

Difficulty: Easy

Credit to: LoSantosYT

  1. We go to editor and put an trigger:

image.thumb.png.2efb6f31772994cb779884ddc8e00063.png

To avoid any problems, I do not put model or addon speed camera (As there are paid scripts for this) So I recommend to look for a surveillance camera and put it as below

  1. Go to Functions.hpp and add the next at the bottom:
     
    class LoSantosYT {
        tag = "lsyt"
    	class DGT
    	{
    		file = "LoSantosYT\SpeedCamera";
    		class controlvelocidad {};
    		class calcmulta {};
    	};
    };

If you know how to program instead of copy and paste other people's scripts, you will know how to modify this :D

  1. Create a folder in your mission folder Create the following folder structure in your_mission_folder\LoSantosYT\SpeedCamera.
  2. Create the next file in and call him fn_calcmulta.sqf

 


/*
    File: fn_calcularsancionconlimite.sqf
    Author: LoSantosYT
    Description:
	Dada una velocidad y un límite, calcula la sanción de puntos y de dinero.

	PARAMS
		0 - Número: límite
		1 - Número: velocidad

	Devuelve: Array [dinero, puntos]

	Ejemplo [120, 138] call lsyt_fnc_calcularsancionconlimite

*/

params ["_limit", "_speed"];

private["_base", "_result", "_return"];

_base = 1250; // 100 de base
_result = false;

if(_limit isEqualTo 30) then {
	_result = true;
	if(_speed > 30) then {_return = [_base * 1, 0]};
	if(_speed > 50) then {_return = [_base * 3, 2]};
	if(_speed > 60) then {_return = [_base * 4, 4]};
	if(_speed > 70) then {_return = [_base * 5, 6]};
	if(_speed > 80) then {_return = [_base * 6, 6]};
};

if(_limit isEqualTo 40) then {
	_result = true;
	if(_speed > 40) then {_return = [_base * 1, 0]};
	if(_speed > 60) then {_return = [_base * 3, 2]};
	if(_speed > 70) then {_return = [_base * 4, 4]};
	if(_speed > 80) then {_return = [_base * 5, 6]};
	if(_speed > 90) then {_return = [_base * 6, 6]};
};


if(_limit isEqualTo 50) then {
	_result = true;
	if(_speed > 50) then {_return = [_base * 1, 0]};
	if(_speed > 70) then {_return = [_base * 3, 2]};
	if(_speed > 80) then {_return = [_base * 4, 4]};
	if(_speed > 90) then {_return = [_base * 5, 6]};
	if(_speed > 100) then {_return = [_base * 6, 6]};
};


if(_limit isEqualTo 60) then {
	_result = true;
	if(_speed > 60) then {_return = [_base * 1, 0]};
	if(_speed > 90) then {_return = [_base * 3, 2]};
	if(_speed > 110) then {_return = [_base * 4, 4]};
	if(_speed > 120) then {_return = [_base * 5, 6]};
	if(_speed > 130) then {_return = [_base * 6, 6]};
};


if(_limit isEqualTo 70) then {
	_result = true;
	if(_speed > 70) then {_return = [_base * 1, 0]};
	if(_speed > 100) then {_return = [_base * 3, 2]};
	if(_speed > 120) then {_return = [_base * 4, 4]};
	if(_speed > 130) then {_return = [_base * 5, 6]};
	if(_speed > 140) then {_return = [_base * 6, 6]};
};



if(_limit isEqualTo 80) then {
	_result = true;
	if(_speed > 80) then {_return = [_base * 1, 0]};
	if(_speed > 110) then {_return = [_base * 3, 2]};
	if(_speed > 130) then {_return = [_base * 4, 4]};
	if(_speed > 140) then {_return = [_base * 5, 6]};
	if(_speed > 150) then {_return = [_base * 6, 6]};
};



if(_limit isEqualTo 90) then {
	_result = true;
	if(_speed > 90) then {_return = [_base * 1, 0]};
	if(_speed > 120) then {_return = [_base * 3, 2]};
	if(_speed > 140) then {_return = [_base * 4, 4]};
	if(_speed > 150) then {_return = [_base * 5, 6]};
	if(_speed > 160) then {_return = [_base * 6, 6]};
};



if(_limit isEqualTo 100) then {
	_result = true;
	if(_speed > 100) then {_return = [_base * 1, 0]};
	if(_speed > 140) then {_return = [_base * 3, 2]};
	if(_speed > 160) then {_return = [_base * 4, 4]};
	if(_speed > 170) then {_return = [_base * 5, 6]};
	if(_speed > 180) then {_return = [_base * 6, 6]};
};



if(_limit isEqualTo 110) then {
	_result = true;
	if(_speed > 110) then {_return = [_base * 1, 0]};
	if(_speed > 140) then {_return = [_base * 3, 2]};
	if(_speed > 160) then {_return = [_base * 4, 4]};
	if(_speed > 170) then {_return = [_base * 5, 6]};
	if(_speed > 180) then {_return = [_base * 6, 6]};
};



if(_limit isEqualTo 120) then {
	_result = true;
	if(_speed > 120) then {_return = [_base * 1, 0]};
	if(_speed > 150) then {_return = [_base * 3, 2]};
	if(_speed > 170) then {_return = [_base * 4, 4]};
	if(_speed > 180) then {_return = [_base * 5, 6]};
	if(_speed > 190) then {_return = [_base * 6, 6]};
};

if(!_result) then { _return = [0,0]};

_return

Also create the next file in and call him fn_controlvelocidad.sqf
 


/*
    File: fn_calcularsancionconlimite.sqf
    Author: LoSantosYT
    Description:
	Recibe una llamada desde un trigger.

	MAL, CAMBIAR
	Parámetros:
		0: Número, límite de velocidad
		1: String, nombre público del radar
		2: Jugador, jugador que va en el vehículo

	[limite, "Nombre del radar", jugador] call lsyt_fn_controlvelocidad;
	[120, "Autopista Morrison-Lakeside PK.5", player] lsyt_fn_controlvelocidad

	Condición trigger:
	this && (local player) && (vehicle player in thisList)

	Script en el trigger:
	[120, "Nombre autopista", player] call lsyt_fnc_controlvelocidad

*/

params ["_limit", "_name", "_speed", "_player"];

private["_fineCalc", "_vehicle", "_speed", "_trigger", "_license", "_fine", "_percentage", "_plate", "_points", "_speeltime", "_text"];

_vehicle = vehicle _player;
_speed = speed _vehicle;
_speed = round _speed;

// Comprobar que se haya superado el límite de velocidad
if(_speed <= _limit) exitWith {};

// Comprobar que el jugador esté montado a un vehículo
if(_player == _vehicle) exitWith {};

// Comprobar que el jugador sea civil
if(side _player != civilian) exitWith {};

// Comprobar que el jugador sea el conductor
if(_player != driver _vehicle) exitWith {};

// Los radares tienen un margen de error...
// Si el límite es = o menor de 100, es el límite + 10
if(_limit <= 100) then {
	_trigger = _limit + 10;
} else {
	// Si el límite es +100, el margen es 110% del límite
	_trigger = round (limit * 1.10);
};

if(_speed < _trigger) exitWith {};

// Aquí estaría bien añadir un sleep random de x tiempo para que la gente tenga la incertidumbre de si le ha saltado o no...
// _tiempo = random 15;
// sleep _tiempo (...)
//sleep _sleeptime;

playSound "fotoradar";
cutText ["","WHITE OUT",0.5];
cutText ["","WHITE IN",0.5];	

// Ahora, la cantidad también depende de la velocidad a la que íbamos...
// Para simplificarlo, lo haré en base a una función con un máximo, pero siguiendo una fórmula

_fineCalc = [_limit, _speed] call lsyt_fnc_calcmulta;

_fine = _fineCalc select 0;

// Si encima no tiene el permiso de conducir, le sumamos un plus fijo
_license = license_civ_driver;

if(!_license) then {
	_fine = _fine + 500; // Cantidad a sumar si no tiene el carnet
};

_points = _fineCalc select 1;

_plate = _vehicle;

_datos = format ["CIRCULAR A %1 KM/H, TENIENDO LIMITADA LA VELOCIDAD A %2 KM/H. VELOCIMETRO DE POLICE DEPARTAMENT QUE HA SIDO SOMETIDO AL CONTROL METEOROLÓGICO LEGALMENTE ESTABLECIDO.", _speed, _limit];

// Llamamos al sistema de sanciones
systemChat "Deberia aparecer la multa";

// La notificación por hint se genera por partes
_text = "<t size='2'>DGT</t><br/><t size='1'>Notificación de sanción</t><t align='left'>";

_text = _text + format["<br/><br/><t size='1' underline='true'>1. LUGAR DE DENUNCIA</t><br/>%1", _name];

_text = _text + format["<br/><br/><t size='1' underline='true'>2. HECHO DENUNCIADO</t><br/>%1", _datos];

_text = _text + format["<br/><br/><t size='1' underline='true'>3. DATOS VEHÍCULO</t><br/>Velocidad captada: %1 Km/h", _speed];

_text = _text + format["<br/><br/><t size='1' underline='true'>SANCIÓN</t>"];

if(_fine > 0) then {
	imperial_bank = (imperial_bank - _fine) max 0;
	_text = _text + format["<br/>Importe total multa: %1 € (PAGADO)", _fine];
};

_text = _text + "</t>";
hint parseText _text; // Lo enviamos

// ... y ya estaría.

Result:
unknown.png

image.thumb.jpeg.e0d0aac2514e93d39877a18aa0df0a6a.jpeg

 

Edited by LoSantos_YT
  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
On 8/16/2022 at 4:28 PM, bubu09 said:

Hello I try to put your script but it does not detect me the speed it puts me any instead of the speed

@bubu09 

try substituting _player for player and _vehicle for vehicle player. Make sure you have followed all the steps correctly.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.