Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Add event to player
- player addEventHandler [ "Killed", {
- //Get passed killed and killer
- params[ "_killed", "_killer" ];
- //If we were killed by a player AND did not kill ourself
- if ( isPlayer _killer && !( _killer isEqualTo _killed ) ) then {
- //Is our killer an enemy
- _killedSide = ( getNumber ( configFile >> "CfgVehicles" >> typeOf _killed >> "side" ) ) call BIS_fnc_sideType;
- _isEnemy = _killedSide getFriend side _killer < 0.6;
- //Get killers stats
- //Removed, as we wont change them here but send to function on killers client
- //and let it handle changing stats
- //If killer was an enemy
- if ( _isEnemy ) then {
- //Increase their stats
- //Send updates to client rather than doing them remotely by PV in setvariable
- //As it could be possible that the stats do not reach the client before the call to update function
- //So do it in one call to the clients update function
- //This also means that we do not need to PV client stats around as no one needs to know them other than the actual client
- //Which has the added benifit of saving a lot of network traffic
- //[ cash, exp, kill ]
- [ 500, 200, 1 ] remoteExec [ "fnc_updateStats", _killer ];
- }else{
- //Decrease their stats
- [ -100, -200 ] remoteExec [ "fnc_updateStats", _killer ];
- };
- };
- }];
- //
- //
- //
- //fn_addBounty.sqf
- //This is added to AI
- params["_unit"];
- //Add event ( see initPlayerLocal.sqf for code comments )
- _unit addEventHandler [ "Killed", {
- _unit = _this select 0;
- _killer = _this select 1;
- if ( isPlayer _killer && !( _killer isEqualTo _unit ) ) then {
- _killedSide = ( getNumber ( configFile >> "CfgVehicles" >> typeOf _unit >> "side" ) ) call BIS_fnc_sideType;
- _isEnemy = _killedSide getFriend side _killer < 0.6;
- if ( _isEnemy ) then {
- [ 250, 100, 1 ] remoteExec [ "fnc_updateStats", _killer ];
- }else{
- [ -100, -200 ] remoteExec [ "fnc_updateStats", _killer ];
- };
- };
- }];
- //Flag unit as having had event added
- _unit setVariable [ "hasEvent", true ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement