#Squawk Codes for Arma 3

1 messages · Page 1 of 1 (latest)

hybrid canyon
#

Hey men,
I'm just starting with scripting in SQF. I've scripted some easy things like an air raid speaker with switches and stuff. Now, I want to implement a squawk code system for air traffic control.

Here's my idea: You get in a plane and ask for clearance to take off. The ATC gives you a squawk code. To set your squawk code, you type "#squawk" followed by the code in the chat. The ATC and other aircraft will see your code as a movable marker on the map. It will display your squawk code, altitude, heading, and speed.
My Problems:
1.: I can set a marker with a #squawk command. and if i write somethink like #squawk 2121 i'll get a feedback from the system - but it sets my code to 'scalar' - so i thought, ill force it to lower. then i'll get 'any'. When i type letters like #squawk Alpha i'll get an error.
2.: My Marker doesnt update its position. and i'll get no informations next to the marker like heading, speed etc.

To be honest, I'm quite exhausted at the moment. However, I don't think I can come up with a solution quickly. Does anyone have any ideas on what might be causing it? Thank you in advance for your help!

#
["squawk", {
    // Check if the player is sitting in an airplane
    if (!(vehicle player isKindOf "Air")) exitWith {
        hint "You need to be in an airplane to change the transponder.";
    };

    // Retrieve the entered transponder code from the chat command
    private _transponderCode = parseNumber (_this select 1) ;

    // Set the transponder code of the aircraft.
    vehicle player setVariable ["transponderCode", _transponderCode, true];

    // Update the map marker with the new transponder code.
    private _marker = vehicle player getVariable ["marker", objNull];
    if (!isNull _marker) then {
        _marker setMarkerText format ["Squawk: %1", _transponderCode];
    } else {
        // Create a new map marker if none exists.
        private _markerPos = position vehicle player;
        private _markerName = format ["Squawk Marker (%1)", name vehicle player];
        _marker = createMarker [_markerName, _markerPos];
        _marker setMarkerType "mil_dot";
        _marker setMarkerColor "ColorRed";
        _marker setMarkerText format ["Squawk: %1", _transponderCode];
        vehicle player setVariable ["marker", _marker, true];
    };

    hint format ["Transponder code set to %1.", _transponderCode];
}] call CBA_fnc_registerChatCommand;