Welcome to this tutorial that will allow you separate garages according to their position. For example, vehicles stored in a specific garage can only be retrieved from this garage.
This tutorial is a follow to the request for help from L Lilbape.
This tutorial is a follow to the request for help from L Lilbape.
Let's go !
On your mapping, you should have a line like this in the init of the object to store your vehicle in the garage:
Code:
this addAction[localize "STR_MAR_Store_vehicle_in_Garage",life_fnc_storeVehicle,"",0,false,false,"",'!life_garage_store'];
Replace :
Code:
life_fnc_storeVehicle
Code:
{[cursorObject,player,"kavala"] call life_fnc_storeVehicle;}
This will result in :
Code:
this addAction[localize "STR_MAR_Store_vehicle_in_Garage",{[player,false,"kavala"] call life_fnc_storeVehicle;},"",0,false,false,"",'!life_garage_store'];
In the init of the garage for take out the vehicles, replace this line :
Code:
[getPlayerUID player,playerSide,"Car",player] remoteExecCall ["TON_fnc_getVehicles",2];
Code:
[getPlayerUID player,playerSide,"Car",player,"kavala"] remoteExecCall ["TON_fnc_getVehicles",2];
In your core/actions/fn_storeVehicle.sqf, search this line :
Code:
[_vehicle,false,(_this select 1),_storetext] remoteExec ["TON_fnc_vehicleStore",RSERV];
Code:
[_vehicle,false,(_this select 1),_storetext,(param [2,"",["",0]])] remoteExec ["TON_fnc_vehicleStore",RSERV];
Add at the end of your life_server/Functions/Systems/fn_vehicleStore.sqf :
Code:
_garageName = param [4,"",["",0]];
if (_garageName isEqualType "") then {
if !(_garageName isEqualTo "") then {
_query = format ["UPDATE vehicles SET garage_name='""%1""' WHERE pid='%2' AND plate='%3'",_garageName,_uid,_plate];
[_query,1] call DB_fnc_asyncCall;
};
};
In your life_server/Functions/Systems/fn_getVehicles.sqf, replace :
Code:
_query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color FROM vehicles WHERE pid='%1' AND alive='1' AND active='0' AND side='%2' AND type='%3'",_pid,_side,_type];
Code:
_garageName = param [4,"",[""]];
_query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color FROM vehicles WHERE pid='%1' AND alive='1' AND active='0' AND side='%2' AND type='%3'",_pid,_side,_type];
if !(_garageName isEqualTo "") then {
_query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color FROM vehicles WHERE pid='%1' AND alive='1' AND active='0' AND side='%2' AND type='%3' AND garage_name='""%4""'",_pid,_side,_type,_garageName];
};
In your database, run the following code :
Code:
ALTER TABLE `vehicles` ADD COLUMN `garage_name` TEXT NOT NULL;
-----
If all your garages depend on a position, you will need to set a default garage for new purchased vehicles that are not stored in the garage before the server reboot, otherwise they will not be visible anywhere in the garages.
To do this, in your life_server/Functions/MySQL/fn_insertVehicle.sqf, replace this line :
Code:
_query = format ["INSERT INTO vehicles (side, classname, type, pid, alive, active, inventory, color, plate, gear, damage) VALUES ('%1', '%2', '%3', '%4', '1','1','""[[],0]""', '%5', '%6','""[]""','""[]""')",_side,_className,_type,_uid,_color,_plate];
Code:
_query = format ["INSERT INTO vehicles (side, classname, type, pid, alive, active, inventory, color, plate, gear, damage, garage_name) VALUES ('%1', '%2', '%3', '%4', '1','1','""[[],0]""', '%5', '%6','""[]""','""[]""','""kavala""')",_side,_className,_type,_uid,_color,_plate];
-----
Here we go !
Sincerely,
Forum Manager - Mathis
Dernière édition par un modérateur: