Sign in to follow this  
geekm0nkey

Making a simple counter.

7 posts in this topic

I am trying to get a grip on the various variable functions.  What I am trying to accomplish is make a counter, that checks against a value.. like this
 

_myvar = 4;
if (_iskilled => _myvar) Then
{
   // do something?
   _iskilled = 0;
};
else
{
   _iskilled = _iskilled + 1;
};

Need this to work in multiplayer of course, but does it need to be private, global, public? Does it need some sort of tag to track it per player?

Share this post


Link to post
Share on other sites

Not sure what exactly you're trying to achiev, would be better if you could provide a proper example for where you wanna use that counter. Like, the idea behind.

 

 

Edited by WURSTKETTE
  • Like 1

Share this post


Link to post
Share on other sites
Advertisement

I have spend the day reading over the arma wikis on coding.. I think I have it.. Will be testing soon..

_myvar = 4; // this is set elsewhere say in a config.

_ISKilled = _playerObj getVariable ["ISKilled", 0]; // get for this session
if (_ISKilled => _myvar) Then
{
   // do something?
   _ISKilled = 0; // reset back to 0
};
else
{
   _ISKilled = _ISKilled + 1;
};
_playerObj setVariable ["ISKilled", _ISKilled]; // set for this session

 

Share this post


Link to post
Share on other sites
2 hours ago, WURSTKETTE said:

Not sure what exactly you're trying to achiev, would be better if you could provide a proper example for where you wanna use that counter. Like, the idea behind.

I will, once i'm sure its working. ;)

Ok so it failed again... Here is the actual code... What i am attempting to do is modify DMS AiKillCredits.. I don't want it to be 1:1, as admittedly, killing AI is WAY to easy.. People on my server want credit for killing AI, but i don't want to see K/D like 1500/12 kinda things.. so I wanted to change it so that they would have to kill 4 AI to get one kill credit.

	//DONKEYPUNCH CUSTOM KILL STAT ADD FOR AI KILL
	_AIKilled = _playerObj getVariable ["AIKilled", 0];
	if (DMS_Add_AIKill2DB) then
	{
		if (_AIKilled => DMS_Per_AIKill2DB) then // DMS_Per_AIKill2DB = 4; in the main config.sqf
		{
			_newKillerFrags = _killer getVariable ["ExileKills", 0];
			_newKillerFrags = _newKillerFrags + 1;
			_killer setVariable ["ExileKills", _newKillerFrags];
			format["addAccountKill:%1", getPlayerUID _killer] call ExileServer_system_database_query_fireAndForget;
			ExileClientPlayerKills = _newKillerFrags;
			(owner _playerObj) publicVariableClient "ExileClientPlayerKills";
			ExileClientPlayerKills = nil;
			_AIKilled = 0;
		};
		else
		{
			_AIKilled = _AIKilled + 1;
		};
		_playerObj setVariable ["AIKilled", _AIKilled];
	};

So, what am I doing wrong?

Edited by geekm0nkey

Share this post


Link to post
Share on other sites

Solved my issue, not how I wanted too, cause I wanted to learn the right way.. But.. Anyway.. Simply changed the + 1, to a + .25 on all the mods that count..

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.