Limited territory pay out range

Limited territory pay out range

« posted: Jun 16, 2016, 11:46 AM »
Something i'm trying to figure out, is how to set up the territory pay out system to only give you money if you within a certain distance. That way people can't be muffins and cap zones then piss off, thus get paid for not defending the cap.
Now the best I can think of doing, with my limited "skill" in scripting is I think i'd have to add the additional stuff in the 'territorypayroll' file.  And it would be doing a detect pos for player and territory, then something to get distance, and then if distance is less then set value. pay goes through, if greater then no pay and message saying outside territory range.
Also side note, if i want the territory to show up as red if held by anyone who isn''t me or my group. Would i just set the marker color for all sides to red? Because on the server i'm setting up there is only inde, so having territory zones show red instead of green would be a nice thing to have.

Re: Limited territory pay out range

« Reply #1 posted: Jun 16, 2016, 11:00 PM »
something like this should work:

Quote
_inrange_payout = false;
{
if ((player distance (getmarkerpos _x))< 2000) then
   {
        _inrange_payout = true;
   };   

} forEach allMapMarkers;
if (_inrange_payout) then
      {
         player setVariable ["cmoney", (player getVariable ["cmoney", 0]) + _money, true];
      }
      else
      {
titleText ["You are more than 2km away from the capture territories so you received no money.", "plain down", 0.5];
      };               


in the file
\territory\server\territoryPayroll.sqf

its pseudocode - so you have to fit it into your actual code - but it should give you an idea.

Re: Limited territory pay out range

« Reply #2 posted: Jun 17, 2016, 02:18 AM »
something like this should work:

in the file
\territory\server\territoryPayroll.sqf

its pseudocode - so you have to fit it into your actual code - but it should give you an idea.

So been trying that out and just can't seem to get it to work. Now i've got it to disable the payrole system or maybe break it. Since whether i'm in range or not no money is given, nor is there even a message.
Tried breaking the section up and placing its parts where i thought it would go and also tried keeping it together. Simply put i'm breaking it but not sure how.

Now this is the default payrole scipt i'm using and i've tried slipping your section under '_territoryCapped = false;' and around there up top, but it just deletes my money. And i've tried placing it under 'while {true} do' and also '_territoryCapped = true;' but then if would not delete my money when i booted thing up but every pay role it would delete my money then give me new money.
Maybe i'll get if before a reply but either way thought i'd leave this, since a scrub like me only gets things working by breaking stuff and hoping i figure out what went wrong.

Code: [Select]
]// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
// @file Name: territoryPayroll.sqf
// @file Author: AgentRev

if (!isServer) exitWith {};

_timeInterval = ["A3W_payrollInterval", 1*60] call getPublicVar;
_moneyAmount = ["A3W_payrollAmount", 10000] call getPublicVar;

_territoryCapped = false;
_inrange_payout = false;
{
if ((player distance (getmarkerpos _x))< 2000) then
   {
        _inrange_payout = true;
   };   

} forEach allMapMarkers;
if (_inrange_payout) then
      {
         player setVariable ["cmoney", (player getVariable ["cmoney", 0]) + _money, true];
      }
      else
      {
titleText ["You are more than 2km away from the capture territories so you received no money.", "plain down", 0.5];
      };

while {true} do
{
if (_territoryCapped) then
{
sleep _timeInterval;
}
else
{
sleep 60;
};

_payouts = [];

{
_territoryOwner = _x select 2;
_territoryChrono = _x select 3;

if (_territoryChrono > 0) then
{
_territoryCapped = true;

if (_territoryChrono >= _timeInterval) then
{
_added = false;

{
if ((_x select 0) isEqualTo _territoryOwner) exitWith
{
_x set [1, (_x select 1) + 1];
_added = true;
};
} forEach _payouts;

if (!_added) then
{
_payouts pushBack [_territoryOwner, 1];
};
};
};
} forEach currentTerritoryDetails;

{
_team = _x select 0;
_count = _x select 1;

_money = _count * _moneyAmount;
_message =  format ["Your team received a $%1 bonus for holding %2 territor%3 during the past %4 minutes", [_money] call fn_numbersText, _count, if (_count == 1) then { "y" } else { "ies" }, ceil (_timeInterval / 60)];

[[_message, _money], "A3W_fnc_territoryActivityHandler", _team, false] call A3W_fnc_MP;
} forEach _payouts;
};
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2488

Re: Limited territory pay out range

« Reply #3 posted: Jun 17, 2016, 02:52 AM »
if you use the "player" command server-side, you're gonna have a bad time

Re: Limited territory pay out range

« Reply #4 posted: Jun 17, 2016, 03:22 AM »
if you use the "player" command server-side, you're gonna have a bad time

Ya was thinking that but didn't mind to much to it since right now i'm testing on lan. Was planning to switch it _team since that is what the payrole money is directed to, but i'm wondering if _playerteam would be better. Since i want to where everyone in the group doesn't get money if only one guy is in the area, thus each individual gets paid based on if they are owner and in zone.
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2488

Re: Limited territory pay out range

« Reply #5 posted: Jun 17, 2016, 03:29 AM »
the code wiking gave you is for territoryActivityHandler.sqf, not territoryPayroll.sqf, he must've been confused

Re: Limited territory pay out range

« Reply #6 posted: Jun 17, 2016, 05:42 AM »
the code wiking gave you is for territoryActivityHandler.sqf, not territoryPayroll.sqf, he must've been confused

So i added his set into territoryActivityHandler, and now I get a message based on if i'm in the zone or not. But I still get money, though the weird part is it's not at the same time as the message saying i'm outside the zone. But like 30-60 seconds later, like this new bit is running but the interval timer in payroll is just going along without a care.
Should i cut out something in payroll or am i'm just being a scrub with how i set up the script down below.

This is how I have it set up
Code: [Select]
// Called with [_message, _money(optional)], "A3W_fnc_territoryActivityHandler", side, false] call A3W_fnc_MP;

diag_log format["A3W_fnc_territoryActivityHandler called with %1", _this];

if (typeName _this == "ARRAY" && {count _this >= 1}) then {
_msg = _this select 0;
_money = 0; if (count _this >= 2) then { _money = _this select 1; };

_inrange_payout = false;
{
if ((player distance (getmarkerpos _x))< 200) then
   {
        _inrange_payout = true;
   };   

} forEach allMapMarkers;
if (_inrange_payout) then
      {
         player setVariable ["cmoney", (player getVariable ["cmoney", 0]) + _money, true];
      }
      else
      {
titleText ["You are more than 2km away from the capture territories so you received no money.", "plain down", 0.5];
      };

playSound 'FD_Finish_F'; // Nice sound effect to draw players attention to the notification
};

  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2488

Re: Limited territory pay out range

« Reply #7 posted: Jun 17, 2016, 07:17 AM »
If I understand correctly, you set the payroll interval to 60 seconds, so the payroll will execute every 60 seconds for everyone.

With that in mind, I think the problem is related to how allMapMarkers is being scanned with the inrange snippet. There are a bunch of other markers than just territories, so you need to narrow the search to only actual territories.

So, replace this bit:

Code: [Select]
_inrange_payout = false;
{
if ((player distance (getmarkerpos _x))< 200) then
   {
        _inrange_payout = true;
   };   

} forEach allMapMarkers;

to this:

Code: [Select]
_inrange_payout = false;
{
if ((_x select 2) in [group player, playerSide] && {player distance markerPos (_x select 0) <= 2000}) exitWith
{
_inrange_payout = true;
};
} forEach currentTerritoryDetails;

This should only allow players within 2km of a friendly territory to receive any capture and payroll money.

Re: Limited territory pay out range

« Reply #8 posted: Jun 17, 2016, 11:19 AM »
Ya was thinking that but didn't mind to much to it since right now i'm testing on lan. Was planning to switch it _team since that is what the payrole money is directed to, but i'm wondering if _playerteam would be better. Since i want to where everyone in the group doesn't get money if only one guy is in the area, thus each individual gets paid based on if they are owner and in zone.

i was in a hurry and copied the wrong filename. I'm sorry for any wasted time this may have caused. thanks for clearing it up agentrev.

Re: Limited territory pay out range

« Reply #9 posted: Jun 17, 2016, 05:08 PM »
i was in a hurry and copied the wrong filename. I'm sorry for any wasted time this may have caused. thanks for clearing it up agentrev.

Oh no I don't mind, after all trying to get it work in the wrong file helped me understand the format a bit better.

Also agent the script is working now but you still get paid for all territories you are holding, thus a zone you hold on the other side of the map you still get paid for if you are near another captured.
Fixed that issue by going into payroll and cutting out _count thus removing the multiplier.

Ok so after testing it out on a hosted match with a friend. When i capped a territory it gave myself and my friend both the not in range message. And the payroll said i wasn't in range when I was sitting on the territory itself and also gave the message to myfriend who wasn't in my group.
Now we tested it with him as group lead and in zone with me, this resulted in him getting the pay out but I still got the message saying I wasn't in range and I got no money.
This is the script as is now
Code: [Select]
// Called with [_message, _money(optional)], "A3W_fnc_territoryActivityHandler", side, false] call A3W_fnc_MP;

diag_log format["A3W_fnc_territoryActivityHandler called with %1", _this];

if (typeName _this == "ARRAY" && {count _this >= 1}) then {
_msg = _this select 0;
_money = 0; if (count _this >= 2) then { _money = _this select 1; };

_inrange_payout = false;
{
if ((_x select 2) in [group player, playerSide] && {player distance markerPos (_x select 0) <= 300}) exitWith
{
_inrange_payout = true;
};
} forEach currentTerritoryDetails;
if (_inrange_payout) then
      {
         player setVariable ["cmoney", (player getVariable ["cmoney", 0]) + _money, true];
titleText [_msg, "plain down", 0.5];
      }
      else
      {
titleText ["You are more than 300m away from the captured territory so you received no money.", "plain down", 0.5];
      };

playSound 'FD_Finish_F'; // Nice sound effect to draw players attention to the notification
};

Right now after finding out the script is noting the host which is my frined, i'm now just trying to find the defining value for the territory owner. And not the whole team or just the host but the individual owner or the individual in the owning group that is on independent.

Re: Limited territory pay out range

« Reply #10 posted: Jun 18, 2016, 02:17 PM »
Ok so i got stuff working I literally said **** it and just looked up the saves files from missions I played that had this feature. And simply just cut it up and made it work in my mission file.
  • Offline eldude
  • Fresh Spawn
  • *
  • Posts: 11

Re: Limited territory pay out range

« Reply #11 posted: May 16, 2018, 12:08 AM »
Ok so i got stuff working I literally said **** it and just looked up the saves files from missions I played that had this feature. And simply just cut it up and made it work in my mission file.

Hi Ivan,

do you mind sharing the code you found in the end please?

Thanks.