Jump to content
Sign in to follow this  
ZenWarrior

Bounty script problem

Recommended Posts

Hi,

with the help of Clay, i added some bounty to enemy units.

Here´s an example:

for "_i" from 0 to 5 do

{

_man = objnull;

_side = createcenter CIVILIAN;

_grp = createGroup _side;

_zombies = (_zombarray select (floor(random(count _zombarray))));

_pos = (_posarray select (floor(random(count _posarray))));

_zombies createUnit [_pos,_grp,"_man = this",0.8];

[_man,0] execFSM "Scripts\Zombie\AI_Zombie_2.fsm";

_man setVariable ["Bounty", 5, true];

_man addMPEventHandler ["MPKilled",

{

_man = _this select 0;

_bounty = _man getVariable "Bounty";

_killer = this select 1;

DCV_Bank = DCV_Bank + _bounty;

player groupchat format ["You earned 5 Bounty for killing a Zombie!"];

}];

};

All works pretty good, but ALL players on the server get the bounty and the message if one kills a enemy unit.

In my init.sqf i have this line:

playerw = ["wman1","wman2","wman3","wman4","wman5","wman6","wman7","wman8","wman9","wman10","wman11","wman12","wman13","wman14","wman15","wman16","wman17","wman18","wman19","wman20","wman21","wman22","wman23","wman24"];

How can i check what player killed the unit and allocate the bounty just to him??

Sry for the newb questions but i´m still learning^^

Share this post


Link to post
Share on other sites

Check if the player is the killer

if (player == _killer) then {
     //he's the killer, do stuff here
};

Share this post


Link to post
Share on other sites

Thanks for the fast reply, i´ll try that out immediately.

I changed code to this:

_man setVariable ["Bounty", 5, true];

_man addMPEventHandler ["MPKilled",

{

_man = _this select 0;

_bounty = _man getVariable "Bounty";

_killer = this select 1;

if (player == _killer) then {

DCV_Bank = DCV_Bank + _bounty;

player groupchat format ["You earned 5 Bounty for killing a Zombie!"];

};

}];

};

Now i get no more bounty at all.

Edited by ZenWarrior

Share this post


Link to post
Share on other sites

_killer = _this select 1; your missing the underscore and you have an extra }; at the end remove it.

Share this post


Link to post
Share on other sites

Thank you F2k, it really just was the underscore... :rolleyes:

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  

×