The-Programmer Forum

LustyFR a écrit le dernier message :
#4
Hello! C'est pas la méthode la plus propre, mais c'est la plus simple à expliquer. Ajoute à la fin de ton fn_vehicleCreate.sqf :
Code:
[_vehicle,_uid,_plate] spawn {
    _contractNumber = round (random 1000000);
    uiSleep 5;

    _query = format ["UPDATE vehicles SET insurance='4', dateInsurance=CURRENT_TIMESTAMP, contract_number='%3', expiration_date=DATE_ADD(CURRENT_TIMESTAMP, INTERVAL 2 DAY) WHERE pid='%1' AND plate='%2'",(_this select 1),(_this select 2),_contractNumber];
    [_query,1] call DB_fnc_asyncCall;

    uiSleep 1;

    _query = format ["SELECT CONCAT('""',expiration_date,'""'), CONCAT('""',dateInsurance,'""') FROM vehicles WHERE pid='%1' AND plate='%2'",(_this select 1),(_this select 2)];
    _queryResult = [_query,2] call DB_fnc_asyncCall;

    private _expirationDate = _queryResult select 0;
    _expirationDate = call compile _expirationDate;

    private _dateInsurance = _queryResult select 1;
    _dateInsurance = call compile _dateInsurance;

    (_this select 0) setVariable ["vehicle_insurance_contract",_contractNumber,true];
    (_this select 0) setVariable ["vehicle_insure_status",4,true];
    (_this select 0) setVariable ["vehicle_insurance_expiration",_expirationDate,true];
    (_this select 0) setVariable ["vehicle_insurance_date",_dateInsurance,true];
};

Au top !

Cela fonctionne parfaitement.

Merci ;)