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 :
Je ne comprend pas vraiment pourquoi... Si vous avez une idée je suis preneur
Merci !
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
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";