Ppgtjmad / SimpleShops

[HG] Simple Shops
27 stars 8 forks source link

alive #40

Open merce92 opened 6 years ago

merce92 commented 6 years ago

could someone like me add the rewards in the ia of alive

Will-Nichols commented 6 years ago

Following this here as I am interested in the possible answers.

BrianV1981 commented 3 weeks ago

This should help:

/*

    killedEventHandlers.sqf
    Author: BrianV1981

    https://forums.bohemia.net/forums/topic/211383-trigger-on-enemy-death/
    https://forums.bohemia.net/forums/topic/225166-help-killed-event-handler/
    https://community.bistudio.com/wiki/BIS_fnc_sideID
    https://github.com/gruppe-adler/grad-moneyMenu/wiki/addFunds

    [unit, amount, addToBankAccount] call grad_moneymenu_fnc_addFunds

    Parameter - Explanation
    unit -  Object - The unit or storage object to add or detract from.
    amount -    Number - The Amount to add. Negative value to subtract. Total funds will never go below 0.
    addToBankAccount (optional) Bool - Use true to add the amount to the unit's bank account instead of his wallet.

    Example
    [this, -2000] call grad_moneymenu_fnc_addFunds; // subtracts 2000 from wallet
    [storageBox, 100] call grad_moneymenu_fnc_addFunds; // adds 100 to 
    [player, 1500, true] call grad_moneymenu_fnc_addFunds; // adds 1500 to players bank

    *****THIS IS OBSOLETE AND HAS BEEN INTEGRATED INTO THE arma3mercenaries KILL SCRIPT!*****

*/

///////////adds random 10k wallet for killing opfor////////////////
addMissionEventHandler ["entityKilled", {
  params ["_killed","_killer","_instigator"];
  if (local _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 0) then {
  [_instigator, random 10000] call grad_moneymenu_fnc_addFunds;
  "BLUFOR killed a member of OPFOR, good job! 0-10,000 cr. has been added to their wallet. Don't forget to check the corpse for more money!" remoteExec ["hintSilent"];
  }
}];
///////////adds random 10k WALLET to dead opfor////////////////
addMissionEventHandler ["entityKilled", {
  params ["_killed","_killer","_instigator"];
  if (local _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 0) then {
  [_killed, random 10000] call grad_moneymenu_fnc_addFunds;
  }
}];
/////////// minus 10k BANK for ff /////////////
addMissionEventHandler ["entityKilled", {
  params ["_killed","_killer","_instigator"];
  if (local _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 1) then {
  [_instigator, -10000, true] call grad_moneymenu_fnc_addFunds;
  "BLUFOR killed a NATO member! 10,000 cr. has been deducted from their bank account." remoteExec ["hintSilent"];
  }
}];
addMissionEventHandler ["entityKilled", {
  params ["_killed","_killer","_instigator"];
  if (local _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) then {
  [_instigator, -10000, true] call grad_moneymenu_fnc_addFunds;
  "BLUFOR killed a Syndikat member! (NATO allied) 10,000 cr. has been deducted from their bank account." remoteExec ["hintSilent"];
  }
}];
addMissionEventHandler ["entityKilled", {
  params ["_killed","_killer","_instigator"];
  if (local _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 3) then {
  [_instigator, -10000, true] call grad_moneymenu_fnc_addFunds;
  "BLUFOR killed a civilian! 10,000 cr. has been deducted from their bank account." remoteExec ["hintSilent"];
  }
}];

change out all grad_moneymenu_fnc_addFunds functions with the HG_fnc_addOrSubCash function:

Add or sub cash
Function
[HG_fnc_addOrSubCash](https://github.com/Ppgtjmad/SimpleShops/blob/master/HG/Functions/Client/Generic/fn_addOrSubCash.sqf)
Parameters
0 - INTEGER - Amount of cash [default: 1]
1 - INTEGER - 0 means add, 1 means subtract [default: 0]
2 - INTEGER - 0 means add/take in/from pockets, 1 means add/take in/from bank [default: 0]
Returns
Nothing

Case #1 - Local execution

[500,0] call HG_fnc_addOrSubCash; // Adds 500 to cash
[500,1] call HG_fnc_addOrSubCash; // Subs 500 from cash
[500,0,1] call HG_fnc_addOrSubCash; // Adds 500 to bank
[500,1,1] call HG_fnc_addOrSubCash; // Subs 500 from bank
Case #2 - Remote execution
_unit refers to a player

[500,0] remoteExecCall ["HG_fnc_addOrSubCash",_unit,false]; // Adds 500 to cash 
[500,1] remoteExecCall ["HG_fnc_addOrSubCash",_unit,false]; // Subs 500 from cash 
[500,0,1] remoteExecCall ["HG_fnc_addOrSubCash",_unit,false]; // Adds 500 to bank 
[500,1,1] remoteExecCall ["HG_fnc_addOrSubCash",_unit,false]; // Subs 500 from bank

i.e.:


///////////adds 500 cash for killing opfor////////////////
addMissionEventHandler ["entityKilled", {
  params ["_killed","_killer","_instigator"];
  if (local _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 0) then {
    [500, 0] remoteExecCall ["HG_fnc_addOrSubCash", _instigator, false]; // Adds 500 to instigator's cash
    "BLUFOR killed a member of OPFOR, good job! 500 cr. has been added to your wallet. Don't forget to check the corpse for more money!" remoteExec ["hintSilent", _instigator];
  }
}];

will give you 500 cash for killing OPFOR.

The above example reward script has been overhauled several times and integrated into a kill script but it's a great starting point! For a more complex example, I have a repository called arma3mercenaries kill script.