Hallo,
Es ist schon spät, also werde ich versuchen meinen Beitrag schnellstmöglich zu verfassen. Bilder werde ich mir hier ersparen, dazu kann nämlich hier (Eine Blaulichtleiste die es in sich hat) oder hier (https://native-network.net/wsif/entry/129…gen-mit-sirene/) das Script in Aktion angeschaut werden.
Fangen wir an.
1. Config File erstellen und bearbeiten
1.1 Config File erstellen
- Ihr erstellt eine Config File(.hpp oder .h) mit dem Namen "emergencyLightsConfig"
- Hier fügt ihr folgendes ein:
C
Alles anzeigenclass emergencyLightsConfig { engineTimeout = 0.05; defaultAttenuation[] = {0.181, 0, 1000, 130}; class west { class C_Offroad_01_F { class S1 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0; brightnessMaximum = 20; position[] = {-0.560547,0.109863,0.441497}; attenuation[] = {}; phaseTime = 0.2; timeout = 0; }; class S2 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0; brightnessMaximum = 20; position[] = {0.487427,0.103027,0.441497}; attenuation[] = {}; phaseTime = 0.2; timeout = .06; }; class S3 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0; brightnessMaximum = 20; position[] = {-0.422607,0.106934,0.441497}; attenuation[] = {}; phaseTime = 0.2; timeout = 0; }; class S4 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0; brightnessMaximum = 20; position[] = {0.35144,0.104004,0.441497}; attenuation[] = {}; phaseTime = 0.2; timeout = .06; }; class S5 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0; brightnessMaximum = 20; position[] = {-0.261597,0.104004,0.441497}; attenuation[] = {}; phaseTime = 0.2; timeout = 0; }; class S6 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0; brightnessMaximum = 20; position[] = {0.208374,0.103027,0.441497}; attenuation[] = {}; phaseTime = 0.2; timeout = .06; }; class S7 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0; brightnessMaximum = 20; position[] = {-0.108643,0.103027,0.441497}; attenuation[] = {}; phaseTime = 0.2; timeout = 0; }; class S8 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0; brightnessMaximum = 20; position[] = {0.0594482,0.10791,0.441497}; attenuation[] = {}; phaseTime = 0.2; timeout = .06; }; }; class C_SUV_01_F { class S1 { status = false; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.0863, 0.5137, 0.9412}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {-0.5,0,0.22}; attenuation[] = {0.3, 0, 100, 130}; phaseTime = 0; timeout = 0; }; class S2 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.0863, 0.5137, 0.9412}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {0.5,0,0.22}; attenuation[] = {0.3, 0, 100, 130}; phaseTime = 0.2; timeout = 0; }; }; class C_Hatchback_01_F { class S1 { status = false; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.0863, 0.5137, 0.9412}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {-0.39,0,0.16}; attenuation[] = {0.3, 0, 100, 130}; phaseTime = 0; timeout = 0; }; class S2 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.0863, 0.5137, 0.9412}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {0.34,0,0.16}; attenuation[] = {0.3, 0, 100, 130}; phaseTime = 0.2; timeout = 0; }; }; class B_Quadbike_01_F { class S1 { status = false; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.0863, 0.5137, 0.9412}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {0.27,1,-0.65}; attenuation[] = {0.07, 0, 1000, 130}; phaseTime = 0.2; timeout = 0; }; class S2 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.0863, 0.5137, 0.9412}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {-0.28,1,-0.65}; attenuation[] = {0.07, 0, 1000, 130}; phaseTime = 0.2; timeout = 0; }; }; }; class independent { class C_Offroad_01_F { class S1 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {0.34,0,0.57}; attenuation[] = {}; phaseTime = 0.2; timeout = 0; }; class S2 { status = false; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {-0.42,0,0.57}; attenuation[] = {}; phaseTime = 0.2; timeout = 0; }; class S3 { status = false; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {-0.26,2.59,-0.48}; attenuation[] = {0.1, 0, 1000, 130}; phaseTime = 0.2; timeout = 0; }; class S4 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {0.175,2.59,-0.48}; attenuation[] = {0.1, 0, 1000, 130}; phaseTime = 0.2; timeout = 0; }; }; class C_SUV_01_F { class S1 { status = false; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.0863, 0.5137, 0.9412}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {-0.5,0,0.22}; attenuation[] = {0.3, 0, 100, 130}; phaseTime = 0; timeout = 0; }; class S2 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.0863, 0.5137, 0.9412}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {0.5,0,0.22}; attenuation[] = {0.3, 0, 100, 130}; phaseTime = 0.2; timeout = 0; }; }; class C_Van_01_box_F { class S1 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {0.56,2.15,-0.8}; attenuation[] = {0.07, 0, 1000, 130}; phaseTime = 0.2; timeout = 0; }; class S2 { status = false; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {-0.59,2.15,-0.8}; attenuation[] = {0.07, 0, 1000, 130}; phaseTime = 0.2; timeout = 0; }; class S3 { status = false; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {0.72,0.68,0.65}; attenuation[] = {0.17, 0, 1000, 130}; phaseTime = 0.2; timeout = 0; }; class S4 { status = true; color[] = {0.0863, 0.5137, 0.9412}; ambientColor[] = {0.1,0.1,1}; brightnessMinimum = 0.05; brightnessMaximum = 20; position[] = {-0.72,0.68,0.65}; attenuation[] = {0.17, 0, 1000, 130}; phaseTime = 0.2; timeout = 0; }; }; }; class civilian {}; };
Ich gehe jetzt davon aus, dass diese Config selbsterklärend bis auf die "S*"-Klassen ist.
- Nun bindet ihr die Config File in eurer Master-Config-File ein oder eben in der "description.ext". Dies macht ihr wie folgt:
Wobei natürlich "path\to\file.hpp" der relative Pfad der Mission File eurer eben erstellten Config File ist.
Damit habt ihr die Config File erstellt. Nun geht es darum, wie die Config File konfiguriert werden kann.
1.2 Config File konfigurieren
Hier eine Erklärung:
Ich habe mir die Freiheit genommen, eine Config File zu erstellen, da das Bearbeiten von Blaulichten vereinfacht wird.
Dabei ist es wie folgt angeordnet:
-
emergencyLightsConfig (class)
-
side (class)
-
classname (class)
- status (bool)
- color (array[3])
- ambientColor (array[3])
- brightnessMinimum (scalar/integer)
- brightnessMaximum (scalar/integer)
- position (array[3])
- attenuation (array[])
- phaseTime (scalar/integer)
- timeout (scalar/integer)
-
classname (class)
-
side (class)
Und hier sind folgende Erklärungen (nein, nicht zu den Datentypen):
Property / Einstellung | Description / Erklärung |
status | Dieser Parameter lässt das Licht beim ersten mal an (true) oder eben aus (false) |
color | Die eigentliche Farbe des Lichts. |
ambientColor | Die Farbe, die an die Umgebung abgegeben wird. Am besten eine "leichte" Farbe nutzen |
brightnessMinimum | Die minimale Helligkeit. Trifft zu, wenn das Licht "aus" ist. |
birghtnessMaximum | Die maximale Helligkeit. Trifft zu, wenn das Licht "an" ist. |
position | Die "model"-Position der Lichtquelle. Besitzt nicht die "worldspace"- sondern die "model"-Koordinaten - siehe worldToModel - Bohemia Interactive Community |
attenuation | Ist schwierig zu beschreiben. Ich nenne es immer: "Das Array was für das Aussehen der Lichtkugel(quelle) sorgt - siehe setLightAttenuation - Bohemia Interactive Community |
phaseTime | Gibt an wie lange das Licht an bleibt. |
timeout | Ist der Abstand(Pause in sek.) zwischen dem nächsten Licht. |
Das sollte erstmal als Erklärung genügen.
2. Den Key Handler bearbeiten
- Ihr geht in die "fn_keyHandler.sqf" ändert folgendes:
C
Alles anzeigen//OLD ONE //L Key? case 38: { //If cop run checks for turning lights on. if(_shift && playerSide in [west,independent]) then { if(vehicle player != player && (typeOf vehicle player) in ["C_Offroad_01_F","B_MRAP_01_F","C_SUV_01_F","C_Hatchback_01_sport_F", "B_Heli_Light_01_F","B_Heli_Transport_01_F" ]) then { if(!isNil {vehicle player GVAR "lights"}) then { if(playerSide == west) then { [vehicle player] call life_fnc_sirenLights; } else { [vehicle player] call life_fnc_medicSirenLights; }; _handled = true; }; }; }; if(!_alt && !_ctrlKey) then { [] call life_fnc_radar; }; }; //NEW ONE //L Key? case 38: { //If cop run checks for turning lights on. if(!isNil {vehicle player getVariable "lights"} && vehicle player != player && _shift) then { if (!(vehicle player getVariable "lights")) then { [vehicle player, player] spawn life_fnc_emergencyLights; } else { vehicle player setVariable ["lights", false, true]; }; }; if(!_alt && !_ctrlKey) then { [] call life_fnc_radar; }; };
Fertig.
3. fn_emergencyLights.sqf einfügen
- Ihr erstellt eine neue Datei mit dem Namen "fn_emergencyLights.sqf" in eurem "functions"-Ordner.
- Diese Datei füllt mit folgendem Inhalt:
C
Alles anzeigen/* File: fn_emergencyLights.sqf Author: Vincent H. aka AGPHeaddikilla aka Yoghurt aka Yogurette Link: http://forums.bistudio.com/showthread.php?157474-Offroad-Police-sirens-lights-and-underglow Original Author: mindstorm, modified by Adanteh Description: Adds the light effect to cop vehicles, specifically the offroad. License: MIT License Copyright (c) 2016 Vincent Heins (http://www.allgameplay.de/) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ private ["_vehicle", "_sendUnit", "_engineTimeout", "_defaultAttenuation", "_playerSide", "_classname", "_lights", "_lightObjects"]; _vehicle = [_this, 0, ObjNull, [ObjNull]] call BIS_fnc_param; _sendUnit = [_this, 1, ObjNull, [ObjNull]] call BIS_fnc_param; if (isNull _vehicle || isNull _sendUnit) exitWith {}; _engineTimeout = getNumber(missionConfigFile >> "emergencyLightsConfig" >> "engineTimeout"); _defaultAttenuation = getArray(missionConfigFile >> "emergencyLightsConfig" >> "defaultAttenuation"); _playerSide = toLower (str side _sendUnit); _classname = typeOf _vehicle; _lightObjects = []; { private ["_status", "_color", "_ambientColor", "_brightnessMinimum", "_brightnessMaximum", "_position", "_attenuation", "_phaseTime", "_timeout"]; _status = getNumber(_x >> "status"); _color = getArray(_x >> "color"); _ambientColor = getArray(_x >> "ambientColor"); _brightnessMinimum = getNumber(_x >> "brightnessMinimum"); _brightnessMaximum = getNumber(_x >> "brightnessMaximum"); _position = getArray(_x >> "position"); _attenuation = getArray(_x >> "attenuation"); _phaseTime = getNumber(_x >> "phaseTime"); _timeout = getNumber(_x >> "timeout"); _light = "#lightpoint" createVehicleLocal getPos _vehicle; _light setLightColor _color; _light setLightAmbient _ambientColor; _light lightAttachObject [_vehicle, _position]; if (_status == 1) then { _light setLightBrightness _brightnessMaximum; } else { _light setLightBrightness _brightnessMinimum; }; if ((count _attenuation) <= 0) then { _light setLightAttenuation _defaultAttenuation; } else { _light setLightAttenuation _attenuation; }; _light setLightIntensity 10; _light setLightFlareSize 0.38; _light setLightFlareMaxDistance 150; _light setLightUseFlare true; _light setLightDayLight true; _lightObjects pushBack [_light, _status, ([[_phaseTime], 0, nil, [0]] call BIS_fnc_param), time, ([[_timeout], 0, nil, [0]] call BIS_fnc_param), _brightnessMinimum, _brightnessMaximum]; } forEach ("true" configClasses (missionConfigFile >> "emergencyLightsConfig" >> _playerSide >> _classname)); if ((count _lightObjects) <= 0) exitWith {}; if (_sendUnit == player) then { vehicle player setVariable ["lights", true, true]; _players = []; { if (player != _x) then { _players pushBack _x; }; } forEach playableUnits; [vehicle player, player] remoteExec ["life_fnc_emergencyLights", _players]; }; _lightObj = ObjNull; while { (alive _vehicle) } do { if(!(_vehicle getVariable ["lights", false])) exitWith {}; { private ["_lightObj", "_time", "_timeout", "_oldTime", "_status", "_brightnessMinimum", "_brightnessMaximum", "_extra"]; _lightObj = [_x, 0, ObjNull, [ObjNull]] call BIS_fnc_param; _time = [_x, 2, .2, [0]] call BIS_fnc_param; _timeout = [_x, 4, 0, [0]] call BIS_fnc_param; _oldTime = ([_x, 3, time, [0]] call BIS_fnc_param) + _timeout; _status = [_x, 1, 0, [0]] call BIS_fnc_param; _brightnessMinimum = [_x, 5, 0, [0]] call BIS_fnc_param; _brightnessMaximum = [_x, 6, 0, [0]] call BIS_fnc_param; _extra = 0; if (!isEngineOn _vehicle) then { _extra = _engineTimeout; }; if (_time == 0) then { if (isEngineOn _vehicle) then { _time = (random [0.1, 0.2, 0.3]); } else { _time = (random [0.1, 0.2 + 0.2, 0.3 + 0.2]); }; }; if ((time - _oldTime) > (_time + _extra)) then { if (_status == 0) then { _lightObj setLightBrightness _brightnessMinimum; _x set [1, 1]; } else { _lightObj setLightBrightness _brightnessMaximum; _x set [1, 0]; }; _x set [3, time]; sleep (_timeout + _extra); }; } forEach _lightObjects; sleep 0.1; }; { deleteVehicle (_x select 0); } forEach _lightObjects;
Auch fertig!
4. life_fnc_emergencyLights in CfgFunctions einfügen
- Geht in eure "CfgFunctions"-Datei und fügt folgendes unter "class Functions {};" ein (oder in einer anderen Kategorie, ihr müsst das selbst wissen):
ENDE
Das war das Tutorial, für ein Script welches sehr gefragt war/ist. Hoffentlich habt ihr Spaß damit und hoffentlich spamt ihr nicht jeden Fehler in die Antworten. Wichtig: Immer zuerst selber nachdenken und versuchen die Sachen zu fixen und dann nachfragen. Sollte es Fehler geben, so bitte meldet diese hier.
Alle Rechte Vincent Heins vorbehalten und dieses Script ist mit der MIT Lizenz lizenziert.
Jegliche Nutzung ist erlaubt, sowie das bearbeiten durch Einverständnis meinerseits.
Das war mein liebevoller Disclaimer/Haftungsausschluss, der das Script auf mich festlegt^^.
Naja, immer sicher gehen.
Mit freundlichen Grüßen,
Vincent H.