Jump to content

Put coins on AI?


Recommended Posts

Somethimes it happens when checking wallets of DZMS AI's:

You took <NULL>  coins, ID says <NULL>!

All coins on screen are gone only solution -> relog

Anyone a solution for this?

 

I use this code in my DZMSAISpawn.sqf:
    //Zupa Currency
     _cash = round(random 20) * 100; // number between 0 and 20 00
    _unit setVariable["cashMoney",_cash,true];

Link to comment
Share on other sites

Somethimes it happens when checking wallets of DZMS AI's:

You took <NULL>  coins, ID says <NULL>!

All coins on screen are gone only solution -> relog

Anyone a solution for this?

 

I use this code in my DZMSAISpawn.sqf:

    //Zupa Currency

     _cash = round(random 20) * 100; // number between 0 and 20 00

    _unit setVariable["cashMoney",_cash,true];

 

Same here.

Link to comment
Share on other sites

Then you guys are not using the Souls Hive. Change the variable to the SC version you are using

 

My bad, I left out the part about using SC 3.0 and a default hive. The null only comes up when looting coins from DZMS AI.  I haven't seen or heard problems with coins and DZAI or WAI. The only thing I can see different when looting coins from DZMS AI, is there's no name assigned to the AI unit.

 

Correction:  It seems to only cause problems with DZMS and WAI.  Works flawless with DZAI

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

 

change

		_unit enableAI "TARGET";
		_unit enableAI "AUTOTARGET";
		_unit enableAI "MOVE";
		_unit enableAI "ANIM";
		_unit enableAI "FSM";
		_unit setCombatMode ai_combatmode;
		_unit setBehaviour ai_behaviour;
		removeAllWeapons _unit;
		removeAllItems _unit;
		_unit addweapon _weapon;

to 

		_unit enableAI "TARGET";
		_unit enableAI "AUTOTARGET";
		_unit enableAI "MOVE";
		_unit enableAI "ANIM";
		_unit enableAI "FSM";
		_unit setCombatMode ai_combatmode;
		_unit setBehaviour ai_behaviour;
		removeAllWeapons _unit;
		removeAllItems _unit;
		_unit addweapon _weapon;

                // Soul Hive
		_unit setVariable["CashMoney",5000,true];
                // 999 Hive
                _unit setVariable["headShots",5000,true];

Or how much cash u want, i put 5000 now, change that number to your likings

 

 

If u want like random generated cash try this:

 

Between 0 to 20000 ( always +1000)


		_unit enableAI "TARGET";
		_unit enableAI "AUTOTARGET";
		_unit enableAI "MOVE";
		_unit enableAI "ANIM";
		_unit enableAI "FSM";
		_unit setCombatMode ai_combatmode;
		_unit setBehaviour ai_behaviour;
		removeAllWeapons _unit;
		removeAllItems _unit;
		_unit addweapon _weapon;


                _cash = round(random 20) * 1000; // number between 0 and 20 000

                // Soul Hive
		_unit setVariable["CashMoney",_cash ,true];
                // 999 Hive
                _unit setVariable["headShots",_cash ,true];

Zupa will this work with your new coin system: Single Currency 3.0 & Storage DEFAULT HIVE ( No global banking).

Link to comment
Share on other sites

  • 2 months later...

to stop the null message I used
 
 

//give coin
_coinsRandom = random 1;
if (_coinsRandom <= 0.5) then {
_cash = round(random 20) * 5; // number between 0 and 100
_unit setVariable["CashMoney",_cash ,true];
} else {
_cash = 0;
_unit setVariable["CashMoney",_cash ,true];
};
//end of coins

Link to comment
Share on other sites

  • 2 months later...

Zupa will this work with your new coin system: Single Currency 3.0 & Storage DEFAULT HIVE ( No global banking).

I am trying to add this to my server as well,. I have the latest wai and,dzsm and dzai, I have only added what kat has added for the wai system . I get this is the Rpt for the wai system 3:03:07   Error Undefined variable in expression: mission_announce

 3:03:07 File z\addons\dayz_server\modules\Construction.sqf, line 171
 3:03:08 Error in expression <tnumber = count _position;
 
if(_aitype == "Hero") then {
_unitGroup = createGro>
 3:03:08   Error position: <== "Hero") then {
_unitGroup = createGro>
 3:03:08   Error Generic error in expression
 3:03:08 File z\addons\dayz_server\WAI\compile\spawn_static.sqf, line 32
 3:03:08 Error in expression <= time;
_unarmed = false;
 
if(_aitype == "Hero") then {
_unitGroup = createGro>
 3:03:08   Error position: <== "Hero") then {
_unitGroup = createGro>
 3:03:08   Error ==: Type Bool, expected Number,String,Object,Side,Group,Text,Config entry,Display (dialog),Control,Team member,Task,Location
 3:03:08 File z\addons\dayz_server\WAI\compile\spawn_group.sqf, line 42
 3:03:08 Error in expression <= time;
_unarmed = false;
 
if(_aitype == "Hero") then {
_unitGroup = createGro>
I would put in spoiler but I am not sure how.
Link to comment
Share on other sites

  • 6 months later...
On 12/5/2014 at 1:11 AM, kat said:

WAI:

 

spawn_group.sqf

 

Find


call {
      if(_aitype == "hero")         exitWith { _unit setVariable ["Hero",true]; _unit setVariable ["humanity", ai_remove_humanity]; };
      if(_aitype == "bandit")     exitWith { _unit setVariable ["Bandit",true]; _unit setVariable ["humanity", ai_add_humanity]; };
      if(_aitype == "special")     exitWith { _unit setVariable ["Special",true]; _unit setVariable ["humanity", ai_special_humanity]; };
     };

Replace with


call {
      if(_aitype == "hero")  exitWith { _unit setVariable ["Hero",true]; _unit setVariable ["humanity", ai_remove_humanity]; _unit setVariable ["cashMoney", ai_hero_amount]; };
      if(_aitype == "bandit")  exitWith { _unit setVariable ["Bandit",true]; _unit setVariable ["humanity", ai_add_humanity]; _unit setVariable ["cashMoney", ai_bandit_amount]; };
      if(_aitype == "special")  exitWith { _unit setVariable ["Special",true]; _unit setVariable ["humanity", ai_special_humanity]; _unit setVariable ["cashMoney", ai_special_amount]; };
     };

on_kill.sqf

 

Add


_playerCoins    = _player getVariable["cashMoney",0];
_unitCoins      = _unit   getVariable["cashMoney",0];
Under

_banditkills    = _player getVariable["banditKills",0];
_humankills     = _player getVariable["humanKills",0];

Add


if (ai_coin_award) then {
     _player setVariable ["cashMoney",(_playerCoins + _unitCoins),true];
};

Under


if (ai_humanity_gain) then {
     _gain = _unit getVariable ["humanity", 0];
     call {
        if (_unit getVariable ["Hero", false]) exitWith { _player setVariable ["humanity",(_humanity - _gain),true]; };
        if (_unit getVariable ["Bandit", false]) exitWith { _player setVariable ["humanity",(_humanity + _gain),true]; }; 
        if (_unit getVariable ["Special", false]) exitWith { if (_humanity < 0) then { _player setVariable ["humanity",(_humanity - _gain),true]; } else { _player setVariable ["humanity",(_humanity + _gain),true]; }; };
    };
};

Config.sqf

 

Add


ai_coin_award = true;
ai_hero_amount = 200;
ai_bandit_amount = 200;
ai_special_amount = 300;

Change the values to what you want. 

 

Under


ai_special_humanity = 150;

If your using an older version of SC then change 'cashMoney' to 'headShots'

 

This is works perfectly.

 

Thanks

Link to comment
Share on other sites

  • 3 weeks later...
On 12/5/2014 at 2:11 AM, kat said:

WAI:

 

spawn_group.sqf

 

Find


call {
      if(_aitype == "hero")         exitWith { _unit setVariable ["Hero",true]; _unit setVariable ["humanity", ai_remove_humanity]; };
      if(_aitype == "bandit")     exitWith { _unit setVariable ["Bandit",true]; _unit setVariable ["humanity", ai_add_humanity]; };
      if(_aitype == "special")     exitWith { _unit setVariable ["Special",true]; _unit setVariable ["humanity", ai_special_humanity]; };
     };

Replace with


call {
      if(_aitype == "hero")  exitWith { _unit setVariable ["Hero",true]; _unit setVariable ["humanity", ai_remove_humanity]; _unit setVariable ["cashMoney", ai_hero_amount]; };
      if(_aitype == "bandit")  exitWith { _unit setVariable ["Bandit",true]; _unit setVariable ["humanity", ai_add_humanity]; _unit setVariable ["cashMoney", ai_bandit_amount]; };
      if(_aitype == "special")  exitWith { _unit setVariable ["Special",true]; _unit setVariable ["humanity", ai_special_humanity]; _unit setVariable ["cashMoney", ai_special_amount]; };
     };

on_kill.sqf

 

Add


_playerCoins    = _player getVariable["cashMoney",0];
_unitCoins      = _unit   getVariable["cashMoney",0];
Under

_banditkills    = _player getVariable["banditKills",0];
_humankills     = _player getVariable["humanKills",0];

Add


if (ai_coin_award) then {
     _player setVariable ["cashMoney",(_playerCoins + _unitCoins),true];
};

Under


if (ai_humanity_gain) then {
     _gain = _unit getVariable ["humanity", 0];
     call {
        if (_unit getVariable ["Hero", false]) exitWith { _player setVariable ["humanity",(_humanity - _gain),true]; };
        if (_unit getVariable ["Bandit", false]) exitWith { _player setVariable ["humanity",(_humanity + _gain),true]; }; 
        if (_unit getVariable ["Special", false]) exitWith { if (_humanity < 0) then { _player setVariable ["humanity",(_humanity - _gain),true]; } else { _player setVariable ["humanity",(_humanity + _gain),true]; }; };
    };
};

Config.sqf

 

Add


ai_coin_award = true;
ai_hero_amount = 200;
ai_bandit_amount = 200;
ai_special_amount = 300;

Change the values to what you want. 

 

Under


ai_special_humanity = 150;

If your using an older version of SC then change 'cashMoney' to 'headShots'

 

anybody know how to make the coins random with this method.  I've been trying for a few days now and cant figure it out lol

Link to comment
Share on other sites

		if (!_unarmed) then {
			for "_i" from 1 to _mags do {
				_unit addMagazine _magazine;
			};
			_unit addweapon _weapon;
			_unit selectWeapon _weapon;
			_cash = round(random 20) * 100; // number between 0 and 20 000
            _unit setVariable["CashMoney",_cash ,true];
		};

^^^^^^^^ WAI

	//Add the behaviour
	_unit enableAI "TARGET";
	_unit enableAI "AUTOTARGET";
	_unit enableAI "MOVE";
	_unit enableAI "ANIM";
	_unit enableAI "FSM";
	_unit setCombatMode "RED";
	_unit setBehaviour "COMBAT";
	_cash = round(random 20) * 100; // number between 0 and 20 000
	_unit setVariable["CashMoney",_cash,true];

^^^^^^^^^ DZMS

 

That's how mine is, much easier :)

Link to comment
Share on other sites

i agree its much easier, this is what  i had previously. the only issue is i get the "null" option when picking up coins. and anything a player does after that, doesnt save.  And they can take advantage of the bug if they know what they are doing.

The method above gives you the coins when you kill the ai, just like humanity.  Would stop the check wallet bug.  But i need it a random number lol

Link to comment
Share on other sites

Ok so it pays off to be persistent lol.  I managed to get the random coins given to you when killing an AI, just like the humanity.

This is meant to try and stop the null coins issue when checking wallets.

I use single currency 2.0. so the variables might be different for other versions of single currency.

For WAI, do this

Spoiler

open your config.sqf

find this


ai_special_humanity			= 150;

add this bellow


ai_coin_award				= true;  		// gain Money for killing AI

then open your compile\on_kill.sqf (in your compiles folder)

find this


_humankills 	= _player getVariable["humanKills",0];

add this bellow


_money = round(random 20) * 500; // Any number between 0 and 20 000

still in the on_kill sqf, find this


if (ai_humanity_gain) then {
			_gain = _unit getVariable ["humanity", 0];
			call {
				if (_unit getVariable ["Hero", false]) exitWith { _player setVariable ["humanity",(_humanity - _gain),true]; };
				if (_unit getVariable ["Bandit", false]) exitWith { _player setVariable ["humanity",(_humanity + _gain),true]; };					
				if (_unit getVariable ["Special", false]) exitWith { if (_humanity < 0) then { _player setVariable ["humanity",(_humanity - _gain),true]; } else { _player setVariable ["humanity",(_humanity + _gain),true]; }; };
			};
		};

add this bellow


if (ai_coin_award) then {
			_cash = _player getVariable ["cashMoney", 0];
			call {
				if (_unit getVariable ["Hero", false]) exitWith { _player setVariable ["cashMoney",(_cash + _money),true]; };
				if (_unit getVariable ["Bandit", false]) exitWith { _player setVariable ["cashMoney",(_cash + _money),true]; };					
				if (_unit getVariable ["Special", false]) exitWith { _player setVariable ["cashMoney",(_cash + _money),true]; };
			};
		};

save the files

For DAZI, do this

Spoiler

open your init\DAZ_config.sqf

find this


DZAI_humanityGain = 50;

add this bellow


//Amount of money to reward player for killing an AI unit (Default: 0)									
DZAI_moneyGain = true;	

open your compile\fn_countkills.sqf

find this


_killer setVariable [_killType,(_killCount +1),true];

add this bellow


_money = round(random 20) * 500; // number between 0 and 20 000

still in the compile\fn_countkills.sqf

find this


if (DZAI_humanityGain != 0) then {
	_humanity = _killer getVariable["humanity",0];
	_humanity = _humanity + DZAI_humanityGain;
	_killer setVariable["humanity",_humanity,true];
};

add this bellow


if (DZAI_moneyGain) then {
	_cash = _killer getVariable["cashMoney",0];
	_cash = _cash + _money;
	_killer setVariable["cashMoney",_cash,true];
};

Save your files

For DZMS do this

Spoiler

open your DZMSconfig.sqf

find this


DZMSCntHumanity = 50;

add this bellow


// add money when killing ais
DZMSaddmoney = true;

open your scripts\DZMSkilled.sqf

find this


_banditkills = _player getVariable ["banditKills",0];

add this bellow


_cash = _player getVariable ["cashMoney",0];
_money = round(random 20) * 500; // Any number between 0 and 20 000

still in scripts\DZMSkilled.sqf

find this


if (DZMSMissHumanity) then {
		_player setVariable ["humanity",(_humanity + DZMSCntHumanity),true];
	};

add this bellow


if (DZMSaddmoney) then {
		_player setVariable ["cashMoney",(_cash + _money),true];
	};

save your files

Its been tested it works.  I have not tested this for the long range with a base of players. Only on my test server.

For being able to change the range or random coins given, alter what is in bold

_money = round(random 20) * 500;      20 * 500.  So basically the max is 10 000. 250 would be 5000 max

Now as for being able to check your own wallet and players wallets i would suggest this fix by KoTaS

it removes the check wallet option from AIs and you only get the option for players

 

Also if you have plot 4 life i would suggest reading my post in that thread just bellow his, just need to change one variable.

Thanks to Zupa and team for the amazing coin script. Thanks Kotas for your check wallet fix. and thanks to the creators of the AI systems (sry i dont know all the names and i know they've been passed around a bit lol, but TY)

on a side note. Im not a coder by any means. i copy and pasted some code and changed variables. If someone with experience can shed light if it can be done cleaner please let me know.

Duke

Link to comment
Share on other sites

  • 6 months later...
26 minutes ago, Bricktop said:

Old post I know - I just reinstalled DZAI and can't figure out how to add the coin ...

Tried and failed x3 - Could someone sort me out here?

What code and where would I put it to add random (1000-20000) coin to DZAI patrols.

Thanks for any help!

 

https://gist.github.com/anonymous/4e1e92199d9f777f0bdb4fc66f654aaa

Under:

if ((getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) < 8) then {_unit addMagazine _magazine};

Try pasting this:

_aicash = round(random 100) * 197;
_unit setVariable["cashMoney",_aicash ,true];

 

Link to comment
Share on other sites

1 hour ago, BigEgg said:

Under:


if ((getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) < 8) then {_unit addMagazine _magazine};

Try pasting this:


_aicash = round(random 100) * 197;
_unit setVariable["cashMoney",_aicash ,true];

 

Thanks @BigEgg! 

Testing on next reset ...

 

EDIT - WORKS PERFECT!! - 

anyone using DZAI this method works to add coins to your patrols.

Thanks again BigEgg ~

BigBigEgg

Link to comment
Share on other sites

On 8/6/2016 at 1:49 AM, Bricktop said:

Thanks @BigEgg! 

Testing on next reset ...

 

EDIT - WORKS PERFECT!! - 

anyone using DZAI this method works to add coins to your patrols.

Thanks again BigEgg ~

BigBigEgg

Do you still use the check wallet option? If so do you have issues with coins saying NULL?

Link to comment
Share on other sites

I do use check wallet but don't seem to have any issues with NULL -

However my players have been mentioning a negative value in coins like (-75k) or (- 750k)

I can use infistar to give them coins back but this is becoming quite the problem lately ...

Looking for information on the now 

Link to comment
Share on other sites

On 8/7/2016 at 4:18 PM, Bricktop said:

I do use check wallet but don't seem to have any issues with NULL -

However my players have been mentioning a negative value in coins like (-75k) or (- 750k)

I can use infistar to give them coins back but this is becoming quite the problem lately ...

Looking for information on the now 

my post just above your first post explains how to remove the check wallet option from AIs, and when you kill AIs it automatically gives you coins.  Since i changed that, i havnt had issues with negative coins or the NULL issue.

Link to comment
Share on other sites

  • 4 months later...

Hello

i would ask You for help :) I add coins into AI (theduke option from few post above - it's working perfectly!) on kill but it would be cool when person who killed AI got some message with amount of coins he got for kill. I tried add info in script in file fn_countkills.sqf by adding one line:

 

if (DZAI_moneyGain) then {


    _cash = _killer getVariable["headShots",0];
    systemChat format ['You took coins '_cash];
    _cash = _cash + _money;
    _killer setVariable["headShots",_cash,true];
    
};

Not lucky - not working, no msg :)

 

For me fine would be when person who killed AI got Message: "(Unit name) was killed" add here something like this: "(Unit name) was killed. You gain XX coins bounty." 

 

I tried to find in files/code place where is line for this (Unit name was killed) and i didnt found it :( Could some one show me? Or help with above?

 

Of course above is only for DZAI, for Wicked AI isnt any message for killing, it's possible to add this too? 

 

Im using only epoch server files, 1.0.5.1,

Wicked AI 2.2.0 - https://epochmod.com/forum/topic/15671-release-wicked-ai-220/

Single Currency Banking 1.1 - https://epochmod.com/forum/topic/15177-release-single-currency-banking-11/

DZAI - http://opendayz.net/threads/dzai-visual-installation-guide.18447/

 

Link to comment
Share on other sites

  • 3 months later...
21 hours ago, DY357LX said:

Anyone managed to add coins to DZAI using @salival's ZSC for Epoch 1.0.6.1 files?

Yep sure. It's easy. Here you go:

Go to server.pbo\DZAI\compile\ai_setup_loadout.sqf

Search for this line:

if ((getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) < 8) then {_unit addMagazine _magazine};

Add this below:

_cash = round(random 20) * 100;
_unit setVariable[Z_moneyVariable,_cash,true];

That's a random number of coins between 0 and 2000. If you want more just change the 20 behind the "random".

Link to comment
Share on other sites

3 hours ago, DAmNRelentless said:

Yep sure. It's easy. Here you go:

Go to server.pbo\DZAI\compile\ai_setup_loadout.sqf

Search for this line:


if ((getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) < 8) then {_unit addMagazine _magazine};

Add this below:


_cash = round(random 20) * 100;
_unit setVariable[Z_moneyVariable,_cash,true];

That's a random number of coins between 0 and 2000. If you want more just change the 20 behind the "random".

I would do it in ai_death.sqf instead so you're only broadcasting the unit having coins if it dies. Saves unnecessarily sending stuff over the network

 

Maybe before this: https://github.com/oiad/DZAI/blob/master/DZAI/compile/ai_death.sqf#L83

Link to comment
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
  • Advertisement
×
×
  • Create New...