Zupa Posted August 12, 2014 Report Share Posted August 12, 2014 Universal Develoment functions for script developers, also included in the compiles of the singel currency. Updated 28-08-2014 Always succes when removing 0 coins. 999 Headshot system: // usage // _removed = [player, 5000] call SC_fnc_removeCoins; // if(_removed = true)then{ GREAT SUCCES }else{ IT FAILED, not enoguh money}; SC_fnc_removeCoins= { private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["headShots",0]; if(_amount > 0)then{ if (_wealth < _amount) then { _result = false; } else { _newwealth = _wealth - _amount; _player setVariable["headShots",_newwealth, true]; _player setVariable ["moneychanged",1,true]; _result = true; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; }; }else{ _result = true; }; _result }; // usage // _added = [player, 5000] call SC_fnc_addCoins; // if(_added = true)then{ GREAT SUCCES }else{ IT FAILED, Something went wrong}; SC_fnc_addCoins = { private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["headShots",0]; _player setVariable["headShots",_wealth + _amount, true]; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; _player setVariable ["moneychanged",1,true]; _newwealth = _player getVariable["headShots",0]; if (_newwealth >= _wealth) then { _result = true; }; _result }; 2.0 Cashmoney system (Soul): // usage // _removed = [player, 5000] call SC_fnc_removeCoins; // if(_removed = true)then{ GREAT SUCCES }else{ IT FAILED, not enoguh money}; SC_fnc_removeCoins= { private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["cashMoney",0]; if(_amount > 0)then{ if (_wealth < _amount) then { _result = false; } else { _newwealth = _wealth - _amount; _player setVariable["cashMoney",_newwealth, true]; _player setVariable ["moneychanged",1,true]; _result = true; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; }; }else{ _result = true; }; _result }; // usage // _added = [player, 5000] call SC_fnc_addCoins; // if(_added = true)then{ GREAT SUCCES }else{ IT FAILED, Something went wrong}; SC_fnc_addCoins = { private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["cashMoney",0]; _player setVariable["cashMoney",_wealth + _amount, true]; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; _player setVariable ["moneychanged",1,true]; _newwealth = _player getVariable["cashMoney",0]; if (_newwealth >= _wealth) then { _result = true; }; _result }; mgm and 31_D!4b10 2 Link to comment Share on other sites More sharing options...
mgm Posted August 14, 2014 Report Share Posted August 14, 2014 OK guys, i got limited time, i wrote these compile functions that will make adding and removing coins universal and easy: ( So easy to edit scripts where u have to pay quick.) On top of your compiles.sqf (best outside of the isDedi): THIS ISNT TESTED, so would be great if a experience guy can test it first. ( i'm leaving like soon to a festival). THIS IS FOR 999: 1.1 version // usage // _removed = [player, 5000] call SC_fnc_removeCoins; // if(_removed = true)then{ GREAT SUCCES }else{ IT FAILED, not enoguh money}; SC_fnc_removeCoins= { private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["headShots",0]; if (_wealth <= _amount) then { _result = false; } else { _newwealth = _wealth - _amount; _player setVariable["headShots",_newwealth, true]; _player setVariable ["moneychanged",1,true]; _result = true; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; }; _result }; // usage // _added = [player, 5000] call SC_fnc_addCoins; // if(_added = true)then{ GREAT SUCCES }else{ IT FAILED, Something went wrong}; SC_fnc_addCoins = { private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["headShots",0]; _player setVariable["headShots",_wealth + _amount, true]; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; _player setVariable ["moneychanged",1,true]; _newwealth = _player getVariable["headShots",0]; if (_newwealth >= _wealth) then { _result = true; }; _result }; Nice one Zupa. Have a good time! calamity 1 Link to comment Share on other sites More sharing options...
Rocu Posted August 19, 2014 Report Share Posted August 19, 2014 This is useful, but there's a minor error in it. When trying to SC_fnc_removeCoins it won't remove player's coins when you have the exact amount. For example when trying to buy something for 2000 and you have exactly 2000, most scripts reply with: You need another 0 coins. Easy fix for that. Find: if (_wealth <= _amount) then { Replace with: if (_wealth < _amount) then { Edit// This is now fixed on the 1st post Link to comment Share on other sites More sharing options...
Kimzer Posted August 22, 2014 Report Share Posted August 22, 2014 Trying to get the Skin trader script to use this. But i am struggling. (Not my field this.) Currently its looking like this. It works if i remove the if(_removed = true) then { line, but it will let you buy skins regardless of how many coins you have. If i keep the if(_removed = true) then { line, then it wont do anything. Link to original script: I hope someone can assist me here as im sure there are more people who want to use this with coins. :) if(not local player) exitWith{}; #include "dialog\definitions.sqf" disableSerialization; _display = findDisplay SKINS_DIALOG; _listbox = _display displayCtrl SKINS_UNITLIST; _sel = lbCurSel _listbox; if(_sel < 0) exitWith{}; _unittype = Men_Clothing select _sel; _typename = lbtext [sKINS_UNITLIST,_sel]; _hasGPS = false; _hasCompass = false; _hasRadio = false; _hasWatch = false; _hasMap = false; /********************* Buy Skin ********************/ _cash = 5000; _removed = [player, _cash] call SC_fnc_removeCoins; if(_removed = true) then { _msg = format ["Payed %1 %2. Skin Change incoming!",_cash, DNCurrency]; systemChat ("(DayZNorway.com): "+str _msg+""); _msg spawn AH_fnc_dynTextMsg; if (player hasWeapon "ItemCompass") then { _hasCompass = true; }; if (player hasWeapon "ItemRadio") then { _hasRadio = true; }; if (player hasWeapon "ItemGPS") then { _hasGPS = true; }; if (player hasWeapon "ItemWatch") then { _hasWatch = true; }; if (player hasWeapon "ItemMap") then { _hasMap = true; }; player playActionNow "Medic"; sleep 7; CloseDialog 0; sleep 1; [dayz_playerUID,dayz_characterID,_unittype] spawn player_humanityMorph; sleep 0.2; vehicle player switchCamera 'EXTERNAL'; sleep 3; if (!_hasCompass) then { player removeWeapon "ItemCompass"; }; if (!_hasRadio) then { player removeWeapon "ItemRadio"; }; if (!_hasGPS) then { player removeWeapon "ItemGPS"; }; if (!_hasWatch) then { player removeWeapon "ItemWatch"; }; if (!_hasMap) then { player removeWeapon "ItemMap"; }; }else{ _msg = format ["You need another %1 %2.",_cash, DNCurrency]; systemChat ("(DayZNorway.com): "+str _msg+""); _msg spawn AH_fnc_dynTextMsg; }; }; /*******************************************************/ Link to comment Share on other sites More sharing options...
Zupa Posted August 28, 2014 Author Report Share Posted August 28, 2014 Bump updated: Both systems. Always succes when removing 0 coins. ttkrickjames, mgm and tehtrk 3 Link to comment Share on other sites More sharing options...
flakvest Posted January 3, 2015 Report Share Posted January 3, 2015 Is there a way for this to work with SC 3.0? Link to comment Share on other sites More sharing options...
bFe Posted April 9, 2015 Report Share Posted April 9, 2015 Is there a way for this to work with SC 3.0? Link to comment Share on other sites More sharing options...
P0k3r_OF_Sm0t Posted May 13, 2015 Report Share Posted May 13, 2015 Works for me with SC 3.0 Link to comment Share on other sites More sharing options...
Thug Posted June 27, 2015 Report Share Posted June 27, 2015 With the help of Affraid and this script, we now have the refuel working on our taviana map. Thank you for your work. :D Link to comment Share on other sites More sharing options...
Johnw7392 Posted July 5, 2015 Report Share Posted July 5, 2015 I am using the SC 3.0 on my Overpoch server and am wanting to use SC rearm/refuel by axe cop so I do need this in my ZSC compiles right? How would I put this into my ZSC Compiles? Do I replace what is currently in there or just paste this underneath? Current SC_fnc_removeCoins private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["cashMoney",0]; if(_amount > 0)then{ if (_wealth < _amount) then { _result = false; } else { _newwealth = _wealth - _amount; _player setVariable["cashMoney",_newwealth, true]; _player setVariable ["moneychanged",1,true]; _result = true; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; }; }else{ _result = true; }; _result Current SC_fnc_addCoins private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["cashMoney",0]; _player setVariable["cashMoney",_wealth + _amount, true]; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; _player setVariable ["moneychanged",1,true]; _newwealth = _player getVariable["cashMoney",0]; if (_newwealth >= _wealth) then { _result = true; }; _result Link to comment Share on other sites More sharing options...
AiiDynBrus Posted February 2, 2016 Report Share Posted February 2, 2016 On 12/08/2014 at 11:37 PM, Zupa said: Universal Develoment functions for script developers, also included in the compiles of the singel currency. Updated 28-08-2014 Always succes when removing 0 coins. 999 Headshot system: // usage // _removed = [player, 5000] call SC_fnc_removeCoins; // if(_removed = true)then{ GREAT SUCCES }else{ IT FAILED, not enoguh money}; SC_fnc_removeCoins= { private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["headShots",0]; if(_amount > 0)then{ if (_wealth < _amount) then { _result = false; } else { _newwealth = _wealth - _amount; _player setVariable["headShots",_newwealth, true]; _player setVariable ["moneychanged",1,true]; _result = true; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; }; }else{ _result = true; }; _result }; // usage // _added = [player, 5000] call SC_fnc_addCoins; // if(_added = true)then{ GREAT SUCCES }else{ IT FAILED, Something went wrong}; SC_fnc_addCoins = { private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["headShots",0]; _player setVariable["headShots",_wealth + _amount, true]; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; _player setVariable ["moneychanged",1,true]; _newwealth = _player getVariable["headShots",0]; if (_newwealth >= _wealth) then { _result = true; }; _result }; 2.0 Cashmoney system (Soul): // usage // _removed = [player, 5000] call SC_fnc_removeCoins; // if(_removed = true)then{ GREAT SUCCES }else{ IT FAILED, not enoguh money}; SC_fnc_removeCoins= { private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["cashMoney",0]; if(_amount > 0)then{ if (_wealth < _amount) then { _result = false; } else { _newwealth = _wealth - _amount; _player setVariable["cashMoney",_newwealth, true]; _player setVariable ["moneychanged",1,true]; _result = true; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; }; }else{ _result = true; }; _result }; // usage // _added = [player, 5000] call SC_fnc_addCoins; // if(_added = true)then{ GREAT SUCCES }else{ IT FAILED, Something went wrong}; SC_fnc_addCoins = { private ["_player","_amount","_wealth","_newwealth", "_result"]; _player = _this select 0; _amount = _this select 1; _result = false; _wealth = _player getVariable["cashMoney",0]; _player setVariable["cashMoney",_wealth + _amount, true]; PVDZE_plr_Save = [_player,(magazines _player),true,true] ; publicVariableServer "PVDZE_plr_Save"; _player setVariable ["moneychanged",1,true]; _newwealth = _player getVariable["cashMoney",0]; if (_newwealth >= _wealth) then { _result = true; }; _result }; Ummm so where do you put this code? in compiles.sqf or? Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now