Morning people!
Sorry if this seems very straight forward, but I'm struggling to get my head around "addPublicVariableEventHandler". I'm using SPON_Money for Sahraniville, a Roleplaying mission, but I can't seem to get the fines to work. I've e-mailed the developer of SPON_Money/Core, and he suggested trying addPublicVariableEventHandler. There are two variables - one is SPON_PlayerBankBalance, the other SPON_PlayerCashBalance. I've been told that I can't use CashBalance. I am trying to make it so that when a police officer hits the "Fine $1,000 option", the unit in question has that amount removed from their bank account. I had some help from a chap called DeChevs, who provided the following, which he advised to put into my init.sqf:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fine = [];
"fine" addPublicVariableEventHandler {if (player == _civilian) then {SPON_playerBankBalance = SPON_playerBankBalance - _fine; _civilian groupchat format ["You were fined $%1 by the establishment!", _fine];}else{_officer groupchat ["%1 fined.", _civilian];};};[/QUOTE]
The action "Fine" for the cop executes the following:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_civilian = _this select 0;
_officer = _this select 1;
_fine = 1000;
switch (side player) do
{
case CIVILIAN: {if (SPON_playerBankBalance < _fine) then {player globalchat "I can't afford the fine." }else{ SPON_playerBankBalance = SPON_playerBankBalance - _fine; player globalchat "I paid the fine.";};};
case WEST: {_msg=Format["I gave %1 a fine.", _civilian]; _officer globalchat _msg;};
};[/QUOTE]
But this does not seem to work. Originally I tried a CrimeCity style BankBalance = BankBalance - Fine, but that took the money away from every unit that was alive, and I can't figure out a way around it!
Any help will be very much appreciated fellas![]()
HOME
Reply With Quote



