Advertisement
Nebulazer

Untitled

Aug 24th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.21 KB | None | 0 0
  1. //Add event to player
  2. player addEventHandler [ "Killed", {
  3.  
  4.     //Get passed killed and killer
  5.     params[ "_killed", "_killer" ];
  6.  
  7.     //If we were killed by a player AND did not kill ourself
  8.     if ( isPlayer _killer && !( _killer isEqualTo _killed ) ) then {
  9.  
  10.         //Is our killer an enemy
  11.         _killedSide = ( getNumber ( configFile >> "CfgVehicles" >> typeOf _killed >> "side" ) ) call BIS_fnc_sideType;
  12.         _isEnemy = _killedSide getFriend side _killer < 0.6;
  13.  
  14.         //Get killers stats
  15.         //Removed, as we wont change them here but send to function on killers client
  16.         //and let it handle changing stats
  17.  
  18.         //If killer was an enemy
  19.         if ( _isEnemy ) then {
  20.  
  21.             //Increase their stats
  22.             //Send updates to client rather than doing them remotely by PV in setvariable
  23.             //As it could be possible that the stats do not reach the client before the call to update function
  24.             //So do it in one call to the clients update function
  25.             //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
  26.             //Which has the added benifit of saving a lot of network traffic
  27.             //[ cash, exp, kill ]
  28.             [ 500, 200, 1 ] remoteExec [ "fnc_updateStats", _killer ];
  29.  
  30.         }else{
  31.  
  32.             //Decrease their stats
  33.             [ -100, -200 ] remoteExec [ "fnc_updateStats", _killer ];
  34.         };
  35.     };
  36. }];
  37.  
  38.  
  39. //
  40. //
  41. //
  42. //fn_addBounty.sqf
  43. //This is added to AI
  44.  
  45.  
  46. params["_unit"];
  47.  
  48.     //Add event ( see initPlayerLocal.sqf for code comments )
  49.     _unit addEventHandler [ "Killed", {
  50.         _unit = _this select 0;
  51.         _killer = _this select 1;
  52.  
  53.         if ( isPlayer _killer && !( _killer isEqualTo _unit ) ) then {
  54.  
  55.             _killedSide = ( getNumber ( configFile >> "CfgVehicles" >> typeOf _unit >> "side" ) ) call BIS_fnc_sideType;
  56.             _isEnemy = _killedSide getFriend side _killer < 0.6;
  57.  
  58.             if ( _isEnemy ) then {
  59.  
  60.                 [ 250, 100, 1 ] remoteExec [ "fnc_updateStats", _killer ];
  61.  
  62.             }else{
  63.  
  64.                 [ -100, -200 ] remoteExec [ "fnc_updateStats", _killer ];
  65.             };
  66.  
  67.         };
  68.  
  69.     }];
  70.  
  71.     //Flag unit as having had event added
  72.     _unit setVariable [ "hasEvent", true ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement