The-Programmer Forum

AltisLifeDev a écrit le dernier message :
#5
Solved the issus, can close.
C++:
/*
    File: fn_dynDrugFields.sqf
    Author: Your Mom /(.)(.)\
*/

diag_log "--------------------------------------";
diag_log "Drug Fields Init: Initializing...";
diag_log "--------------------------------------";

// Lets Make them waite
sleep(1*60);


diag_log "--------------------------------------";
diag_log "Dyn Drug Fields: Initializing...";
diag_log "--------------------------------------";

private _drugLocations = [
    ["weed", "Weed Field", "ColorRed", "mil_dot"],
    ["heroin", "Heroin Field", "ColorRed", "mil_dot"],
    ["cocaine", "Cocaine Field", "ColorRed", "mil_dot"]
];

private _stayTime = getNumber(missionConfigFile >> "CfgDynMarkers" >> "DynMarkers_Settings" >> "fields_position_time");
if (_stayTime == 0) exitWith {
    diag_log "--------------------------------------";
    diag_log "Error: fields_position_time is set to 0!";
    diag_log "--------------------------------------";
};

private ["_createDrugFieldMarker", "_createDrugFieldAreaMarker"];

//Used for marking Field on the Map
_createDrugFieldMarker = {
    private ["_drugType", "_drugName", "_color", "_markerType", "_location", "_markerName", "_drugFieldMarker", "_locationArray"];

    _params = params [
        ["_drugType", "", [""]],
        ["_drugName", "", [""]],
        ["_color", "", [""]],
        ["_markerType", "", [""]]
    ];

    _locationArray = getArray(missionConfigFile >> "CfgDynMarkers" >> "DynMarkers_Settings" >> format ["%1_locations", _drugType]);
    if (count _locationArray == 0) exitWith {
        diag_log format ["Error: No %1 locations defined!", _drugType];
    };

    _location = selectRandom _locationArray;

    _markerName = format ["%1_field", _drugType];
    _drugFieldMarker = createMarker [_markerName, _location];
    _drugFieldMarker setMarkerColor _color;
    _drugFieldMarker setMarkerType _markerType;
    _drugFieldMarker setMarkerText _drugName;

    format ["%1_field", _drugType] setMarkerPos _location;

    diag_log format ["Server Created %1 Map Marker At: %2", _drugType, _location];
};

//Main Marker Used for Config_Gather.hpp
_createDrugFieldAreaMarker = {
    private ["_drugType", "_areaMarkerName", "_areaMarkerPos", "_drugFieldAreaMarker","_zoneMarkerName"];

    _params = params [
        ["_drugType", "", [""]]
    ];

    _areaMarkerName = format ["%1_field", _drugType];
    _zoneMarkerName = format ["%1_zone", _drugType];
    _areaMarkerPos = getMarkerPos _areaMarkerName;
    _drugFieldAreaMarker = createMarker [_zoneMarkerName, _areaMarkerPos];
    _drugFieldAreaMarker setMarkerColor "ColorWhite";
    _drugFieldAreaMarker setMarkerType "empty";
    _drugFieldAreaMarker setMarkerShape "ELLIPSE";
    _drugFieldAreaMarker setMarkerSize [30, 30];

    format ["%1_zone", _drugType] setMarkerPos _areaMarkerPos;

    if(_areaMarkerName in allMapMarkers)then{
        diag_log format ["Server Created %1 Gather Zone At: %2", _drugType, _areaMarkerPos];
    };
};

{
    _x call _createDrugFieldMarker;
    _x call _createDrugFieldAreaMarker;
} forEach _drugLocations;

sleep (_stayTime * 60);

{
    private _drugType = _x select 0;
    private _markerName = format ["%1_field", _drugType];
    private _areaMarkerName = format ["%1_zone", _drugType];
    deleteMarker _markerName;
    deleteMarker _areaMarkerName;

    diag_log format ["Server Removed %1 field marker and area marker", _drugType];
} forEach _drugLocations;

diag_log "---------------------------";
diag_log "Dyn Drug Fields: Removed...";
diag_log "---------------------------";

//Repsawn the drug fields
{
    _x call _createDrugFieldMarker;
    _x call _createDrugFieldAreaMarker;
} forEach _drugLocations;

diag_log "--------------------------------------";
diag_log "Dyn Drug Fields: Respawning...";
diag_log "--------------------------------------";