Jump to content

Recommended Posts

Hello there,

 

as the title already says I got a problem with my capture script (with no Syntax-Errors).

 

fn_moneyPointBlu.sqf:

Spoiler

/*
	File: core\blu\fn_moneyPointBlu.sqf
	Author: TheDusty01
	
	Description:
	Handles the money points.
*/
_c = varHolder getVariable ["moneyCounter", 0];

_mName = "";
_point = getMarkerPos _mName;

if (_c == 0) then {
	_mName = "blu_money_1";
	_point = getMarkerPos _mName;
};
if (_c == 1) then {
	_mName = "blu_money_2";
	_point = getMarkerPos _mName;
	_c = 0;
};

_blu = 0;
_opf = 0;
_ind = 0;

_infantry = _point nearEntities ["Man", 30];
_vehicles = _point nearEntities [["Air", "Car", "Motorcycle", "Tank"], 30];

{
	/* Count the infantry for each team */
	switch (side _x) do {
		// Get blufor infantry count
		case west: {
			_blu = _blu + 1;
		};

		// Get opfor infantry count
		case east: {
			_opf = _opf + 1;
		};

		// Get independent infantry count
		case independent: {
			_ind = _ind + 1;
		};
	};
} forEach _infantry;

{
	/* Count the infantry for each team in the vehicle */
	_crew = crew _x;
	switch (side _crew) do {
		// Get blufor infantry count
		case west: {
			_blu = _blu + 1;
		};

		// Get opfor infantry count
		case east: {
			_opf = _opf + 1;
		};

		// Get independent infantry count
		case independent: {
			_ind = _ind + 1;
		};
	};

} forEach _vehicles;

/* Calculate who owns the objective */
_controlled = "";
_players = 0;
_color = "ColorBlack";

// Tie
if (_blu + _opf + _ind == 0) then {
	_controlled = "tie";
	_color = "ColorGrey";
	hint "tie";
} else {
	// Blufor
	if (_blu > _opf && _blu > _ind) then {
		_controlled = "blu";
		_color = "ColorWEST";
		_players = _blu;
	};

	// Opfor
	if (_opf > _blu && _opf > _ind) then {
		_controlled = "opf";
		_color = "ColorEAST";
		_players = _opf;
	};

	// Independent
	if (_ind > _blu && _ind > _opf) then {
		_controlled = "ind";
		_color = "ColorGUER";
		_players = _ind;
	};
};
_mName setMarkerColor _color;
if !(_controlled isEqualTo "tie") then {
	[_controlled, _players] call game_fnc_moneyGive;
};

// Handling the other point
_c = 1;
varHolder setVariable ["moneyCounter", _c, true];

 

alt: http://pastebin.com/BcvMmrcw

The problem with this is that the color isn't changing back to "ColorBlack" when nobody is in the sector.

 

fn_moneyGive.sqf:

Spoiler

/*
	File: core\functions\fn_moneyGive.sqf
	Author: TheDusty01
	
	Description:
	Add the money to the controlling team.
*/
#include "..\..\script_macros.hpp"

private ["_faction", "_plrs"];
_faction = _this select 0;
_plrs = _this select 1;

_obj = varHolder;
_amount = GAME_SETTINGS(getNumber, "money_amount");

_bluforMoney = _obj getVariable "bluforMoney";
_opforMoney = _obj getVariable "opforMoney";
_independentMoney = _obj getVariable "independentMoney";

// Calculate the reward
_finalAmount = _plrs * _amount;

// Adding the money to the team
if (_faction isEqualTo "blu") then {
	_bluforMoney = _bluforMoney + _finalAmount;
};
if (_faction isEqualTo "opf") then {
	_opforMoney = _opforMoney + _finalAmount;
};
if (_faction isEqualTo "ind") then {
	_independentMoney = _independentMoney + _finalAmount;
};

_obj setVariable ["bluforMoney", _bluforMoney, true];
_obj setVariable ["opforMoney", _opforMoney, true];
_obj setVariable ["independentMoney", _independentMoney, true];

 

alt: http://pastebin.com/1dHjZE50

 

How I execute the first script (fn_moneyPointBlu.sqf):

/*
	File: core\functions\fn_mainLoop.sqf
	Author: TheDusty01
	
	Description:
	Main loop for all capturable points.
*/
_game_active = varHolder getVariable "game_active";

while {_game_active} do {
	sleep 4;
	
	// Setting up the money system
	[] call game_fnc_moneyPointBlu;
	[] call game_fnc_moneyPointOpf;
	[] call game_fnc_moneyPointInd;

	// Setting up the capture points
	[] call game_fnc_capPoints;
};

 

If someone has any ideas post them down below please.

 

Thanks for help in advance,

TheDusty01

Share this post


Link to post
Share on other sites

Oh I see, it should be 

if ((_blu + _opf + _ind) == 0) then {
	// bla bla
};

 

Edit:

Oh I am so stupid.. That wouldn't be really a tie but still this isn't the problem. When I am inside of the the area in still says over and over tie even when I am in it.

But why?

Share this post


Link to post
Share on other sites
if (_blu + _opf + _ind != 0) then {
	if ({selectMax [_blu, _opf, _ind] isEqualTo _x} count [_blu, _opf, _ind] > 1) then {
		...tie...
	} else {
		switch (selectMax [_blu, _opf, _ind]) do {
			case _blu: {...blu...};
			case _opf: {...opf...};          
			case _ind: {...ind...};
		};
	};
};

I believe the tie you look for is when the population is something else than 0.

 

Also the condition to give money probably should be:

if !(_controlled in ["", "tie"]) then {

 

  • Like 1

Share this post


Link to post
Share on other sites
30 minutes ago, kauppapekka said:

if (_blu + _opf + _ind != 0) then {
	if ({selectMax [_blu, _opf, _ind] isEqualTo _x} count [_blu, _opf, _ind] > 1) then {
		...tie...
	} else {
		switch (selectMax [_blu, _opf, _ind]) do {
			case _blu: {...blu...};
			case _opf: {...opf...};          
			case _ind: {...ind...};
		};
	};
};

I believe the tie you look for is when the population is something else than 0.

 

Also the condition to give money probably should be:


if !(_controlled in ["", "tie"]) then {

 

Gonna try it later since I don't have time now.

Nvm, I just tried it and it didn't worked.. Stays black so it doesn't count as a tie even when I am inside the sector as a blufor soldier (which should execute the blufor part and the marker should be blue).

 

Thanks for your help though! :)

Share this post


Link to post
Share on other sites

Fixed the vehicle crew part:

Spoiler

{
	{
		switch (side _x) do {

			case west: {
				_blu = _blu + 1;
			};

			case east: {
				_opf = _opf + 1;
			};

			case independent: {
				_ind = _ind + 1;
			};
		};
	} forEach crew _x;
} forEach _vehicles;

 

 

 

And then put a marker down "marker_0" and executed this code from the debug console:

Spoiler

[] spawn {
    while {true} do { 
        _mName = "marker_0"; 
        _point = getMarkerPos _mName; 

        _blu = 0; 
        _opf = 0; 
        _ind = 0; 

        _infantry = _point nearEntities ["Man", 30]; 
        _vehicles = _point nearEntities [["Air", "Car", "Motorcycle", "Tank"], 30]; 

        { 
            switch (side _x) do { 
                case west: {_blu = _blu + 1;}; 
                case east: {_opf = _opf + 1;}; 
                case independent: {_ind = _ind + 1;}; 
            }; 
        } forEach _infantry; 


        { 
            { 
                switch (side _x) do { 
                    case west: {_blu = _blu + 1;}; 
                    case east: { _opf = _opf + 1;}; 
                    case independent: {_ind = _ind + 1;}; 
                }; 
            } forEach crew _x; 
        } forEach _vehicles; 


         hintSilent str [_blu, _opf, _ind];

        _controlled = "";
        _players = 0; 
        _color = "ColorBlack"; 

        if (_blu + _opf + _ind != 0) then { 
            if ({selectMax [_blu, _opf, _ind] isEqualTo _x} count [_blu, _opf, _ind] > 1) then { 
                _controlled = "tie"; 
                _color = "ColorGrey"; 
            } else { 
                switch (selectMax [_blu, _opf, _ind]) do { 
                
                    case _blu: {  
                        _controlled = "blu"; 
                        _color = "ColorWEST"; 
                        _players = _blu;
                    }; 
                    
                    case _opf: {
                        _controlled = "opf"; 
                        _color = "ColorEAST"; 
                        _players = _opf; 
                    };     
                    
                    case _ind: {
                        _controlled = "ind"; 
                        _color = "ColorGUER"; 
                        _players = _ind; 
                    }; 
                }; 
            }; 
        };
        _mName setMarkerColor _color; 

    }; 
}; 

 

 

Share this post


Link to post
Share on other sites
20 hours ago, TheDusty01 said:

_game_active = varHolder getVariable "game_active";

while {_game_active} do {
	sleep 4;

};

 

This is an endless cycle that will never end (or never begin)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×