[Tuto] assurance 5.0


#1

Assurance repris de ALTISLIFERPG, l’auteur étant FazeCHEF

Pour ma part j’ai juste déplacé le bouton d’assurance.

Côté Mpmission

Allez dans le dossier “dialog” et ouvrez le fichier “impound.hpp”

Cherchez

class SellCar: Life_RscButtonMenu {  
            idc = -1;  
            text = "$STR_Global_Sell";  
            onButtonClick = "[] call life_fnc_sellGarage; closeDialog 0;";  
            x = 0.26 + (6.25 / 40) + (1 / 250 / (safezoneW / safezoneH));  
            y = 0.9 - (1 / 25);  
            w = (6.25 / 40);  
            h = (1 / 25);  
        }; 

Et ajoutez ceci en dessous

 class InsureCar : life_RscButtonMenu  
    {  
        idc = 97480;  
        text = "Assurer";  
        onButtonClick = "[] call life_fnc_insureCar;";  
        x = 0.43 + (6.25 / 40) + (1 / 250 / (safezoneW / safezoneH));  
        y = 0.9 - (1 / 25);  
        w = (6.25 / 40);  
        h = (1 / 25);  
    }; 

Ensuite dans “Dialog” =>" Functions", vous créez un fichier nomé “fn_insureCar.sqf”
Vous copiez tout le code dans se fichier.

#include "..\..\script_macros.hpp" 
/* 
 File: fn_insureCar.sqf 
 Author: Guit0x "Lintox" 
 Description: 
 Insure a vehicle from the garage. 
*/ 
private["_vehicle","_vehicleLife","_vid","_pid","_unit","_multiplier","_price","_purchasePrice","_insurancePrice"]; 
disableSerialization; 
if ((lbCurSel 2802) isEqualTo -1) exitWith {hint localize "STR_Global_NoSelection"}; 
_vehicle = lbData[2802,(lbCurSel 2802)]; 
_vehicle = (call compile format["%1",_vehicle]) select 0; 
_vehicleLife = _vehicle; 
_vid = lbValue [ 2802 , (lbCurSel 2802 )];
_pid = getPlayerUID player;
_unit = player; 
if(isNil "_vehicle") exitWith {hint localize "STR_Garage_Selection_Error"}; 
if ((time - life_action_delay) < 1.5) exitWith {hint localize "STR_NOTF_ActionDelay";}; 
if (!isClass (missionConfigFile >> "LifeCfgVehicles" >> _vehicleLife)) then { 
 _vehicleLife = "Default"; //Use Default class if it doesn't exist 
 diag_log format["%1: LifeCfgVehicles class doesn't exist",_vehicle]; 
}; 
_price = M_CONFIG(getNumber,"LifeCfgVehicles",_vehicleLife,"price"); 
switch (playerSide) do { 
 case civilian: { 
 _multiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_CIVILIAN"); 
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_CIVILIAN"); 
 }; 
 case west: { 
 _multiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_COP"); 
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_COP"); 
 }; 
 case independent: { 
 _multiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_MEDIC"); 
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_MEDIC"); 
 }; 
 case east: { 
 _multiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_OPFOR"); 
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_OPFOR"); 
 }; 
}; 
_insurancePrice = _purchasePrice * _multiplier; 
if(!(_insurancePrice isEqualType 0) || _insurancePrice < 1) then {_insurancePrice = 500}; 
if(BANK < _insurancePrice) exitWith {hint format[(localize "STR_GNOTF_NotEnoughMoney"),[_insurancePrice] call life_fnc_numberText];}; 
if (life_HC_isActive) then { 
 [_vid,_pid,_insurancePrice,player,life_garage_type] remoteExecCall ["HC_fnc_insureCar",HC_Life]; 
} else { 
 [_vid,_pid,_insurancePrice,player,life_garage_type] remoteExecCall ["TON_fnc_insureCar",RSERV]; 
}; 
hint localize "STR_InsuranceApply"; 
BANK = BANK - _insurancePrice; 
life_action_delay = time; 
closeDialog 0;

Retournez a la racine de votre mpmission et ouvrez le fichier “function.hpp”

Et ajouter “class insureCar {};” comme ci-dessous

    class Dialog_Controls {
        file = "dialog\function";
        class bankDeposit {};
        class bankTransfer {};
        class bankWithdraw {};
        class displayHandler {};
        class gangDeposit {};
        class gangWithdraw {};
        class garageLBChange {};
        class impoundMenu {};
        class progressBar {};
        class safeFix {};
        class safeInventory {};
        class safeOpen {};
        class safeTake {};
        class sellGarage {};
        class setMapPosition {};
        class spawnConfirm {};
        class spawnMenu {};
        class spawnPointCfg {};
        class spawnPointSelected {};
        class unimpound {};
        class vehicleGarage {};
        class wireTransfer {};
	class insureCar {}; //ici
    };

Rendez-vous dans le dossier “functions” qui se trouve dans votre dossier “dialog” et ouvrez le fichier “fn_garageLBChange.sql” ( plusieurs manipulation a faire dans se fichier )

Cherchez après la ligne suivante

private["_control","_index","_className","_classNameLife","_dataArr","_vehicleColor","_vehicleInfo","_trunkSpace","_sellPrice","_retrievePrice","_sellMultiplier","_price","_storageFee","_purchasePrice"];

Et remplacez la par celle-ci

private["_control","_index","_className","_classNameLife","_dataArr","_vehicleColor","_vehicleInfo","_trunkSpace","_sellPrice","_retrievePrice","_sellMultiplier","_insurance","_insuranceMultiplier","_price","_storageFee","_purchasePrice","_insurancePrice"];

Cherchez

_classNameLife = _className;

Ajouter ça en dessous

_insurance = (_dataArr select 2 );

Cherchez

switch (playerSide) do { 
 case civilian: { 
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_CIVILIAN"); 
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_CIVILIAN"); 
 }; 
 case west: { 
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_COP"); 
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_COP"); 
 }; 
 case independent: { 
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_MEDIC"); 
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_MEDIC"); 
 }; 
 case east: { 
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_OPFOR"); 
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_OPFOR"); 
 }; 
};

Et remplacer par cela

switch (playerSide) do {
 case civilian: {
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_CIVILIAN");
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_CIVILIAN");
 _insuranceMultiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_CIVILIAN");
 };
 case west: {
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_COP");
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_COP");
 _insuranceMultiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_COP");
 };
 case independent: {
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_MEDIC");
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_MEDIC");
 _insuranceMultiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_MEDIC");
 };
 case east: {
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_OPFOR");
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_OPFOR");
 _insuranceMultiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_OPFOR");
 };
};

Cherchez

_sellPrice = _purchasePrice * _sellMultiplier;

Ajoutez

_insurancePrice = _purchasePrice * _insuranceMultiplier;

Cherchez

if (!(_retrievePrice isEqualType 0) || _retrievePrice < 1) then {_retrievePrice = 500;};

Ajoutez

if (!(_insurancePrice isEqualType 0) || _insurancePrice < 1) then {_insurancePrice = 500;};

Cherchez

(CONTROL(2800,2803)) ctrlSetStructuredText parseText format[ 
 (localize "STR_Shop_Veh_UI_RetrievalP")+ " <t color='#8cff9b'>$%1</t><br/> 
 " +(localize "STR_Shop_Veh_UI_SellP")+ " <t color='#8cff9b'>$%2</t><br/> 
 " +(localize "STR_Shop_Veh_UI_Color")+ " %8<br/> 
 " +(localize "STR_Shop_Veh_UI_MaxSpeed")+ " %3 km/h<br/> 
 " +(localize "STR_Shop_Veh_UI_HPower")+ " %4<br/> 
 " +(localize "STR_Shop_Veh_UI_PSeats")+ " %5<br/> 
 " +(localize "STR_Shop_Veh_UI_Trunk")+ " %6<br/> 
 " +(localize "STR_Shop_Veh_UI_Fuel")+ " %7 
 ",

Remplacer par

(CONTROL(2800,2803)) ctrlSetStructuredText parseText format[
(localize "STR_Shop_Veh_UI_RetrievalP")+ " <t color='#8cff9b'>$%1</t><br/>
" +(localize "STR_Shop_Veh_UI_SellP")+ " <t color='#8cff9b'>$%2</t><br/>
Prix de l'assurance: <t color='#8cff9b'>$%9</t><br/>
Etat de l'assurance: %10 <br/>
" +(localize "STR_Shop_Veh_UI_Color")+ " <t color='#8cff9b'>%8</t><br/>
" +(localize "STR_Shop_Veh_UI_MaxSpeed")+ " <t color='#8cff9b'>%3 km/h</t><br/>
" +(localize "STR_Shop_Veh_UI_HPower")+ " <t color='#8cff9b'>%4</t><br/>
" +(localize "STR_Shop_Veh_UI_PSeats")+ " <t color='#8cff9b'>%5</t><br/>
" +(localize "STR_Shop_Veh_UI_Trunk")+ " <t color='#8cff9b'>%6</t><br/>
" +(localize "STR_Shop_Veh_UI_Fuel")+ " <t color='#8cff9b'>%7</t>
",

Cherchez

(_vehicleInfo select 12),
_vehicleColor
];

Remplacer par

(_vehicleInfo select 12),
_vehicleColor,
[_insurancePrice] call life_fnc_numberText,
if(_insurance == 1) then {"<t color='#8cff9b'>Assuré</t>"} else {"<t color='#FF0000'>Pas d'assurance</t>"},
(_vehicleInfo select 9)
];
if(_insurance == 1) then {
ctrlShow [97480,False];
}else{
ctrlShow [97480,True];
};

Maintenant allez dans “dialog” =>" Function" et ouvrez le fichier “impoundMenu.sqf”

Cherchez

_tmp = [(_x select 2),(_x select 8)];

Remplacer par

_tmp = [(_x select 2),(_x select 8),(_x select 9)];

Aller a la racine de votre fichier mpmission et ouvrez “CfgRemoteExec.hpp”

Ajoutez "F(TON_fnc_insureCar,SERVER) " comme ci-dessous

        /* Server only functions */
        F(BIS_fnc_execVM,SERVER)
        F(DB_fnc_insertRequest,SERVER)
        F(DB_fnc_queryRequest,SERVER)
        F(DB_fnc_updatePartial,SERVER)
        F(DB_fnc_updateRequest,SERVER)
        F(life_fnc_jailSys,SERVER)
        F(life_fnc_wantedAdd,SERVER)
        F(life_fnc_wantedBounty,SERVER)
        F(life_fnc_wantedCrimes,SERVER)
        F(life_fnc_wantedFetch,SERVER)
        F(life_fnc_wantedProfUpdate,SERVER)
        F(life_fnc_wantedRemove,SERVER)
        F(SPY_fnc_cookieJar,SERVER)
        F(SPY_fnc_observe,SERVER)
        F(TON_fnc_addContainer,SERVER)
        F(TON_fnc_addHouse,SERVER)
        F(TON_fnc_chopShopSell,SERVER)
        F(TON_fnc_cleanupRequest,SERVER)
        F(TON_fnc_deleteDBContainer,SERVER)
        F(TON_fnc_getID,SERVER)
        F(TON_fnc_getVehicles,SERVER)
        F(TON_fnc_insertGang,SERVER)
        F(TON_fnc_keyManagement,SERVER)
        F(TON_fnc_manageSC,SERVER)
        F(TON_fnc_pickupAction,SERVER)
        F(TON_fnc_removeGang,SERVER)
        F(TON_fnc_sellHouse,SERVER)
        F(TON_fnc_sellHouseContainer,SERVER)
        F(TON_fnc_setObjVar,SERVER)
        F(TON_fnc_spawnVehicle,SERVER)
        F(TON_fnc_spikeStrip,SERVER)
        F(TON_fnc_updateGang,SERVER)
        F(TON_fnc_updateHouseContainers,SERVER)
        F(TON_fnc_updateHouseTrunk,SERVER)
        F(TON_fnc_vehicleCreate,SERVER)
        F(TON_fnc_vehicleDelete,SERVER)
        F(TON_fnc_vehicleStore,SERVER)
        F(TON_fnc_vehicleUpdate,SERVER)
        F(TON_fnc_handleBlastingCharge,SERVER)
        F(TON_fnc_houseGarage,SERVER)
	F(TON_fnc_playerLogged,SERVER) //BOURSE
	F(TON_fnc_getUpdate,SERVER) //BOURSE
	F(TON_fnc_changePrice,SERVER) //BOURSE
	F(TON_fnc_insureCar,SERVER) //assurance

Allez dans votre “Stringtable.xml” et ajoutez

<Key ID="STR_InsuranceApply"> 
 <Original>You just insure your vehicle you are now protected against explosions!</Original> 
 < Czech > Now you insure your vehicle is now protected against explosions ! < / Czech > 
 < Spanish > You just make sure your vehicle is now protected against explosions ! < / Spanish > 
 < Italian > Just ensure your vehicle you are now protected against explosions ! < / Italian > 
 < Polish > Just insure your vehicle you are now protected from explosion ! < / Polish > 
 < Russian > You just insure your car, you are now protected against explosions ! < / Russian > 
 < French > You just make your vehicle you are now protected against explosions ! < / French > 
 < Portuguese > You just hold your vehicle you are now protected against explosions ! < / Portuguese > 
 < German > They only insure your vehicle, you are now protected against explosions ! < / German > 
 </Key>

Allez dans votre dossier “config” et ouvrez “config_master.hpp”

Ajoutez

/* Vehicle Insurance Prices */ 
vehicle_insurance_multiplier_CIVILIAN = .25; //Civilian Vehicle Insurance Price = Vehicle Buy Price * multiplier 
vehicle_insurance_multiplier_COP = .1; //Cop Vehicle Insurance Price = Vehicle Buy Price * multiplier 
vehicle_insurance_multiplier_MEDIC = .1; //Medic Vehicle Insurance Price = Vehicle Buy Price * multiplier 
vehicle_insurance_multiplier_OPFOR = -1; // -- NOT IN USE -- Simply left in for east support.

Côté life_server

Ouvrez votre “config.cpp” et ajouter “class insureCar {};”

comme ci-dessous

    class TON_System {
        tag = "TON";
        class Systems {
            file = "\life_server\Functions\Systems";
            class managesc {};
            class cleanup {};
            class huntingZone {};
            class getID {};
            class vehicleCreate {};
            class spawnVehicle {};
            class getVehicles {};
            class vehicleStore {};
            class vehicleDelete {};
            class spikeStrip {};
            class transferOwnership {};
            class federalUpdate {};
            class chopShopSell {};
            class clientDisconnect {};
            class cleanupRequest {};
            class setObjVar {};
            class keyManagement {};
            class vehicleUpdate {};
            class recupkeyforHC {};
            class handleBlastingCharge {};
            class terrainSort {};
            class insureCar {}; //Ici

Allez dans votre dossier "systems qui se trouve dans votre dossier “Functions” et ouvrez “fn_spawnVehicle.sqf” ( plusieurs manipulation a faire dans se fichier )

Cherchez

_query = format["SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel, damage, blacklist FROM vehicles WHERE id='%1' AND pid='%2'",_vid,_pid];

Remplacez par

_query = format["SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel, damage, blacklist, insure FROM vehicles WHERE id='%1' AND pid='%2'",_vid,_pid];

Cherchez

_vehicle setVariable ["dbInfo",[(_vInfo select 4),(_vInfo select 7)],true];

Remplacez par

_vehicle setVariable ["dbInfo",[(_vInfo select 4),(_vInfo select 7),(_vInfo select 14)],true];

Cherchez

[1,_spawntext] remoteExecCall ["life_fnc_broadcast",_unit];
serv_sv_use deleteAt _servIndex;

Remplacez par

if ((_vInfo select 14) isEqualTo 1) then {
[ 1 , "Your vehicle is available and it is assured!" ] RemoteExecCall [ "life_fnc_broadcast" , _unit];
}else{
[ 1 , "Your vehicle is available but is not insured!" ] RemoteExecCall [ "life_fnc_broadcast" , _unit];
};
serv_sv_use deleteAt _servIndex;

Allez dans “functions” => “systems” et creez le fichier “fn_insureCar.sqf” et copiez tout le code suivant

/*
File: fn_insureCar.sqf
Author: Guit0x "Lintox"
Description:
Insure a vehicle from the garage.
*/
private["_vid","_pid","_query","_sql","_unit","_insurancePrice","_thread"];
_vid = [_this,0,-1,[0]] call BIS_fnc_param;
_pid = [_this,1,"",[""]] call BIS_fnc_param;
_unit = [_this,2,ObjNull,[ObjNull]] call BIS_fnc_param;
_insurancePrice = [_this,3,0,[0]] call BIS_fnc_param;
_query = format["UPDATE vehicles SET insure='1' WHERE pid='%1' AND id='%2'",_pid,_vid];
waitUntil { ! DB_Async_Active};
_thread = [_query,1] call DB_fnc_asyncCall;

Allez dans le dossier “FSM”, ouvrez “cleanut.fsm” et remplacer le contenu par le code suivant

/*%FSM<COMPILE "C:\Program Files (x86)\Bohemia Interactive\Tools\FSM Editor Personal Edition\scriptedFSM.cfg, Server-Side Cleanup">*/
/*%FSM<HEAD>*/
/*
item0[] = {"init",0,250,-62.908096,-391.651611,27.091887,-341.651672,0.000000,"init"};
item1[] = {"true",8,218,-62.976639,-315.185364,27.023363,-265.185364,0.000000,"true"};
item2[] = {"Share__Work_load",2,250,-64.183350,-224.681931,25.816656,-174.681931,0.000000,"Share " \n "Work-load"};
item3[] = {"Continue__",4,218,-220.591476,74.216980,-130.591476,124.216980,0.000000,"" \n "" \n "Continue" \n "" \n ""};
item4[] = {"Time_Check",4,218,-219.425827,-133.310532,-129.425964,-83.310455,0.000000,"Time Check"};
item5[] = {"Delete_Dead_Cars",2,4346,-220.186951,-29.248400,-130.187195,20.751413,0.000000,"Delete" \n "Dead" \n "Cars"};
item6[] = {"",7,210,-312.538239,95.295059,-304.538239,103.295059,0.000000,""};
item7[] = {"",7,210,-312.798218,-204.081940,-304.798218,-196.081940,0.000000,""};
item8[] = {"End_Cleanup_",1,250,-64.828239,87.581070,25.171984,137.581238,0.000000,"" \n "End Cleanup" \n ""};
item9[] = {"Check_for_HC_",4,218,-65.059021,-30.047342,24.941008,19.952658,0.000000,"" \n "Check for HC" \n ""};
link0[] = {0,1};
link1[] = {1,2};
link2[] = {2,4};
link3[] = {3,6};
link4[] = {4,5};
link5[] = {5,3};
link6[] = {5,9};
link7[] = {6,7};
link8[] = {7,2};
link9[] = {9,8};
globals[] = {0.000000,0,0,0,0,640,480,1,53,6316128,1,-481.887177,425.726196,554.522583,-436.926575,170,901,1};
window[] = {0,-1,-1,-32000,-32000,1065,104,1468,104,1,188};
*//*%FSM</HEAD>*/
class FSM
{
  fsmName = "Server-Side Cleanup";
  class States
  {
    /*%FSM<STATE "init">*/
    class init
    {
      name = "init";
      init = /*%FSM<STATEINIT""">*/"private [""_impound"",""_cars"",""_objs"",""_totCars"",""_thread""];" \n
       "_impound = time;" \n
       "_cars = time;" \n
       "_objs = time;" \n
       "cleanupFSM setFSMVariable [""stopfsm"",false];"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "true">*/
        class true
        {
          priority = 0.000000;
          to="Share__Work_load";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Share__Work_load">*/
    class Share__Work_load
    {
      name = "Share__Work_load";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Time_Check">*/
        class Time_Check
        {
          priority = 0.000000;
          to="Delete_Dead_Cars";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"((time - _cars) > (3 * 60))"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Delete_Dead_Cars">*/
    class Delete_Dead_Cars
    {
      name = "Delete_Dead_Cars";
      init = /*%FSM<STATEINIT""">*/"{" \n
       "	if (!alive _x) then {" \n
       "		_dbInfo = _x getVariable [""dbInfo"",[]];" \n
       "		if (count _dbInfo > 0) then {" \n
       "			_uid = _dbInfo select 0;" \n
       "			_plate = _dbInfo select 1;" \n
       "			_insureSystem = _dbInfo select 2;" \n
       "			 diag_log "" destroy vehicle !"";" \n
       "			diag_log format[""insureSystem = %1 "", _insureSystem];" \n
       "			if(_insureSystem == 1) then " \n
       "			{ diag_log "" Insured !"";" \n
       "			 diag_log format[""insureSystem = %1 "", _insureSystem];" \n
       "" \n
       "			_query_0 = format [""UPDATE vehicles SET alive='1', insure='0', active='0' WHERE pid='%1' AND plate='%2'"",_uid,_plate];" \n
       "			_query_0 spawn {" \n
       "				" \n
       "				_thread = [_this,1] call DB_fnc_asyncCall;" \n
       "			};" \n
       "		} else {" \n
       "			 diag_log "" Not insured !"";" \n
       " 				diag_log format[""insureSystem = %1 "", _insureSystem];" \n
       "				 _query = format[""UPDATE vehicles SET alive='0' WHERE pid='%1' AND plate='%2'"",_uid,_plate]; " \n
       "			 _query spawn {" \n
       "			_thread = [_this,1] call DB_fnc_asyncCall;" \n
       "			};" \n
       "		};" \n
       "		if (!isNil ""_x"" && {!isNull _x}) then {" \n
       "			deleteVehicle _x;" \n
       "		};" \n
       "	};" \n
       "};" \n
       "} forEach allMissionObjects ""LandVehicle"";" \n
       "" \n
       "{" \n
       "	if (!alive _x) then {" \n
       "		_dbInfo = _x getVariable [""dbInfo"",[]];" \n
       "		if (count _dbInfo > 0) then {" \n
       "			_uid = _dbInfo select 0;" \n
       "			_plate = _dbInfo select 1;" \n
       "			_insureSystem = _dbInfo select 2;" \n
       "			 diag_log "" destroy vehicle !"";" \n
       "			 diag_log format[""insureSystem = %1 "", _insureSystem];" \n
       "			 if(_insureSystem == 1) then" \n
       "			{ diag_log "" Insured !"";" \n
       "			 diag_log format[""insureSystem = %1 "", _insureSystem];" \n
       "			_query_0 = format [""UPDATE vehicles SET alive='1', insure='0', active='0' WHERE pid='%1' AND plate='%2'"",_uid,_plate];" \n
       "			_query_0 spawn {" \n
       "				" \n
       "				_thread = [_this,1] call DB_fnc_asyncCall;" \n
       "            };} else { " \n
       "				diag_log "" Not Insured !"";" \n
       "			      diag_log format[""insureSystem = %1 "", _insureSystem];" \n
       "				_query = format[""UPDATE vehicles SET alive='0' WHERE pid='%1' AND plate='%2'"",_uid,_plate]; " \n
       "				_query spawn {" \n
       "			_thread = [_this,1] call DB_fnc_asyncCall;" \n
       "			};" \n
       "		};" \n
       "	};" \n
       "		if (!isNil ""_x"" && {!isNull _x}) then {" \n
       "			deleteVehicle _x;" \n
       "		};" \n
       "	};" \n
       "} forEach allMissionObjects ""Air"";" \n
       "_cars = time;" \n
       "" \n
       "//Group cleanup." \n
       "{" \n
       "	if (units _x isEqualTo [] && local _x) then {" \n
       "		deleteGroup _x;" \n
       "	};" \n
       "} forEach allGroups;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Check_for_HC_">*/
        class Check_for_HC_
        {
          priority = 0.000000;
          to="End_Cleanup_";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"cleanupFSM getFSMVariable ""stopfsm"""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Continue__">*/
        class Continue__
        {
          priority = 0.000000;
          to="Share__Work_load";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!(cleanupFSM getFSMVariable ""stopfsm"")"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "End_Cleanup_">*/
    class End_Cleanup_
    {
      name = "End_Cleanup_";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
      };
    };
    /*%FSM</STATE>*/
  };
  initState="init";
  finalStates[] =
  {
    "End_Cleanup_",
  };
};
/*%FSM</COMPILE>*/

Allez dans “functions” => “Systems” et ouvrez “fn_getVehicles.sql”

Cherchez

_query = format["SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel, damage, blacklist FROM vehicles WHERE id='%1' AND pid='%2'",_vid,_pid];

Remplacez par

_query = format["SELECT id, side, classname, type, pid, alive, active, plate, color, insure FROM vehicles WHERE pid='%1' AND alive='1' AND active='0' AND side='%2' AND type='%3'",_pid,_side,_type];

Côté BDD

Allez sur votre base de donnée et dans l’onglet SQL entrez se code puis validé

ALTER TABLE vehicles ADD insure INT(1) NOT NULL DEFAULT '0';


#2

Petit erreur je pense … Le prix des assurance reste a 0 à mon avis :slight_smile: je pense que c’est a la récupération de la value inoDB ?


#3

Salut Blayfix, je te confirme ça des que je suis chez moi.


#4

As-tu bien vérifier car pour ma part, tout est ok, je viens de faire la vérification. Mon assurance se déduis biens


#5

Dans l’affichage du garage, assurance prix = 0$ aucune erreur coté log (client et server) altislife 5.0


#6

Vérifie ton config_master.hpp

/* Vehicle Insurance Prices */ 
vehicle_insurance_multiplier_CIVILIAN = .25; //Civilian Vehicle Insurance Price = Vehicle Buy Price * multiplier 
vehicle_insurance_multiplier_COP = .1; //Cop Vehicle Insurance Price = Vehicle Buy Price * multiplier 
vehicle_insurance_multiplier_MEDIC = .1; //Medic Vehicle Insurance Price = Vehicle Buy Price * multiplier 
vehicle_insurance_multiplier_OPFOR = -1; // -- NOT IN USE -- Simply left in for east support.


#7

J’ai exactement ça …


#8

Petite erreur au niveau du impoud.sqf :wink: RESOLU !
(J’ai pas vraiment fais pareil a ce niveau la pour une question de propretter)


#9

Blayfix Scott? confirme tu que tout est ok alors? Peux tu me partager ton impound.sqf pour que je comprenne se que tu as fais?


#10

Il suffit de bien suivre le tuto. J’avais juste essayer de bien remettre en forme mais mettais tromper sur une valeur tout simplement


#11

Erreur également pour moi, les prix sont tous à 0 et quand tu veux assurer/vendre… sa m’est un message en haut à droite de l’écran et sa ne marche pas.


#12

Ouvre un sujet dans aide avec tes logs :wink:


#13

Comme Blayfix Scott te l’indique, indique nous tes logs. Si non reverifie tes fichiers. Ou partage nous tes fichiers qu’on regarde ca.

Sans modif autre que se que j’indique il doit être fonctionnel

Je rentre pas avant 17h. On pourra se voir sur mon TS si tu nécessite plus d’infos


#14

J’ai je pense encore trouver une erreur.
Dans le fn_garageLBChange.sqf car si tu le laisse comme ça alors tu ne vois pas les prix du coup je donne mon fichier.

Le voici:

/*
    File: fn_garageLBChange.sqf
    Author: Bryan "Tonic" Boardwine

    Description:
    Can't be bothered to answer it.. Already deleted it by accident..
*/
disableSerialization;
private["_control","_index","_className","_classNameLife","_dataArr","_vehicleColor","_vehicleInfo","_trunkSpace","_sellPrice","_retrievePrice","_sellMultiplier","_insurance","_insuranceMultiplier","_price","_storageFee","_purchasePrice","_insurancePrice"];
_control = _this select 0;
_index = _this select 1;

//Fetch some information.
_dataArr = CONTROL_DATAI(_control,_index);
_dataArr = call compile format ["%1",_dataArr];
_className = (_dataArr select 0);
_classNameLife = _className;
_insurance = (_dataArr select 2 );

if (!isClass (missionConfigFile >> "LifeCfgVehicles" >> _classNameLife)) then {
    _classNameLife = "Default"; //Use Default class if it doesn't exist
    diag_log format ["%1: LifeCfgVehicles class doesn't exist",_className];
};

_vehicleColor = ((M_CONFIG(getArray,"LifeCfgVehicles",_classNameLife,"textures") select (_dataArr select 1)) select 0);
if (isNil "_vehicleColor") then {_vehicleColor = "Default";};

_vehicleInfo = [_className] call life_fnc_fetchVehInfo;
_trunkSpace = [_className] call life_fnc_vehicleWeightCfg;

_price = M_CONFIG(getNumber,"LifeCfgVehicles",_classNameLife,"price");
_storageFee = LIFE_SETTINGS(getNumber,"vehicle_storage_fee_multiplier");

switch (playerSide) do {
 case civilian: {
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_CIVILIAN");
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_CIVILIAN");
 _insuranceMultiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_CIVILIAN");
 };
 case west: {
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_COP");
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_COP");
 _insuranceMultiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_COP");
 };
 case independent: {
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_MEDIC");
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_MEDIC");
 _insuranceMultiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_MEDIC");
 };
 case east: {
 _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_OPFOR");
 _sellMultiplier = LIFE_SETTINGS(getNumber,"vehicle_sell_multiplier_OPFOR");
 _insuranceMultiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_OPFOR");
 };
};
_retrievePrice = _purchasePrice * _storageFee;
_sellPrice = _purchasePrice * _sellMultiplier;
_insurancePrice = _purchasePrice * _insuranceMultiplier;

if (!(_sellPrice isEqualType 0) || _sellPrice < 1) then {_sellPrice = 500;};
if (!(_retrievePrice isEqualType 0) || _retrievePrice < 1) then {_retrievePrice = 500;};
if (!(_insurancePrice isEqualType 0) || _insurancePrice < 1) then {_insurancePrice = 500;};

(CONTROL(2800,2803)) ctrlSetStructuredText parseText format [
    (localize "STR_Shop_Veh_UI_RetrievalP")+ " <t color='#8cff9b'>$%1</t><br/>
    " +(localize "STR_Shop_Veh_UI_SellP")+ " <t color='#8cff9b'>$%2</t><br/>
	" +(localize "STR_Shop_Veh_UI_insurprice")+ " <t color='#8cff9b'>$%9</t><br/>
	" +(localize "STR_Shop_Veh_UI_etapinsur")+ "<t color='#8cff9b'>%10</t><br/>
    " +(localize "STR_Shop_Veh_UI_Color")+ " %8<br/>
    " +(localize "STR_Shop_Veh_UI_MaxSpeed")+ " %3 km/h<br/>
    " +(localize "STR_Shop_Veh_UI_HPower")+ " %4<br/>
    " +(localize "STR_Shop_Veh_UI_PSeats")+ " %5<br/>
    " +(localize "STR_Shop_Veh_UI_Trunk")+ " %6<br/>
    " +(localize "STR_Shop_Veh_UI_Fuel")+ " %7
    ",
[_retrievePrice] call life_fnc_numberText,
[_sellPrice] call life_fnc_numberText,
(_vehicleInfo select 8),
(_vehicleInfo select 11),
(_vehicleInfo select 10),
if (_trunkSpace isEqualTo -1) then {"None"} else {_trunkSpace},
(_vehicleInfo select 12),
_vehicleColor,
[_insurancePrice] call life_fnc_numberText,
if(_insurance == 1) then {"<t color='#8cff9b'>Assuré</t>"} else {"<t color='#FF0000'>Pas d'assurance</t>"},
(_vehicleInfo select 9)
];
if(_insurance == 1) then {
ctrlShow [97480,False];
}else{
ctrlShow [97480,True];
};

ctrlShow [2803,true];
ctrlShow [2830,true]; 

Naturellement il faut aussi ajouter le nouveau code dans votre stingtable dans Shop_Strings:


        <Key ID="STR_Shop_Veh_UI_insurprice">
            <Original>Prix de l'assurance :</Original>
            <French>Prix de l'assurance :</French>
        </Key>
        <Key ID="STR_Shop_Veh_UI_etapinsur">
            <Original>Etat de l'assurance : </Original>
            <French>Etat de l'assurance : </French>
        </Key>

Voilà chez moi ça marche comme ça! :slight_smile:
Merci pour le tutoriel comme même et on espérons de vous avoir aider!


#15

Bonjour Specy peux-tu me dire ou as-tu réalisé la modification?


#16

Ici:

    (localize "STR_Shop_Veh_UI_RetrievalP")+ " <t color='#8cff9b'>$%1</t><br/>
    " +(localize "STR_Shop_Veh_UI_SellP")+ " <t color='#8cff9b'>$%2</t><br/>
	" +(localize "STR_Shop_Veh_UI_insurprice")+ " <t color='#8cff9b'>$%9</t><br/>
	" +(localize "STR_Shop_Veh_UI_etapinsur")+ "<t color='#8cff9b'>%10</t><br/>
    " +(localize "STR_Shop_Veh_UI_Color")+ " %8<br/>
    " +(localize "STR_Shop_Veh_UI_MaxSpeed")+ " %3 km/h<br/>
    " +(localize "STR_Shop_Veh_UI_HPower")+ " %4<br/>
    " +(localize "STR_Shop_Veh_UI_PSeats")+ " %5<br/>
    " +(localize "STR_Shop_Veh_UI_Trunk")+ " %6<br/>
    " +(localize "STR_Shop_Veh_UI_Fuel")+ " %7
    ",

#17

C’est bien se qui me semblait, ça ne change absolument rien au faite que le script fonctionne ou non. Tu n’as fais que définir une variable dans le stringtable et tu la localise. Mais en soit ça reste fonctionnel dans les deux cas


#18

Enfaite si tu ne changeais pas ce code alors quand tu ouvrais ton garage tu n’avais pas les informations du vehicule (prix de vente, couleur, prix de sortie, prix de l’assurance et si le vehicule est assuré ou pas)


#19

Oui j’ai jamais dit le contraire mais je ne voyais pas le prix de l’assurance donc c’est pas super je trouves


#20

Bah si, car moi il est fonctionnel sans avoir fait ton procédé, c’est que t’es trompé ailleurs.