Français Solved Problème avec le chargement des véhicules après un redémarrage

  • Auteur de la discussion Auteur de la discussion Valkentinx
  • Date de début Date de début

Valkentinx

User
10/10/22
24
1
300
Bonjour,

J'ai créé aujourd'hui un script de sauvegarde de position pour les véhicules. Mais j'ai un problème lorsque je veux effectuer le chargement des véhicules après le redémarrage.

J'ai cette erreur :

Code:
21:05:11 "[VEHICLES] Loading"
21:05:11 Error in expression <g format["Loading vehicle -%1- %2", (_x select 4), (_x select 2)];

if ((_x sele>
21:05:11   Error position: <select 4), (_x select 2)];

if ((_x sele>
21:05:11   Error Generic error in expression

Je ne comprend pas vraiment pourquoi... Si vous avez une idée je suis preneur :D

Merci !


Code:
/*

        0       objects.id,
        1       objects.type,
        2       objects.class,
        3       objects.customName,
        4       objects.uid,
        5       objects.plystorage,
        6       objects.spawn,
        7       objects.pos,
        8       objects.dir,
        9       objects.vars,
        10      objects.impounded,
        11      objects.fuel,
        12      objects.color,
        13      objects.material,
        14      objects.stolen,
        15      objects.numpchange,
        16      objects.iscustomplate,
        17      objects.vstorage,
        18      objects.istorage,
        19      objects.tuning,
        20      objects.damage,
        21      objects.insurance,
        22      objects.cid

*/

diag_log "[VEHICLES] Loading";

    {
        diag_log format["Loading vehicle -%1- %2", (_x select 4), (_x select 2)];

        if ((_x select 7) isEqualTo []) then
        {
            diag_log "[ERROR] Cannot spawn : no position";
            [format["UPDATE objects SET spawn='0',plystorage='1',pos='[]' WHERE id='%1'", (_x select 0)], 1] call Server_Database_Async;
        } else {
            _vehicle = [(_x select 2),(_x select 7),(_x select 0),(_x select 4)] call Server_Vehicle_Spawn;
            waitUntil {!(isNull _vehicle)};
            diag_log "Vehicle spawned";

            _vehicle allowDamage false;

            _vehicle setDir (_x select 8);
            _vehicle setVariable ["locked",true,true];

            if(_x#11 < 0.1 && {_vehicle isKindOf "Ship"}) then {
                _vehicle setFuel 0.1;
            } else {
                _vehicle setFuel (_x select 11);
            };

            _damage = [(_x select 20)] call Server_Database_ToArray;
            if((count _damage) > 0) then {
                _parts = getAllHitPointsDamage _vehicle;
                for "_i" from 0 to ((count _damage) - 1) do {
                    _vehicle setHitPointDamage [format ["%1",((_parts select 0) select _i)],_damage select _i];
                };
            };

            if((_x select 12) != "<null>") then {
                _vehicle setObjectTextureGlobal [0,(_x select 12)];
            };

            if((_x select 13) != "<null>") then {
                _vehicle setObjectMaterialGlobal [0,(_x select 13)];
            };

            _vehicle setVariable["numPChange",(_x select 15),true];
            _vehicle setVariable["isCustomPlate",(_x select 16),true];

            if((_x select 21) isEqualTo 1) then {
                _vehicle setVariable["insurance",true,true];
            } else {
                _vehicle setVariable["insurance",false,true];
            };

            _iInventory = [(_x select 18)] call Server_Database_ToArray;
            if ((count _iInventory) > 0) then {
                _items = _iInventory select 0;
                _mags = _iInventory select 1;
                _backpacks = _iInventory select 2;
                _weapons = _iInventory select 3;

                clearItemCargoGlobal _vehicle;
                clearMagazineCargo _vehicle;
                clearWeaponCargoGlobal _vehicle;
                clearBackpackCargoGlobal _vehicle;
                for "_i" from 0 to ((count (_items select 0)) - 1) do {
                    _vehicle addItemCargoGlobal [((_items select 0) select _i), ((_items select 1) select _i)];
                };
                for "_i" from 0 to ((count (_mags select 0)) - 1) do {
                    _vehicle addMagazineCargoGlobal [((_mags select 0) select _i), ((_mags select 1) select _i)];
                };
                for "_i" from 0 to ((count (_backpacks select 0)) - 1) do {
                    _vehicle addBackpackCargoGlobal [((_backpacks select 0) select _i), ((_backpacks select 1) select _i)];
                };
                for "_i" from 0 to ((count (_weapons select 0)) - 1) do {
                    _vehicle addWeaponCargoGlobal [((_weapons select 0) select _i), ((_weapons select 1) select _i)];
                };
            };

            _virtualInventory = [(_x select 17)] call Server_Database_ToArray;
            _vehicle setVariable["storage",_virtualInventory,true];

            _vehicle setVariable["cid",(_x select 22),true];

            _addons = [(_x select 19)] call Server_Database_ToArray;
            if ((count _addons) > 0) then {
                {
                    _animName = _x select 0;
                    _animPhase = _x select 1;
                    _vehicle animatesource [_animName, _animPhase, true];
                } foreach _addons;
            };

            _vehicle allowDamage true;
        };
    } forEach (([format["SELECT objects.id,objects.type,objects.class,objects.customName,objects.uid,objects.plystorage,objects.spawn,objects.pos,objects.dir,objects.vars,objects.impounded,objects.fuel,objects.color,objects.material,objects.stolen,objects.numpchange,objects.iscustomplate,objects.vstorage,objects.istorage,objects.tuning,objects.damage,objects.insurance,objects.cid FROM objects INNER JOIN players ON objects.uid=players.uid WHERE spawn='1'"],2] call Server_Database_Async));

    diag_log "[VEHICLES] Ready";
 
Hello Maxence Maxence

Voici ce que j'obtiens :

Code:
11:13:18 "[VEHICLES] Loading"
11:13:19 "DEBUG _x : eawhvxm"
11:13:19 Error in expression <g format["Loading vehicle -%1- %2", (_x select 4), (_x select 2)];

if ((_x sele>
11:13:19   Error position: <select 4), (_x select 2)];

if ((_x sele>
11:13:19   Error Generic error in expression

eawhvxm étant l'ID d'un des véhicules de la DB
 
Ce n'est pas normal, tu devrais avoir un array de ce genre [eawhvxm,...] avec les valeurs des autres colonnes de la base de données.

Tu n'es pas sur TONIC à ce que je vois. Est-ce que tu peux envoyer le code de ta fonction Server_Database_Async ?

Voici la fonction, en effet je ne suis pas sûr TONIC

Code:
private["_queryResult","_key","_return","_loop"];
    params [["_queryStmt","",[""]],["_mode",1,[0]],["_multiarr",false,[false]]];

    _key = "extDB3" callExtension format["%1:%2:%3", _mode, (call extDBCustomID), _queryStmt];

    if(_mode isEqualTo 1) exitWith {true};

    _key = call compile format["%1",_key];
    _key = _key select 1;

    _queryResult = "";
    _loop = true;
    while{_loop} do {
        _queryResult = "extDB3" callExtension format["4:%1", _key];
        if (_queryResult isEqualTo "[5]") then {
            // extDB3 returned that result is Multi-Part Message
            _queryResult = "";
            while{true} do {
                _pipe = "extDB3" callExtension format["5:%1", _key];
                if(_pipe == "") exitWith {_loop = false};
                _queryResult = _queryResult + _pipe;
            };
        } else {
            if (_queryResult isEqualTo "[3]") then {
                //diag_log format ["extDB3: uiSleep [4]: %1", diag_tickTime];
                //uiSleep 0.1;
            } else {
                _loop = false;
            };
        };
    };

    _queryResult = call compile _queryResult;

    if((_queryResult select 0) isEqualTo 0) exitWith {diag_log format ["extDB3: Protocol Error: %1", _queryResult]; []};
    _return = _queryResult select 1;

    if(!_multiarr && count _return > 0) then {
        _return = _return select 0;
    };

    _return;
 
Merci :)
Tu peux essayer de remplacer cette ligne :
Code:
} forEach (([format["SELECT objects.id,objects.type,objects.class,objects.customName,objects.uid,objects.plystorage,objects.spawn,objects.pos,objects.dir,objects.vars,objects.impounded,objects.fuel,objects.color,objects.material,objects.stolen,objects.numpchange,objects.iscustomplate,objects.vstorage,objects.istorage,objects.tuning,objects.damage,objects.insurance,objects.cid FROM objects INNER JOIN players ON objects.uid=players.uid WHERE spawn='1'"],2] call Server_Database_Async));
par :
Code:
} forEach (([format["SELECT objects.id,objects.type,objects.class,objects.customName,objects.uid,objects.plystorage,objects.spawn,objects.pos,objects.dir,objects.vars,objects.impounded,objects.fuel,objects.color,objects.material,objects.stolen,objects.numpchange,objects.iscustomplate,objects.vstorage,objects.istorage,objects.tuning,objects.damage,objects.insurance,objects.cid FROM objects INNER JOIN players ON objects.uid=players.uid WHERE spawn='1'"],2,true] call Server_Database_Async));
 
Hello Maxence Maxence

Ca a l'air de fonctionner, cependant j'ai une nouvelle erreur avec ma variable _vehicle.

Code:
14:02:17 "[VEHICLES] Loading"
14:02:18 "DEBUG _x : [""eawhvxm"",""vehicle"",""Rover"",""noCustomName"",""76561198170351694"",1,1,""[2878.65,5561.78,-0.040863]"",""333"",""[]"",0,0.33,""textures\range_rover\aussie.paa"",""cars\common\rvmats\black_plastic.rvmat"",0,0,0,""[]"",""[]"",""[[`Towbar_Addon`,0],[`Roof_Rack`,1],[`Camping_Equipment`,1],[`Roof_Lights`,0],[`Ladder`,0],[`Snorkel`,0],[`Winch`,0],[`Bull_Bar`,1],[`Lightbar`,0],[`Bumper_Guard`,0],[`Brakelight_Guards`,0]]"",""[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]"",0,0]"
14:02:18 "Loading vehicle -76561198170351694- Rover"
14:02:18 Bad conversion: array
14:02:18 Error in expression <_veh setPosATL _hotFix;
} else {
_veh = createVehicle [_class, _pos, [], 0, 'CAN>
14:02:18   Error position: <createVehicle [_class, _pos, [], 0, 'CAN>
14:02:18   Error 0 elements provided, 3 expected
14:02:18 "Server_Vehicle_Spawn Error: _veh isNull"
14:02:18 Error in expression <rver_Vehicle_Spawn;
waitUntil {!(isNull _vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error position: <_vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error Undefined variable in expression: _vehicle
14:02:18 Error in expression <] call Server_Vehicle_Spawn;
waitUntil {!(isNull _vehicle)};
diag_log "Vehicle s>
   Error position: <!(isNull _vehicle)};
diag_log "Vehicle s>
   Error Undefined behavior: waitUntil returned nil. True or false expected.
14:02:18 Error in expression <rver_Vehicle_Spawn;
waitUntil {!(isNull _vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error position: <_vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error Undefined variable in expression: _vehicle
14:02:18 Error in expression <rver_Vehicle_Spawn;
waitUntil {!(isNull _vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error position: <_vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error Undefined variable in expression: _vehicle
14:02:18 Error in expression <rver_Vehicle_Spawn;
waitUntil {!(isNull _vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error position: <_vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error Undefined variable in expression: _vehicle
14:02:18 Error in expression <rver_Vehicle_Spawn;
waitUntil {!(isNull _vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error position: <_vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error Undefined variable in expression: _vehicle
14:02:18 Error in expression <rver_Vehicle_Spawn;
waitUntil {!(isNull _vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error position: <_vehicle)};
diag_log "Vehicle spawned";
>
14:02:18   Error Undefined variable in expression: _vehicle


Voici la fonction Server_Vehicle_Spawn (a savoir qu'elle fonctionne dans tous mes autres scripts, je ne comprend pas pourquoi elle ne fonctionne pas à cet endroit)


Code:
    params[["_class",""],["_pos",[0,0,0]],["_id",-1],["_owner",objNull],["_doj",false]];
    private _initfunction = !isNil ('Server_Vehicle_Init_' + _class);
    private _lightbarInit = ["Tahoe_PD","CVPI_PD","Mustang_PD","Charger_PD","Silverado_PD","Charger15_PD"];
    private _slicktopInit = ["Tahoe_PD_Slicktop","CVPI_PD_Slicktop","Mustang_PD_Slicktop","Charger_PD_Slicktop"];
    private _veh = ObjNull;

    if (typename _pos == 'Object') then {
        _hotFix = (getPosATL _pos);
        _hotFix set[2, (_hotFix#2)+0.75];
        _veh = createVehicle [_class, _hotFix, [], 0, 'CAN_COLLIDE'];
        _veh setDir (getDir _pos);
        _veh setPosATL _hotFix;
    } else {
        _veh = createVehicle [_class, _pos, [], 0, 'CAN_COLLIDE'];
    };
    if (isNull _veh) exitwith {diag_log "Server_Vehicle_Spawn Error: _veh isNull"};

    _veh setFuelCargo 0;
    _veh setVariable ["owner",[(getplayerUID _owner),_id],true];
    _veh setVariable ["locked",true,true];
    Server_Storage_ListVehicles pushback _veh;
    if (_id IN ["EBOUEUR","LIVREUR","EXTERMINATEUR","KARTING","ROUTIER","CAPITAINE","DEMENAGEUR"]) then {
        switch (_class) do {
            case ("P362_Garbage_Truck"): {
                _veh setObjectTextureGlobal [0,"\Textures\Peterbilt_Garbage_Truck\Waste_Management_Garbage_Truck.paa"];
                if(_pos isEqualTo [2119.36,5155.03,0.3]) then {_veh setDir 178.6;};
            };
            case ("Mailtruck"):
            {
                if (_id isEqualTo "EXTERMINATEUR") then {
                    _veh setObjectTextureGlobal [0,"\Textures\MailTruck\Exterminator_Truck.paa"];
                };
                if (_id isEqualTo "LIVREUR") then
                {
                    private _setDir = switch{_pos} do {
                        case [6056.77,7393.57,0]: {33.8471};
                        case [3507.66,7541.57,0]: {96};
                        case [10313.1,8556.05,0]: {271.516};
                        case [4143.49,6317.9,0]: {91.5289};
                        case [2213.505,11845.4,0]: {271.575};
                        default {30};
                    };
                    _veh setDir(_setDir);
                };
            };
        };
        _owner setVariable ["jobVehicle",_veh,true];
    };
    if (_id isEqualTo "FEDERAL") then {_veh setDir (getDir _owner)};
    if (_doj) then {
        _texture = switch (_class) do {
            case "Taurus": {"\Textures\Taurus\DOJ.paa"};
            case "Tahoe": {"\Textures\Tahoe18\DOJ.paa"};
            case "Focus": {"\Textures\Focus\DOJ.paa"};
            case "Mustang15": {"\Textures\Mustang15\DOJ.paa"};
        };
        _veh setObjectTextureGlobal [0,_texture];
        _owner setVariable ["dojVehicle",_veh,true];
        _veh setVariable ["dojVehicle",true,true];
        _veh setDir 305;
    };

    [_veh,_id] call Server_Vehicle_Init_General;

    if (_initfunction) then {_veh call (missionNamespace getVariable ('Server_Vehicle_Init_' + _class));};
    if (_class IN _lightbarInit) then {_veh call Server_Vehicle_Init_FactionCar;};
    if (_class IN _slicktopInit) then {_veh call Server_Vehicle_Siren_Init;};

    if ((typeOf _veh) IN HitchingVehicles) then{_veh call Server_Vehicle_Init_F150;};
    if(typeOf _veh IN ["MiniExcavator","Boat_Trailer"]) then {
        _veh allowdamage false;
    };

    if(((_owner getVariable["job","sans emploi"]) isEqualTo "police") && {_class isEqualTo "RHIB"}) then {
        _veh setObjectTextureGlobal [0,"\Textures\RHIB\Default\CG_RHIB.paa"];
        _veh setObjectTextureGlobal [1,"\Textures\RHIB\Default\CG_RHIB_P2.paa"];
    };
    [_veh] remoteExec ["Function_Vehicle_AddKey",_owner];
    _veh;
 
Tu peux essayer de remplacer cette ligne :
Code:
_vehicle = [(_x select 2),(_x select 7),(_x select 0),(_x select 4)] call Server_Vehicle_Spawn;
par :
Code:
_vehicle = [(_x select 2),call compile format ["%1", (_x select 7)],(_x select 0),(_x select 4)] call Server_Vehicle_Spawn;
 
Maxence Maxence Ah super merci beaucoup! Je ne pensais pas que ça fonctionnerait avec un call compile.... désolé

Actuellement j'essaie de donner les clés au joueur qui possède le véhicule quand il se connecte.

J'ai donc ma fonction de base pour donner les clés qui fonctionne parfaitement lorsque je fais spawn le véhicule via un achat par exemple.

Function_Vehicle_AddKey :
Code:
private _veh = param [0,objNull];
    private _add = param [1,true];
    if(_add) then {
        if(_veh IN Player_Vehicles) exitWith {};
        Player_Vehicles pushback _veh;
        [format["Vous avez réçu la clé de %1.",getText(configFile >> "CfgVehicles" >> (typeOf _veh) >> "displayName")],Color_Green] call Function_Player_Notification;
    } else {
        Player_Vehicles = Player_Vehicles - [_veh];
    };
    [Player_Vehicles, getPlayerUID player] remoteExec ["Server_Vehicle_SaveKeys",2];
    [] call Function_Vehicle_KeysVerify;

Via un foreach j'essaie donc de donner les clés de cette manière lors du chargement des données du joueur :

Server_Vehicle_addKeysAfterLoad :
Code:
private _player = param [0,objNull];
    {
        diag_log format ["DEBUG _x : %1",_x];
        diag_log format["Vehicle key added -%1- %2", (_x#4), (_x#2)];

        [_x#0] remoteExec ["Function_Vehicle_AddKey",_player];
    } forEach (([format["SELECT objects.id,objects.type,objects.class,objects.customName,objects.uid,objects.plystorage,objects.spawn,objects.pos,objects.dir,objects.vars,objects.impounded,objects.fuel,objects.color,objects.material,objects.stolen,objects.numpchange,objects.iscustomplate,objects.vstorage,objects.istorage,objects.tuning,objects.damage,objects.insurance,objects.cid FROM objects INNER JOIN players ON objects.uid=players.uid WHERE spawn='1' AND plystorage='0'"],2,true] call Server_Database_Async));

Voici comment je call cela dans le script de chargement du joueur :

Function_Player_Initialize :
Code:
[player] remoteExec ["Server_Vehicle_addKeysAfterLoad",2];

J'ai donc remis le diag_log pour savoir ce que je récupère, et j'obtiens cela :

Code:
19:19:27 "Debug_RemoteExecServer - Caller: 76561198170351694 Code: {[player] remoteExec [""Server_Vehicle_addKeysAfterLoad"",2];}"
19:19:27 "DEBUG _x : [""eawhvxm"",""vehicle"",""Rover"",""noCustomName"",""76561198170351694"",0,1,""[2877.77,5563.03,-0.113517]"",""333.064"",""[]"",0,0,""textures\range_rover\aussie.paa"",""cars\common\rvmats\black_plastic.rvmat"",0,0,0,""[[`bucket_empty`,5]]"",""[[[`ItemGPS`,`ItemMap`],[1,1]],[[],[]],[[],[]],[[],[]]]"",""[[`Towbar_Addon`,0],[`Roof_Rack`,1],[`Camping_Equipment`,1],[`Roof_Lights`,0],[`Ladder`,0],[`Snorkel`,0],[`Winch`,0],[`Bull_Bar`,1],[`Lightbar`,0],[`Bumper_Guard`,0],[`Brakelight_Guards`,0]]"",""[1,0,0,1,1,0,0,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0.0708661,0.0629921,0,0,0,0,0,0,0,0,0,0,0,0]"",0,0]"
19:19:27 "Vehicle key added -76561198170351694- Rover"
19:19:27 A null object passed as a target to RemoteExec(Call) 'function_vehicle_addkey'
19:19:27 "DEBUG _x : [""shopvvy"",""vehicle"",""CVPI"",""noCustomName"",""76561198170351694"",0,1,""[3018.32,5623.19,-0.00525475]"",""90.0004"",""[]"",0,1,""#(argb,8,8,3)color(0,0,0,1.0,co)"",""cars\common\rvmats\cvpi_rusty.rvmat"",0,0,0,""[]"",""[]"",""[]"",""[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]"",0,0]"
19:19:27 "Vehicle key added -76561198170351694- CVPI"
19:19:27 A null object passed as a target to RemoteExec(Call) 'function_vehicle_addkey'
19:19:28 "DEBUG _x : [""eawhvxm"",""vehicle"",""Rover"",""noCustomName"",""76561198170351694"",0,1,""[2877.77,5563.03,-0.113517]"",""333.064"",""[]"",0,0,""textures\range_rover\aussie.paa"",""cars\common\rvmats\black_plastic.rvmat"",0,0,0,""[[`bucket_empty`,5]]"",""[[[`ItemGPS`,`ItemMap`],[1,1]],[[],[]],[[],[]],[[],[]]]"",""[[`Towbar_Addon`,0],[`Roof_Rack`,1],[`Camping_Equipment`,1],[`Roof_Lights`,0],[`Ladder`,0],[`Snorkel`,0],[`Winch`,0],[`Bull_Bar`,1],[`Lightbar`,0],[`Bumper_Guard`,0],[`Brakelight_Guards`,0]]"",""[1,0,0,1,1,0,0,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0.0708661,0.0629921,0,0,0,0,0,0,0,0,0,0,0,0]"",0,0]"
19:19:28 "Vehicle key added -76561198170351694- Rover"
19:19:28 "DEBUG _x : [""shopvvy"",""vehicle"",""CVPI"",""noCustomName"",""76561198170351694"",0,1,""[3018.32,5623.19,-0.00525475]"",""90.0004"",""[]"",0,1,""#(argb,8,8,3)color(0,0,0,1.0,co)"",""cars\common\rvmats\cvpi_rusty.rvmat"",0,0,0,""[]"",""[]"",""[]"",""[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]"",0,0]"
19:19:28 "Vehicle key added -76561198170351694- CVPI"


A savoir que :
  • J'ai du exécuter la commande manuellement -> [player] remoteExec ["Server_Vehicle_addKeysAfterLoad",2]; (parce qu'elle ne s'exécute pas quand le player load, je ne comprend pas pourquoi)
  • 19:19:27 A null object passed as a target to RemoteExec(Call) 'function_vehicle_addkey' -> Je ne comprend pas sachant qu'il récupère bien toutes les données de mon foreach d'après ce que je vois dans les logs, donc pourquoi "a null object"? Ca me semble assez bizarre

Merci à toi
 
Dans ta Function_Vehicle_AddKey ton premier paramètre dois être un objet :
Code:
private _veh = param [0,objNull];

Il faut donc envoyer un objet à la place du x#0 ici :
Code:
[_x#0] remoteExec ["Function_Vehicle_AddKey",_player];

Mais à quoi correspond ton objects.id dans ta base de données ?
 
Maxence Maxence

Ah je vois ! Objects.id correspond à l’ID unique du véhicule dans la db (et correspond aussi à sa plaque d’immatriculation)

J’ai essayé de remplacer le _x#0 par _x pour sélectionner l’ensemble des données mais ça ne marche pas non plus. Sûrement parce qu’il ne considère pas ça comme un objet non plus.. mais je ne vois pas comment faire pour récupérer l’objet
 
Code:
_vehicles = nearestObjects [player, ["Air","Thing","LandVehicle","Ship"],10];
    {
        _owner = _x getVariable ["owner",[]];
        if ((_owner#0) isEqualTo (getplayerUID _player)) then {
            diag_log format["Vehicle key added -%1- %2", (_owner#0), (_owner#1)];
            [_x] remoteExec ["Function_Vehicle_AddKey",_player];
        };
    } forEach _vehicles;

J'ai modifié le script et ça fonctionne bien, sauf que j'ai un dernier problème.

J'ai donc essayé cela pour voir :
Code:
_vehicles = nearestObjects [player, ["Air","Thing","LandVehicle","Ship"],10];
{
        _owner = _x getVariable ["owner",[]];
        hint format["%1",_owner];
} forEach _vehicles;

Actuellement ce code au dessus me retourne cela pour les véhicules dans un rayon de 10m autour de moi :
Code:
["76561198170351694","showvvy"] //["uid","id_de_la_voiture"]

Sauf que quand j'augmente le rayon du nearestObjects par un nombre supérieur à 10, par exemple 1000000 pour couvrir toute la surface de la carte, cela me retourne
Code:
[]

Du coup, forcément, si mon joueur est loin de son véhicule, il n'aura pas les clés, parce que le script ne veux fonctionner que si le joueur est proche de son véhicule et pas au dela de 10m.

Je n'arrive pas à comprendre pourquoi