<p>Bonjour à tous, aujourd'hui je vais traduire un tutoriel pour ajouter la bourse, source : altisliferpg.com<br/><br/>
1 - Allez dans votre functions.h et ajouter ceci à la fin :</p>
<pre class="ipsCode prettyprint lang-auto">
class Market{ file = "core\market"; class openMarketView; class refreshMarketView; class marketShortView; class marketBuy; class marketSell; class marketGetBuyPrice; class marketGetSellPrice; class marketconfiguration; class marketReset; class marketChange; class marketGetRow; class marketGetPriceRow; class marketSetPriceRow;};</pre>
<p>Dans le fichier functions.h à nouveau, ajouter ceci en dessous de la class functions :</p>
<pre class="ipsCode prettyprint lang-auto">
class Functions{ file = "core\functions"; class randomRound {}; // <--------- add this};</pre>
<p>2 - Allez dans le dossier Dialog et copier les 2 fichiers disponibles dans le .zip et ouvrer votre MasterHandler.h et ajouter ceci :</p>
<pre class="ipsCode prettyprint lang-auto">
#include "common_EditorWrapper.hpp"#include "market.hpp"</pre>
<p>3 - Ouvrez votre fn_virt_sell.sqf dans core/shops<br/><br/>
Ajoutez à private ceci ["_marketprice"];<br/>
Comme ceci :</p>
<pre class="ipsCode prettyprint lang-auto">
private["_type","_index","_price","_var","_amount","_name","_marketprice"];</pre>
<p>Maintenant trouver cette ligne :</p>
<pre class="ipsCode prettyprint lang-auto">
_price = (GETC(sell_array) select _index) select 1;_var = [_type,0] call life_fnc_varHandle;</pre>
<p>Ajoutez ceci en dessous :</p>
<pre class="ipsCode prettyprint lang-auto">
_marketprice = [_type] call life_fnc_marketGetSellPrice;if(_marketprice != -1) then{ _price = _marketprice;};</pre>
<p>Trouvez cette ligne :</p>
<pre class="ipsCode prettyprint lang-auto">
life_cash = life_cash + _price;</pre>
<p>Ajoutez ceci en dessous :</p>
<pre class="ipsCode prettyprint lang-auto">
if(_marketprice != -1) then { [_type, _amount] spawn { sleep 120; [_this select 0,_this select 1] call life_fnc_marketSell; };};</pre>
<p>4- Fermer le fichier et ouvrer le fichier fn_virt_update.sqf dans le même dossier<br/><br/>
Ajoutez à private ceci ["_marketprice"];<br/>
Comme ceci :</p>
<pre class="ipsCode prettyprint lang-auto">
private["_type","_index","_price","_var","_amount","_name","_marketprice"];</pre>
<p>Maintenant trouvez cette ligne :</p>
<pre class="ipsCode prettyprint lang-auto">
_price = (GETC(buy_array) select _index) select 1;</pre>
<p>Ajoutez ceci en dessous:</p>
<pre class="ipsCode prettyprint lang-auto">
marketprice = [_x] call life_fnc_marketGetBuyPrice;if(_marketprice != -1) then{ _price = _marketprice;};</pre>
<p>A la fin du fichier ajoutez ceci :</p>
<pre class="ipsCode prettyprint lang-auto">
//Call short view here[_shop_data select 1] spawn life_fnc_marketShortView;</pre>
<p>Comme ceci :</p>
<pre class="ipsCode prettyprint lang-auto">
if(_val > 0) then { _gear_list lbAdd format["%1x %2",_val,_name]; _gear_list lbSetData [(lbSize _gear_list)-1,_x]; };} foreach (_shop_data select 1); //Call short view here // this its the new line to add[_shop_data select 1] spawn life_fnc_marketShortView; // this its the new line to add</pre>
<p>5 - Fermer le fichier et ouvrez fn_virt_buy.sqf aussi dans le même dossier<br/><br/>
Ajoutez à private ceci :</p>
<pre class="ipsCode prettyprint lang-auto">
"_marketprice"</pre>
<p>Comme ceci :</p>
<pre class="ipsCode prettyprint lang-auto">
private["_type","_price","_amount","_diff","_name","_hideout","_marketprice"];</pre>
<p>Trouvez cette ligne :</p>
<pre class="ipsCode prettyprint lang-auto">
_amount = ctrlText 2404;</pre>
<p>Ajoutez ceci en dessous:</p>
<pre class="ipsCode prettyprint lang-auto">
_marketprice = [_type] call life_fnc_marketGetBuyPrice;if(_marketprice != -1) then{ _price = _marketprice;};</pre>
<p>Trouvez cette ligne :</p>
<pre class="ipsCode prettyprint lang-auto">
SUB(life_cash,(_price * _amount));</pre>
<p>Ajoutez ceci en dessous:</p>
<pre class="ipsCode prettyprint lang-auto">
if(_marketprice != -1) then { //##94 [_type, _amount] spawn { sleep 120; [_this select 0,_this select 1] call life_fnc_marketBuy; }; };</pre>
<p>6 - Ouvrer le fichier dialog\player_inv.hpp<br/><br/>
En dessous de ceci :</p>
<pre class="ipsCode prettyprint lang-auto">
class ButtonSyncData : life_RscButtonMenu { idc = -1; //shortcuts[] = {0x00050000 + 2}; text = "$STR_PM_SyncData"; onButtonClick = "[] call SOCK_fnc_syncData;"; x = 0.1; y = 0.805; w = (6.25 / 40); h = (1 / 25);};</pre>
<p>Ajoutez ceci :</p>
<pre class="ipsCode prettyprint lang-auto">
class ButtonMarket : Life_RscButtonMenu { idc = -1; text = "Bourse"; onButtonClick = "[] spawn life_fnc_openMarketView;"; //x = 0.26 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH)); x = 0.26 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH)); y = 0.805; w = (6.25 / 40); h = (1 / 25);};</pre>
<p>Ouvrez le fichier init.sqf dans VOTRENOMDEMISSION\init.sqf et en dessous de :</p>
<pre class="ipsCode prettyprint lang-auto">
[] execVM "briefing.sqf"; //Load Briefing[] execVM "KRON_Strings.sqf";</pre>
<p>Ajoutez ça :</p>
<pre class="ipsCode prettyprint lang-auto">
if(isDedicated && isNil("life_market_prices")) then{[] call life_fnc_marketconfiguration;diag_log "Market prices generated!"; "life_market_prices" addPublicVariableEventHandler{diag_log format["Market prices updated! %1", _this select 1];}; //Start server fsm[] execFSM "core\fsm\server.fsm";diag_log "Server FSM executed";};</pre>
<p>Et pour la dernière étape allez dans core\fsm and déplacer le fichier server.fsm dispo dans le .zip<br/><br/>
Désormais vous avez votre système de bourse, enjoy <br/><br/>
Pour le kick par BattlEye, il suffit d'ajouter ces lignes dans Battleye\publicvariable.txt :</p>
<pre class="ipsCode prettyprint lang-auto">
1 "" !="life_HC_isActive" !="HC_UID"7 "" !="life_market_shortnames" !="life_fnc_MP_packet" !="BIS_fnc_MP_packet" !="JipTimeNow" !="life_HC_isActive" !="HC_UID" !="life_gang_list" !="bank_addfunds" !="life_market_prices" !="IL_SetMass" !="IL_SetScore" !="IL_SetDir" !="life_market_resources" !="bis_fnc_execvm" !="Life_fnc_execvm"</pre>
<p>Maintenant pour la version 3.1.4.6+ changez le fichier fn_virt_sell.sqf danscore/shops remplacez le par ceci :</p>
<pre class="ipsCode prettyprint lang-auto">
#include <macro.h>/* File: fn_virt_sell.sqf Author: Bryan "Tonic" Boardwine Description: Sell a virtual item to the store / shop*/ private["_type","_index","_price","_var","_amount","_name","_marketprice"];if((lbCurSel 2402) == -1) exitWith {};_type = lbData[2402,(lbCurSel 2402)];_index = [_type,GETC(sell_array)] call fnc_index;if(_index == -1) exitWith {};_price = (GETC(sell_array) select _index) select 1;_var = [_type,0] call life_fnc_varHandle;_marketprice = [_type] call life_fnc_marketGetSellPrice;if(_marketprice != -1) then{ _price = _marketprice;}; _amount = ctrlText 2405;if(!([_amount] call fnc_isnumber)) exitWith {hint localize "STR_Shop_Virt_NoNum";};_amount = parseNumber (_amount);if(_amount > (missionNameSpace getVariable _var)) exitWith {hint localize "STR_Shop_Virt_NotEnough"}; _price = (_price * _amount);_name = [_var] call life_fnc_vartostr;if(([false,_type,_amount] call life_fnc_handleInv)) then{ hint format[localize "STR_Shop_Virt_SellItem",_amount,_name,[_price] call life_fnc_numberText]; life_cash = life_cash + _price; if(_marketprice != -1) then { [_type, _amount] spawn { sleep 120; [_this select 0,_this select 1] call life_fnc_marketSell; }; }; [] call life_fnc_virt_update; }; if(life_shop_type == "heroin") then{ private["_array","_ind","_val"]; _array = life_shop_npc getVariable["sellers",[]]; _ind = [getPlayerUID player,_array] call fnc_index; if(_ind != -1) then { _val = (_array select _ind) select 2; _val = _val + _price; _array set[_ind,[getPlayerUID player,profileName,_val]]; life_shop_npc setVariable["sellers",_array,true]; } else { _array set[count _array,[getPlayerUID player,profileName,_price]]; life_shop_npc setVariable["sellers",_array,true]; };};</pre>
<p>Merci à : Linxy pour son aide<br/><br/>
Touts les fichiers nécessaire (.zip) : <a href="https://mega.co.nz/#!fZFQjJbB!OGIlZTYFW-ZT-czIiOE8k6GPBFa056TcJTR8u9T6jS8" rel="external nofollow">https://mega.co.nz/#!fZFQjJbB!OGIlZTYFW-ZT-czIiOE8k6GPBFa056TcJTR8u9T6jS8</a><br/><br/><br/>
Patch 3.1.4.8: Copiez les fichiers suivant spécifiques :<br/><br/>
fn.Virt_sell.sqf</p>
<pre class="ipsCode prettyprint lang-auto">
#include <macro.h>/* File: fn_virt_sell.sqf Author: Bryan "Tonic" Boardwine Description: Sell a virtual item to the store / shop*/private["_type","_index","_price","_var","_amount","_name","_marketprice"];if((lbCurSel 2402) == -1) exitWith {};_type = lbData[2402,(lbCurSel 2402)];_index = [_type,GETC(sell_array)] call TON_fnc_index;if(_index == -1) exitWith {};_price = (GETC(sell_array) select _index) select 1;_var = [_type,0] call life_fnc_varHandle;////Marktsystem Anfang////_marketprice = [_type] call life_fnc_marketGetSellPrice;if(_marketprice != -1) then{ _price = _marketprice;};////Marktsystem Ende//// _amount = ctrlText 2405;if(!([_amount] call fnc_isnumber)) exitWith {hint "You didn't enter an actual number";};_amount = parseNumber (_amount);if(_amount > (missionNameSpace getVariable _var)) exitWith {hint "You don't have that many items to sell!"}; _price = (_price * _amount);_name = [_var] call life_fnc_vartostr;if(([false,_type,_amount] call life_fnc_handleInv)) then{ hint format["You sold %1 %2 for $%3",_amount,_name,[_price] call life_fnc_numberText]; life_cash = life_cash + _price; ////Marktsystem Anfang//// if(_marketprice != -1) then { [_type, _amount] spawn { sleep 120; [_this select 0,_this select 1] call life_fnc_marketSell; }; ////Marktsystem Ende//// }; [] call life_fnc_virt_update; }; if(life_shop_type == "heroin") then{ private["_array","_ind","_val"]; _array = life_shop_npc getVariable["sellers",[]]; _ind = [getPlayerUID player,_array] call TON_fnc_index; if(_ind != -1) then { _val = (_array select _ind) select 2; _val = _val + _price; _array set[_ind,[getPlayerUID player,profileName,_val]]; life_shop_npc setVariable["sellers",_array,true]; } else { _array pushBack _array,[getPlayerUID player,profileName,_price]]; life_shop_npc setVariable["sellers",_array,true]; };};</pre>
<p>fn.virt_update.sqf</p>
<pre class="ipsCode prettyprint lang-auto">
#include <macro.h>/* File: fn_virt_update.sqf Author: Bryan "Tonic" Boardwine Description: Update and fill the virtual shop menu.*/private["_display","_item_list","_gear_list","_shop_data","_name","_price","_marketprice"];disableSerialization; //Setup control vars._display = findDisplay 2400;_item_list = _display displayCtrl 2401;_gear_list = _display displayCtrl 2402; //Purge listlbClear _item_list;lbClear _gear_list; _shop_data = [life_shop_type] call life_fnc_virt_shops;ctrlSetText[2403,format["%1", _shop_data select 0]]; { _name = [([_x,0] call life_fnc_varHandle)] call life_fnc_vartostr; _index = [_x,GETC(buy_array)] call TON_fnc_index; if(_index != -1) then { _price = (GETC(buy_array) select _index) select 1; ////Marktsystem Anfang//// _marketprice = [_x] call life_fnc_marketGetBuyPrice; if(_marketprice != -1) then { _price = _marketprice; }; ////Marktsystem Ende//// _item_list lbAdd format["%1 ($%2)",_name,[_price] call life_fnc_numberText]; _item_list lbSetData [(lbSize _item_list)-1,_x]; _item_list lbSetValue [(lbSize _item_list)-1,_price]; };} foreach (_shop_data select 1); { _var = [_x,0] call life_fnc_varHandle; _val = missionNameSpace getVariable _var; _name = [_var] call life_fnc_vartostr; if(_val > 0) then { _gear_list lbAdd format["%1x %2",_val,_name]; _gear_list lbSetData [(lbSize _gear_list)-1,_x]; };} foreach (_shop_data select 1); //Call short view here[_shop_data select 1] spawn life_fnc_marketShortView;</pre>
<p>And a little exemple for fix the xxxxxx in the market:</p>
<pre class="ipsCode prettyprint lang-auto">
["apple", 100, 50, 150, 4, 2, [ ["peach",1] <------- no coma ] ], and for long line["cement", 2250, 250, 4250, 4, 2, [ ["diamondc",1], <------- coma ["oilp",1], <------- coma ["iron_r",1], <------- coma ["copper_r",1], <------- coma ["salt_r",1], <------- coma ["glass",1] <------- no coma ] ], Last items in your configurationmarket ["heroinp", 7000, 3000, 10000, 4, 4, [ ["marijuana",1], <------- coma ["turtle",1], <------- coma ["cocainep",1] <------- no coma ] ] <------- no coma</pre>
<p>Crédit : _Fuzz pour le tutoriel sur altisliferpg.com et EdgeKiller pour la traduction !</p>