Jump to content
Sign in to follow this  
Jackael

Money/WeaponDealer

Recommended Posts

This is a 2-part question;

I'm trying to have a system where you get money for killing certain units and then you can spend the money on weapons or vehicles. The way I imagine this would be done is with a variable that is increased by a certain amount when a trigger is fired (unit dies) but I don't know how to set up the variable or manipulate it.

From there on, I'm trying to have a sort of buying menu (could use a briefing template?) Any ideas there?

Share this post


Link to post
Share on other sites

A very simple approach would be to use the score of every player as a money alternative. That way you don't even need to use any triggers or unit lists, the game itself takes care of 'earning' it.

There are the "score player" and "player addScore x" commands you could work with.

Problem would be you can't easily deny the player getting money for specific enemy units and not for others. Also, if you kill friendlies and your score drops below 0, everyone will start firing on you.

Share this post


Link to post
Share on other sites

I would use:

unit addEventHandler ["killed", {[_this select 1,money] execVM "addmoney.sqf"}];
cash = 0;

unit - is the name of the unit for which killing you earn money

money - is the amount of money to earn for a kill

cash - is the amount of money you have on start

_this select 1 - it is the killer of the unit

in the script "addmoney.sqf" first of all I would check if the first parameter is player, if true, the variable cash is increased by the second parameter - if not true, this means that the unit was killed by someone else, so no money to player.

By using addEventHandler you can specify different amounts of money for different (more/less important) units. You must add an event handler for every unit you want money for killing it.

addmoney.sqf

_killer = _this select 0;
_money = _this select 1;

if (_killer == player) then {cash = cash + _money};

If you want to use a buying menu, I would prefer to create Dialogs. Read about them here: http://community.bistudio.com/wiki/Dialogs

Create a crate in the mission. Then do "clearWeaponCargo crate; clearMagazineCargo crate. By using the dialog menu, you will add weapons and magazines to that crate by addWeaponCargo and addMagazineCargo. It's better than adding weapons to the player himself, because you will not store any previous bought weapons and magazines and must remove all weapons and magazines from player before adding new ones.

Edited by RazorX

Share this post


Link to post
Share on other sites

If you don't want to use dialogs i'd recommend the conversation system. It's actually quite simple to use and makes it a bit more RPG like. :)

Share this post


Link to post
Share on other sites

I'm going to use the dialog system. Is there a demo template floating around anywhere?

Share this post


Link to post
Share on other sites

the dialog templates are on the wiki mentioned above

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
Sign in to follow this  

×