Jump to content
Sign in to follow this  
bigshotking

Store a value for each player

Recommended Posts

I'm trying to make a script that keeps track of how many civilians each player kills.

i.e.

Player1 has killed 1 civilian so a variable holding the number of kills is stored for that player.

Player2 has killed 3 civilian so a marker marks him on the map as hostile and changes his rating to -100.

In conclusion is there a way to store a value for each player?

Thanks for any help,

-Bigshot

Share this post


Link to post
Share on other sites

You can have a global array on the server:

civKillCounts = [];
civKillCounts set [0, [p1, 0]];
civKillCounts set [1, [p2, 0]];
...

And then you increase the second value that corresponds to player killing a civilian at first index.

Share this post


Link to post
Share on other sites

Sweet thank you Engima. If I run into any problems I'll be sure to post back

Share this post


Link to post
Share on other sites

You can also use set and getVariable on the player unit objects; http://community.bistudio.com/wiki/getVariable

Or Engima's example but easier lookup:

civKillUnits = [];
civKillCounts = [];

// update count
_id = count civKillUnits;
civKillUnits set [_id, _unit];
civKillCounts set [_id, _count];

// get killCount for specified unit:
_id = civKillUnits find _unit;
if (_id > -1) then {
 _count = civKillCounts select _id;
};

Edited by Sickboy

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  

×