Jump to content

Recommended Posts

Hey all, so I've gotten my hands on a money system/shop that I've heavily modified now. I am having a problem though, so before I state my issue, yes I've contacted the author, his thread is fairly old so I'm not sure he even comes to forums any longer, and yes I've attempted to fix this myself to no succession. So my issue is the kill reward doesn't seem to work at all. I have it enabled in script, I'm using this with the ravage modules but I don't get any reward when killing zombies/enemy AI. If someone wouldn't mind just helping me figure out how to activate this and get it working it'd be much appreciated. Here all the scripting below:

 

if(!isServer) exitWith {true};

params["_ai"];

// _ai represents the passed AI unit to the function
if((typeName _ai) != "OBJECT") exitWith {diag_log format[(localize "STR_HG_ERR_NOT_OBJECT"),"HG\Functions\Client\AI\fn_aiUnitSetup.sqf"];};
if(!(_ai isKindOf "Man")) exitWith {diag_log format[(localize "STR_HG_ERR_NOT_MAN"),"HG\Functions\Client\AI\fn_aiUnitSetup.sqf"];};
if(isPlayer _ai) exitWith {diag_log format[(localize "STR_HG_ERR_PLAYER"),"HG\Functions\Client\AI\fn_aiUnitSetup.sqf"];};

if((getNumber(getMissionConfig "CfgClient" >> "enableKillReward")) isEqualTo 1) then
{
    _ai addEventHandler
    [
        "Killed",
        {
            params ["_unit","_killer","_instigator"];

			if((!isPlayer _instigator) OR {_instigator isEqualTo _unit}) exitWith {};
			
            if((side (group _unit)) isEqualTo (side (group _instigator))) then
            {
                if((getNumber(getMissionConfig "CfgClient" >> "enableTeamKillPenalty")) isEqualTo 1) then
                {
                    [(getNumber(getMissionConfig "CfgClient" >> "HG_MasterCfg" >> (rank _unit) >> "tkPenaltyAI")),1] remoteExecCall ["HG_fnc_addOrSubCash",_instigator,false];
					if((getNumber(getMissionConfig "CfgClient" >> "enableXP")) isEqualTo 1) then
					{
						[(getNumber(getMissionConfig "CfgClient" >> "HG_MasterCfg" >> (rank _unit) >> "xpPenaltyAI")),1] remoteExecCall ["HG_fnc_addOrSubXP",_instigator,false];
					};
                };
            } else {
                [(getNumber(getMissionConfig "CfgClient" >> "HG_MasterCfg" >> (rank _unit) >> "killedReward")),0] remoteExecCall ["HG_fnc_addOrSubCash",_instigator,false];
				if((getNumber(getMissionConfig "CfgClient" >> "enableXP")) isEqualTo 1) then
				{
					[(getNumber(getMissionConfig "CfgClient" >> "HG_MasterCfg" >> (rank _unit) >> "xpReward")),0] remoteExecCall ["HG_fnc_addOrSubXP",_instigator,false];
				};
				if(((getNumber(getMissionConfig "CfgClient" >> "enableKillCount")) isEqualTo 1) AND ((getNumber(getMissionConfig "CfgClient" >> "enableHUD")) isEqualTo 1)) then
				{
					[0] remoteExecCall ["HG_fnc_addOrSubKills",_instigator,false];
				};
            };
        }
    ];
};

_ai addEventHandler
[
    "HandleRating",
    {
        params["_unit","_rating"];

        if(_rating <= 0) then
        {
            _rating = 0;
        };

        _rating;
    }
];

true;

Thank you.

Share this post


Link to post
Share on other sites

I've resolved this. This can be closed.

 

EDIT: Not resolved, solution didn't work.

Share this post


Link to post
Share on other sites

Always useful if you share the solution so that others can benefit from the thread if they come across similar issue.

  • Like 2

Share this post


Link to post
Share on other sites
8 minutes ago, HazJ said:

Always useful if you share the solution so that others can benefit from the thread if they come across similar issue.

I actually didn't resolve this, I tried and tested it but apparently I was wrong. Didn't bother editing my post because I figured I would have gotten a strike for bumping... If someone still wants to help that'd be great, otherwise I'm still trying things myself.

Share this post


Link to post
Share on other sites

Can you provide more information...

  • Config settings for HG
  • relevant HG_fnc_addOrSub# functions
  • How you are calling the code in your post on the AI units

 

Share this post


Link to post
Share on other sites
2 minutes ago, Larrow said:

Can you provide more information...

  • Config settings for HG
  • relevant HG_fnc_addOrSub# functions
  • How you are calling the code in your post on the AI units

 

Here the config file.
 

/* MONEY */
currencyType = "USD";
cashVariable = "HG_Cash";
bankVariable = "HG_Bank";

/* SYSTEMS */
resetSavedMoney = false;
enableHUD = true;
enablePaycheck = true;
enableKillReward = true;
enableTeamKillPenalty = true;
enableCrate = true;
enableGiveMoney = true;
enableBuyToGarage = true;
clearInventory = true;
storeVehiclesOnDisconnect = true;
deleteBodyOnDisconnect = false;
resetGaragesOnServerStart = false;
enablePlayerInventorySave = true;
enableVehicleInventorySave = true;
enableXP = true;
enableKillCount = true;
enableTags = true;
enableMarkers = true;
enableATM = true;
enableWhitelist = false;

/* WHITELIST */
whitelistSides[] = {"west"};

/* ADMINS */
admins[] = {"_SP_PLAYER_"};

/* KEYS */
atmKey = 0x14;
lockUnlockKey = 0x15;
giveMoneyKey = 0x23;
giveKeyKey = 0x21;
adminKey = 0x52;

/* SAVING */
savingMethod = "Profile";
extDBDatabase = "HG";
extDBProtocol = "SQL_CUSTOM";
extDBCustomFile = "custom.ini";

/* MASTER CFG */
class HG_MasterCfg
{
	class PRIVATE
	{
		paycheck = 8500;
		paycheckPeriod = 30;
		startCash = 10000;
		startBank = 20000;
		killedReward = 250;
		tkPenaltyPlayer = 500;
		tkPenaltyAI = 250;
		xpPenaltyPlayer = 10;
		xpPenaltyAI = 5;
		xpReward = 25;
		xpToLvlUp = 1000;
		iShopDiscount = 0;
		gShopDiscount = 0;
		vShopDiscount = 0;
	};
	class CORPORAL
	{
		paycheck = 10000;
		paycheckPeriod = 30;
		startCash = 10000;
		startBank = 20000;
		killedReward = 500;
		tkPenaltyPlayer = 1000;
		tkPenaltyAI = 500;
		xpPenaltyPlayer = 20;
		xpPenaltyAI = 10;
		xpReward = 20;
		xpToLvlUp = 1500;
		iShopDiscount = 2;
		gShopDiscount = 2;
		vShopDiscount = 2;
	};
	class SERGEANT
	{
		paycheck = 12500;
		paycheckPeriod = 30;
		startCash = 10000;
		startBank = 20000;
		killedReward = 750;
		tkPenaltyPlayer = 1500;
		tkPenaltyAI = 750;
		xpPenaltyPlayer = 30;
		xpPenaltyAI = 15;
		xpReward = 30;
		xpToLvlUp = 2000;
		iShopDiscount = 4;
		gShopDiscount = 4;
		vShopDiscount = 4;
	};
	class LIEUTENANT
	{
		paycheck = 8000;
		paycheckPeriod = 30;
		startCash = 10000;
		startBank = 20000;
		killedReward = 1000;
		tkPenaltyPlayer = 2000;
		tkPenaltyAI = 1000;
		xpPenaltyPlayer = 40;
		xpPenaltyAI = 20;
		xpReward = 40;
		xpToLvlUp = 2500;
		iShopDiscount = 6;
		gShopDiscount = 6;
		vShopDiscount = 6;
	};
	class CAPTAIN
	{
		paycheck = 10000;
		paycheckPeriod = 30;
		startCash = 10000;
		startBank = 20000;
		killedReward = 1500;
		tkPenaltyPlayer = 2500;
		tkPenaltyAI = 1250;
		xpPenaltyPlayer = 50;
		xpPenaltyAI = 25;
		xpReward = 50;
		xpToLvlUp = 3000;
		iShopDiscount = 8;
		gShopDiscount = 8;
		vShopDiscount = 8;
	};
	class MAJOR
	{
		paycheck = 12000;
		paycheckPeriod = 30;
		startCash = 10000;
		startBank = 20000;
		killedReward = 3000;
		tkPenaltyPlayer = 3000;
		tkPenaltyAI = 1500;
		xpPenaltyPlayer = 60;
		xpPenaltyAI = 30;
		xpReward = 60;
		xpToLvlUp = 3500;
		iShopDiscount = 10;
		gShopDiscount = 10;
		vShopDiscount = 10;
	};
	class COLONEL
	{
		paycheck = 14000;
		paycheckPeriod = 15;
		startCash = 10000;
		startBank = 20000;
		killedReward = 3500;
		tkPenaltyPlayer = 3500;
		tkPenaltyAI = 1750;
		xpPenaltyPlayer = 70;
		xpPenaltyAI = 35;
		xpReward = 70;
		xpToLvlUp = 0;
		iShopDiscount = 12;
		gShopDiscount = 12;
		vShopDiscount = 12;
	};
};

////////// DO NOT MODIFY //////////
class HG_DealersCfg
{
	#include "HG_DealersCfg.h"
};

class HG_GaragesCfg
{
    #include "HG_GaragesCfg.h"
};

class HG_GearShopCfg
{
    #include "HG_GearShopCfg.h"
};

class HG_ItemsShopCfg
{
    #include "HG_ItemsShopCfg.h"
};

class HG_TradersCfg
{
	#include "HG_TradersCfg.h"
};

class HG_VehiclesShopCfg
{
    #include "HG_VehiclesShopCfg.h"
};
//////////

As for your second and third questions im not quite sure what you mean.

  • Like 1

Share this post


Link to post
Share on other sites
9 minutes ago, Larrow said:

Can you provide more information...

  • Config settings for HG
  • relevant HG_fnc_addOrSub# functions
  • How you are calling the code in your post on the AI units

 

Heres the add/subtract kills function, not sure if you wanted this or the money so ill post the kills first:

params[["_mode",0,[0]],["_amount",1,[0]],"_oldVal","_newVal"];

_oldVal = player getVariable "HG_Kills";
_newVal = if(_mode isEqualTo 0) then {(_oldVal + _amount)} else {(_oldVal - _amount)};
if(_newVal < 0) then {_newVal = 0};

HG_CLIENT = [1,(getPlayerUID player),_newVal];
if(isServer) then
{
	[HG_CLIENT] call HG_fnc_clientToServer;
} else {
    publicVariableServer "HG_CLIENT";
};
HG_CLIENT = nil;
player setVariable ["HG_Kills",_newVal,true];

[4] call HG_fnc_HUD;

true;

heres the money:
 

params[["_amount",1,[0]],["_mode",0,[0]],["_where",0,[0]],"_oldVal","_newVal"];

if(!([_amount] call HG_fnc_isNumeric)) exitWith {hint (localize "STR_HG_NOT_A_NUMBER");};
if(_amount isEqualTo 0) exitWith {true;};

_oldVal = if(_where isEqualTo 0) then {(player getVariable HG_CASH_VAR)} else {(player getVariable HG_BANK_VAR)};
_newVal = if(_mode isEqualTo 0) then {(_oldVal + _amount)} else {(_oldVal - _amount)};
if(_newVal < 0) then {_newVal = 0};

HG_CLIENT = [[0,(getPlayerUID player),_newVal],[3,(getPlayerUID player),_newVal]] select _where;
	
if(isServer) then
{
	[HG_CLIENT] call HG_fnc_clientToServer;
} else {
    publicVariableServer "HG_CLIENT";
};
	
HG_CLIENT = nil;

if(_where isEqualTo 0) then
{
    player setVariable [HG_CASH_VAR,_newVal,true];
	
	if(HG_HUD_ENABLED) then
    {
        [1] call HG_fnc_HUD;
    };
} else {
    player setVariable [HG_BANK_VAR,_newVal,true];
};

if(HG_ATM_ENABLED) then
{
	[] call HG_fnc_atmRefresh;
};

true;

 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Larrow said:

How you are calling the code in your post on the AI units

The code you show in your OP shows that it needs an AI passed to it...

6 hours ago, socs said:

params["_ai"]; // _ai represents the passed AI unit to the function

...it then adds an event to this AI for when it is killed...

6 hours ago, socs said:

_ai addEventHandler [ "Killed",

...without this the games never going to know when the unit is killed so wont run the HG functions to add/sub cash/rewards.

I dont know, maybe this is done manually by some initialisation of HG's system. Does the XP or kill count work? or is it just the reward? This will tell us whether the event is being added.

 

If you where to change the OP code and add the line as shown...

_ai addEventHandler
    [
        "Killed",
        {
            params ["_unit","_killer","_instigator"];
			
			//Add this line
			format[ "U: %1\nK: %2\nI: %3", _unit, _killer, _instigator ] remoteExec[ "hint", 0 ];
			
			if((!isPlayer _instigator) OR {_instigator isEqualTo _unit}) exitWith {};
			

...on killing an AI do you see the hint.

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, Larrow said:

The code you show in your OP shows that it needs an AI passed to it...

...it then adds an event to this AI for when it is killed...

...without this the games never going to know when the unit is killed so wont run the HG functions to add/sub cash/rewards.

I dont know, maybe this is done manually by some initialisation of HG's system. Does the XP or kill count work? or is it just the reward? This will tell us whether the event is being added.

 

If you where to change the OP code and add the line as shown...


_ai addEventHandler
    [
        "Killed",
        {
            params ["_unit","_killer","_instigator"];
			
			//Add this line
			format[ "U: %1\nK: %2\nI: %3", _unit, _killer, _instigator ] remoteExec[ "hint", 0 ];
			
			if((!isPlayer _instigator) OR {_instigator isEqualTo _unit}) exitWith {};
			

...on killing an AI do you see the hint.

Ill give this a try and edit this post to let you know

EDIT: No this did not work, I received no hit when killing any AI

Share this post


Link to post
Share on other sites
23 hours ago, socs said:

EDIT: No this did not work, I received no hit when killing any AI

Ok so the event is not being added.

 

On 9/23/2018 at 11:17 PM, socs said:

I'm using this with the ravage modules but I don't get any reward when killing zombies/enemy AI.

I presume you place modules to spawn zombies/enemy AI? Or are you placing these units as you would normally?

In the editor (if in fact by module) do these modules have an entry so you can add code to the units they spawn? As I am not familiar with Ravage.

 

If not then you may have to go the continuous while loop method, to get a reference to any spawned units and add the event to them.

  • Like 1

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

×