Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Need help?

    Create a topic in the appropriate section
    Don't write everything in the chat!
  • Take a look at the marketplace

    There you can buy
    everything related to game servers
  • Don't want a ban?

    Please read our rules
    Don't disturb the order!
  • Sell or buy?

    Use services of the guarantor
    We will make your deal safe
Sign in to follow this  
DrTauren

Захват территорий группировками

Recommended Posts

Установка:

1) В папке core/gangs создаём файл fn_areaCapture.sqf с таким содержимым:

#include "..\..\script_macros.hpp"
/*
    File: fn_areaCapture.sqf
    Author: Fuel RebornRoleplay.com

    Description:
    checks the area for gangs or police before allowing you to capture an area
*/
private["_gangNum","_gName","_group","_area","_nil","_pos","_xname","_text","_action","_cpRate","_cP","_nearUnits","_areaContested","_progressBar","_title","_titleText","_ui"];

_area = getpos player nearestObject "Flag_Red_F"; //finds the flag
_group = _area getVariable ["gangOwner",grpNull]; //gets the owner of the flag
_xname = ""; //setup for popo name
_nearUnits = _area nearEntities ["Man",500]; //searches area for players
 _areaContested = false; //sets the area to not contested
if ((player distance _area) > 10) exitWith { hint "You must be closer to the flag to capture this area!"; }; //too far away

/*
#########################################
#       The Police Capture System       #
#########################################
*/

if (playerside isEqualTo west) exitWith {

//inform the server the police are trying to capture it.
[[0,1],"STR_GNOTF_CaptureAreaAttemptPopo",true,[name player]] remoteExecCall ["life_fnc_broadcast",RCLIENT];

//set the cp rate
if (!isNull _group) then {
    _cpRate = 0.0045;
} else {
    _cpRate = 0.0075;
};

//Police officer checks
{
        
    //check for other members of same side
    if ((isPlayer _x) && (_x != player) && (side _x == west)) then {
        _areaContested = false;
    };

    //checks for rebels
    if ((isPlayer _x) && (_x != player) && (side _x == civilian)) then {
        _areaContested = true;
        _xname = "Rebels";
    };

    //closes the capture
    if (_areaContested && _xname isEqualTo "Rebels") then {
        hint "Rebels are nearby!\nGet rid of them first!";
    };

} forEach _nearUnits;

//exit if contested
if (_areaContested) exitWith {};

//Setup our progress bar.
disableSerialization;
_title = localize "STR_GNOTF_CapturingArea";
5 cutRsc ["life_progress","PLAIN"];
_ui = uiNamespace getVariable "life_progress";
_progressBar = _ui displayCtrl 38201;
_titleText = _ui displayCtrl 38202;
_titleText ctrlSetText format["%2 (1%1)...","%",_title];
_progressBar progressSetPosition 0.01;
_cP = 0.01;

if (!(_areaContested)) then {
    for "_i" from 0 to 1 step 0 do {
        sleep 3; //police capture time * 100
        _cP = _cP + _cpRate;
        _progressBar progressSetPosition _cP;
        _titleText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_title];

        //sets the area to incapture
        _area setVariable ["inCapture",true,true];

        //interuption checks
        if (_cP >= 1 || !alive player) exitWith {_area setVariable ["inCapture",false,true];};
        if (player distance _area > 100) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
        if (_areaContested) exitWith {hint "Area Contested";}; //Future testing
        if (life_istazed) exitWith {_area setVariable ["inCapture",false,true];}; //Tazed
        if (life_isknocked) exitWith {_area setVariable ["inCapture",false,true];}; //Knocked
        if (life_interrupted) exitWith {_area setVariable ["inCapture",false,true];}; //interupted
    };
          if (player distance _area > 100) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
};

//Kill the UI display and check for various states
5 cutText ["","PLAIN"];
        if (player distance _area > 100) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
if (!alive player || life_istazed || life_isknocked) exitWith {life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //knocked out or tazed revert state
if (player getVariable["restrained",false]) exitWith {life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //restrained revert state
if (life_interrupted) exitWith {life_interrupted = false; titleText[localize "STR_GNOTF_CaptureCancel","PLAIN"]; life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //interupted revert state
life_action_inUse = false;
titleText[localize "STR_GNOTF_CapturedArea","PLAIN"];

//marker system
_gangNum = _area getVariable ["gangNum", ""];

_gName = group player getVariable "gang_name";
_pText = format["Neutralized Area"];

if (_gangNum == "Gang_Area_1") then {
    "gang_cap_1" setMarkerText _pText;
};

if (_gangNum == "Gang_Area_2") then {
    "gang_cap_2" setMarkerText _pText;
};

if (_gangNum == "Gang_Area_3") then {
    "gang_cap_3" setMarkerText _pText;
};

_area setVariable ["inCapture",false,true];
_area setVariable ["gangOwner",group player,true];

};

/*
#############################################
#       End Of Police Capture System        #
#############################################
*/

/*
#########################################
#       The Rebel Capture System        #
#########################################
*/

_area = getpos player nearestObject "Flag_Red_F"; //finds the flag
_group = _area getVariable ["gangOwner",grpNull]; //gets the ownerr of the flag
_xname = ""; //setup for popo name
_nearUnits = _area nearEntities ["Man",500]; //searches area for players
if (isNil {group player getVariable "gang_name"}) exitWith { hint "You must be in a gang to capture a gang area!"; }; //not in a gang
if (_group isEqualTo group player) exitWith { hint "Your gang already has control over this area!"; }; //already own it
if ((_area getVariable ["inCapture",FALSE])) exitWith {hint "Only one person shall capture at once!"; }; //stops 2 people capturing at the same time

[[0,1],"STR_GNOTF_CaptureAreaAttempt",true,[name player,(group player) getVariable "gang_name"]] remoteExecCall ["life_fnc_broadcast",RCLIENT]; //tells the server someone is trying to capture the outpost

if (!isNull _group) then {

_gangName = _group getVariable ["gang_name",""]; //gets the gang name

    //check if they want to capture someones elses area
    _action = [
        format[localize "STR_GNOTF_AlreadygangControlled",_gangName],
        localize "STR_Gang_captuerr",
        localize "STR_Global_Yes",
        localize "STR_Global_No"
    ] call BIS_fnc_guiMessage;

    _cpRate = 0.0045;
} else {
    _cpRate = 0.0075;
};

//check if area is contested
{

    //check for other members of same gang
    if ((isPlayer _x) && (_x != player) && (side _x == civilian) && (group _x == group player)) then {
        _areaContested = false;
    };

    //check for other rebels
    if ((isPlayer _x) && (_x != player) && (side _x == civilian) && (!(group _x == group player))) then {
        _areaContested = true;
    };

    //checks for cops
    if ((isPlayer _x) && (_x != player) && (side _x == west)) then {
        _areaContested = true;
        _xname = "Police Force";
    };

    //closes the capture
    if (_areaContested) exitWith {
        if (_xname isEqualTo "Police Force") then {
            hint "The Police Force are nearby!\nGet rid of them first!";
        } else {
            hint "Other rebels are nearby!\nGet rid of them first!";
        };
    };

} forEach _nearUnits;
   
//exit if contested 
if (_areaContested) exitWith {};

//Setup our progress bar.
disableSerialization;
_title = localize "STR_GNOTF_CapturingArea";
5 cutRsc ["life_progress","PLAIN"];
_ui = uiNamespace getVariable "life_progress";
_progressBar = _ui displayCtrl 38201;
_titleText = _ui displayCtrl 38202;
_titleText ctrlSetText format["%2 (1%1)...","%",_title];
_progressBar progressSetPosition 0.01;
_cP = 0.01;

if (!(_areaContested)) then {
    for "_i" from 0 to 1 step 0 do {
        sleep  3; //rebel capture time * 100
        _cP = _cP + _cpRate;
        _progressBar progressSetPosition _cP;
        _titleText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_title];

        //sets the area to incapture
        _area setVariable ["inCapture",true,true];

        //interuption checks
        if (_cP >= 1 || !alive player) exitWith {_area setVariable ["inCapture",false,true];};
        if (player distance _area > 100) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
        if (_areaContested) exitWith {hint "Area Contested";};
        if (life_istazed) exitWith {_area setVariable ["inCapture",false,true];}; //Tazed
        if (life_isknocked) exitWith {_area setVariable ["inCapture",false,true];}; //Knocked
        if (life_interrupted) exitWith {_area setVariable ["inCapture",false,true];}; //interupted
    };
    if (player distance _area > 100) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
};

//Kill the UI display and check for various states
5 cutText ["","PLAIN"];
if (player distance _area > 100) exitWith {_area setVariable ["inCapture",false,true];}; //how far they can go from the hideout while capturing
if (!alive player || life_istazed || life_isknocked) exitWith {life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //knocked out or tazed revert state
if (player getVariable["restrained",false]) exitWith {life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //restrained revert state
if (life_interrupted) exitWith {life_interrupted = false; titleText[localize "STR_GNOTF_CaptureCancel","PLAIN"]; life_action_inUse = false;_area setVariable ["inCapture",false,true];}; //interupted revert state
life_action_inUse = false;

titleText[localize "STR_GNOTF_CapturedArea","PLAIN"];

//marker system
_gangNum = _area getVariable ["gangNum", ""];

_gName = group player getVariable "gang_name";
_Text = format["Area Controlled By %1",_gName];

if (_gangNum == "Gang_Area_1") then {
    "gang_cap_1" setMarkerText _text;
};

if (_gangNum == "Gang_Area_2") then {
    "gang_cap_2" setMarkerText _text;
};

if (_gangNum == "Gang_Area_3") then {
    "gang_cap_3" setMarkerText _text;
};

//Tell the world
[[0,1],"STR_GNOTF_CaptureAreaSuccess",true,[name player,(group player) getVariable "gang_name"]] remoteExecCall ["life_fnc_broadcast",RCLIENT];

_area setVariable ["inCapture",false,true];
_area setVariable ["gangOwner",group player,true];

/*
#############################################
#       End Of The Rebel Capture System     #
#############################################
*/

2) Открываем Functions.hpp и добавляем код ниже в  core/gangs:

class areaCapture {};

3) Открываем редактор миссий и создаём три локации:

  • Локация #1
    Добавляем флаг Flag_Red_F и записываем его координаты (понадобится позже)
    Поле init этого флага должно содержать:
    this allowDamage false; this enableSimulation false; this setVariable ["gangNum","Gang_Area_1", true];
    На позиции флага добавляем маркер и называем его: gang_cap_1
    Поле test должно содержать описание: Uncontrolled Area
     
  • Локация #2
    Добавляем флаг Flag_Red_F и записываем его координаты (понадобится позже)
    Поле init этого флага должно содержать:
    this allowDamage false; this enableSimulation false; this setVariable ["gangNum","Gang_Area_2", true];

    На позиции флага добавляем маркер и называем его: gang_cap_2
    Поле test должно содержать описание: Uncontrolled Area
     

  • Локация #3
    Добавляем флаг Flag_Red_F и записываем его координаты (понадобится позже)
    Поле init этого флага должно содержать:
    this allowDamage false; this enableSimulation false; this setVariable ["gangNum","Gang_Area_3", true];

    На позиции флага добавляем маркер и называем его: gang_cap_3
    Поле test должно содержать описание: Uncontrolled Area

  • P.S. Также можно создать триггер в 500 метров для каждого флага, чтобы игроки знали его зону, но это по личному усмотрению

4) Открываем файл stringtable.xml и добавляем код:

        <Key ID="STR_GNOTF_CaptureAreaAttemptPopo">
            <Original>%1 and the police are trying to neutralize an area!</Original>
        </Key>

        <Key ID="STR_GNOTF_CapturingArea">
            <Original>Claiming Area</Original>
        </Key>

        <Key ID="STR_GNOTF_CapturedArea">
            <Original>Area has been captured.</Original>
        </Key>

        <Key ID="STR_Gang_captuerr">
            <Original>Capture Area</Original>
        </Key>

        <Key ID="STR_GNOTF_CaptureAreaSuccess">
            <Original>%1 and his gang: %2 - have claimed an area!</Original>
        </Key>

5) Открываем fn_setupActuons.sqf и добавляем код ниже в классы west и civilian:

//Gang
life_actions = life_actions + [player addAction["<t color='#FF0000'>Capture Gang Location</t>",life_fnc_areaCapture,"",0,false,false,"",' ((typeOf cursorTarget) == "Flag_Red_F") ']];

Серверная часть
6)
Открываем папку life_server/functions/gang и создаём файл fn_gangCash.sqf с таким содержимым:

#include "\life_server\script_macros.hpp"
/*
    File: fn_gangCash.sqf
    Author: Fuel RebornRoleplay.com

    Description:
    checks the gang areas, then rewards the gang if they own them
*/

 /*
    #########################
     #      north outpost        #
     #########################
 */

//gets the flag locations
_area = [4870.743,21934.35,0] nearestObject "Flag_Red_F";

//gets the gang names of the flag owners
_owner = _area getVariable ["gangOwner",grpNull];

//get the gang funds
_gFund = _owner getVariable ["gang_bank",0];

//set the new gang funds
_owner setVariable ["gang_bank",round(_gFund+((count playableUnits)*2000)),true];

//push gang funds to DB
[1,_owner] call TON_fnc_updateGang;
 
 /*
    #########################
     #    south pen outpost    #
     #########################
 */

//gets the flag locations
_area2 = [11207.171,8699.596,0] nearestObject "Flag_Red_F";

//gets the gang names of the flag owners
_owner = _area2 getVariable ["gangOwner",grpNull];

//get the gang funds
_gFund = _owner getVariable ["gang_bank",0];

//set the new gang funds
_owner setVariable ["gang_bank",round(_gFund+((count playableUnits)*2000)),true];

//push gang funds to DB
[1,_owner] call TON_fnc_updateGang;

 /*
    #########################
     #       east outpost        #
     #########################
 */

//gets the flag locations
_area3 = [20079.65,6744.436,0] nearestObject "Flag_Red_F";

//gets the gang names of the flag owners
_owner = _area3 getVariable ["gangOwner",grpNull];

//get the gang funds
_gFund = _owner getVariable ["gang_bank",0];

//set the new gang funds
_owner setVariable ["gang_bank",round(_gFund+((count playableUnits)*2000)),true];

//push gang funds to DB
[1,_owner] call TON_fnc_updateGang;

//time between scripts
Sleep 900;

[] spawn TON_fnc_gangCash;

7) Теперь координаты локаций, которые мы сохраняли нужно вставить в скрипте выше (fn_gangCash.sqf) в трёх местах где написано подобное:

//gets the flag locations
_area3 = [20079.65,6744.436,0] nearestObject "Flag_Red_F";

8) Открываем Config.cpp и вставляем код ниже в: \life_server\Functions\Gangs:

class gangCash {};

9) Открываем server init.sqf и под этой строкой:

[] spawn TON_fnc_initHouses;

вставляем этот код:

[] spawn TON_fnc_gangCash;



Оригинал на английском:

https://www.altisliferpg.com/topic/1257-tutorial-gang-capturable-areas/

 

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • By HellBoy
      Всем привет. Может кто подскажет, как можно ограничить радиус захвата,например ка52, наземной техники ракетами воздух-хемля "Вихрь"? В данный момент захватывается более чем за 5 км и спокойно уничтожается. Снаряды отключать не хочу,а вот радиус бы ограничил. Либо,если это не возможно без вмешательства в мод, как вариант, отключить данные ракеты у пилота,оставив только у стрелка.
    • By himik
      ПТУРы  на боевых вертах и бронетехнике не берут цели в захват,вообще никак,в чем может быть проблема? ЗУРы (ручные) захват делают
  • Our picks

×
×
  • Create New...

Important Information

By using this site, you automaticly agree to our Guidelines and Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.