Zitat von Zaros (10. September 2014)Alles anzeigen
Guten TagIch hau euch heute ein kleines Tutorial für das Permanente Impounden von Fahrzeuge raus
(Bis zum nächsten Restart).
Erstellt folgende Datei:
\core\actions\fn_impoundPermAction.sqf
Spoiler anzeigen
Code Alles anzeigen/* File: fn_impoundAction.sqf Author: Bryan "Tonic" Boardwine Description: Impounds the vehicle */ private["_vehicle","_type","_time","_price","_vehicleData","_upp","_ui","_progress","_pgText","_cP"]; _vehicle = cursorTarget; if(!((_vehicle isKindOf "Car") || (_vehicle isKindOf "Air") || (_vehicle isKindOf "Ship"))) exitWith {}; if(player distance cursorTarget > 10) exitWith {}; if((_vehicle isKindOf "Car") || (_vehicle isKindOf "Air") || (_vehicle isKindOf "Ship")) then { _vehicleData = _vehicle getVariable["vehicle_info_owners",[]]; if(count _vehicleData == 0) exitWith {deleteVehicle _vehicle}; //Bad vehicle. _vehicleName = getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"); [[0,format[localize "STR_NOTF_BeingImpounded",(_vehicleData select 0) select 1,_vehicleName]],"life_fnc_broadcast",true,false] spawn life_fnc_MP; life_action_inUse = true; _upp = localize "STR_NOTF_Impounding"; //Setup our progress bar. disableSerialization; 5 cutRsc ["life_progress","PLAIN"]; _ui = uiNameSpace getVariable "life_progress"; _progress = _ui displayCtrl 38201; _pgText = _ui displayCtrl 38202; _pgText ctrlSetText format["%2 (1%1)...","%",_upp]; _progress progressSetPosition 0.01; _cP = 0.01; while{true} do { sleep 0.09; _cP = _cP + 0.01; _progress progressSetPosition _cP; _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp]; if(_cP >= 1) exitWith {}; if(player distance _vehicle > 10) exitWith {}; if(!alive player) exitWith {}; }; 5 cutText ["","PLAIN"]; if(player distance _vehicle > 10) exitWith {hint localize "STR_NOTF_ImpoundingCancelled"; life_action_inUse = false;}; if(!alive player) exitWith {life_action_inUse = false;}; //_time = _vehicle getVariable "time"; //if(isNil {_time}) exitWith {deleteVehicle _vehicle; hint "This vehicle was hacked in"}; //if((time - _time) < 120) exitWith {hint "This is a freshly spawned vehicle, you have no right impounding it."}; if((count crew _vehicle) == 0) then { [_vehicle] call life_fnc_clearVehicleAmmo; if(!((_vehicle isKindOf "Car") || (_vehicle isKindOf "Air") || (_vehicle isKindOf "Ship"))) exitWith {life_action_inUse = false;}; _type = getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"); switch (true) do { case (_vehicle isKindOf "Car"): {_price = (call life_impound_car);}; case (_vehicle isKindOf "Ship"): {_price = (call life_impound_boat);}; case (_vehicle isKindOf "Air"): {_price = (call life_impound_air);}; }; life_impound_inuse = true; [[_vehicle,true,player,true],"TON_fnc_vehicleStore",false,false] spawn life_fnc_MP; waitUntil {!life_impound_inuse}; hint format[localize "STR_NOTF_Impounded",_type,_price]; [[0,format[localize "STR_NOTF_HasImpounded",player getVariable["realname",name player],(_vehicleData select 0) select 1,_vehicleName]],"life_fnc_broadcast",true,false] spawn life_fnc_MP; life_atmcash = life_atmcash + _price; } else { hint localize "STR_NOTF_ImpoundingCancelled"; }; }; life_action_inUse = false;Danach wechselt ihr in \core\vehicle\fn_vInteractionMenu.sqf
Hier müssen wir erstmal den Button definieren!
und nicht vergessen in die private zu adden
Spoiler anzeigen
Danach noch ca. Zeile 32-22 folgenden Code hinzufügen:
Jetzt setzen wir die Funktion, welche ausgeführt werden soll, wenn man Button 7 auswählt. Fügt dazu folgenden Code im Playerside-Check für West/east ein
Spoiler anzeigen
Das sollte dann so aussehen (immernoch fn_vInteractoinMenu.sqf):Spoiler anzeigen
Code Alles anzeigenif((playerSide in [west, east])) then { _Btn2 ctrlSetText localize "STR_vInAct_Registration"; _Btn2 buttonSetAction "[life_vInact_curTarget] spawn life_fnc_searchVehAction;"; _Btn3 ctrlSetText localize "STR_vInAct_SearchVehicle"; _Btn3 buttonSetAction "[life_vInact_curTarget] spawn life_fnc_vehInvSearch;"; _Btn4 ctrlSetText localize "STR_vInAct_PullOut"; _Btn4 buttonSetAction "[life_vInact_curTarget] spawn life_fnc_pulloutAction;"; if(count crew _curTarget == 0) then {_Btn4 ctrlEnable false;}; _Btn5 ctrlSetText localize "STR_vInAct_Impound"; _Btn5 buttonSetAction "[life_vInact_curTarget] spawn life_fnc_impoundAction;"; if(_curTarget isKindOf "Ship") then { _Btn6 ctrlSetText localize "STR_vInAct_PushBoat"; _Btn6 buttonSetAction "[] spawn life_fnc_pushObject; closeDialog 0;"; if(_curTarget isKindOf "Ship" && {local _curTarget} && {count crew _curTarget == 0}) then { _Btn6 ctrlEnable true;} else {_Btn6 ctrlEnable false}; } else { if(typeOf (_curTarget) in ["C_Kart_01_Blu_F","C_Kart_01_Red_F","C_Kart_01_Fuel_F","C_Kart_01_Vrana_F"]) then { _Btn6 ctrlSetText localize "STR_vInAct_GetInKart"; _Btn6 buttonSetAction "player moveInDriver life_vInact_curTarget; closeDialog 0;"; if(count crew _curTarget == 0 && {canMove _curTarget} && {locked _curTarget == 0}) then {_Btn6 ctrlEnable true;} else {_Btn6 ctrlEnable false}; } else { _Btn6 ctrlSetText localize "STR_vInAct_Unflip"; _Btn6 buttonSetAction "life_vInact_curTarget setPos [getPos life_vInact_curTarget select 0, getPos life_vInact_curTarget select 1, (getPos life_vInact_curTarget select 2)+0.5]; closeDialog 0;"; if(count crew _curTarget == 0 && {canMove _curTarget}) then { _Btn6 ctrlEnable false;} else {_Btn6 ctrlEnable true;}; }; }; _Btn7 ctrlSetText localize "STR_vInAct_Impound_Perm"; _Btn7 buttonSetAction "[life_vInact_curTarget] spawn life_fnc_impoundPermAction;"; } else {Jetzt legen wir die Position des Buttons wie folgt fest: \dialog\pInteraction.h
Ganz unten am Ende der Datei wird bei euch Button 6 sein. Nach diesem fügt ihr folgenden Code ein:
ACHTUNG! KLAMMERN BEACHTEN!
Spoiler anzeigen
Code Alles anzeigenclass ButtonSeven : life_RscButtonMenu { idc = 37456; colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5}; text = ""; sizeEx = 0.025; x = BGX + 0.03; y = BGY + 0.37; w = 0.24; h = 0.038; };Als nächstes fügen wir die Funktion in der Functions.h unter class Actions hinzu:
Nun noch den Button-Text in die Stringtable im Package "Vehicle_Interaction"
Spoiler anzeigen
Folgendes File solltet ihr am besten komplett übernehmen:
life_server\Functions\Systems\fn_vehicleStore.sqfSpoiler anzeigen
Code Alles anzeigen/* File: fn_vehicleStore.sqf Author: Bryan "Tonic" Boardwine Description: Stores the vehicle in the 'Garage' */ private["_vehicle","_impound","_vInfo","_vInfo","_plate","_uid","_query","_sql","_unit","_impound_perm"]; _vehicle = [_this,0,ObjNull,[ObjNull]] call BIS_fnc_param; _impound = [_this,1,false,[true]] call BIS_fnc_param; _unit = [_this,2,ObjNull,[ObjNull]] call BIS_fnc_param; _impound_perm = [_this,3,false,[true]] call BIS_fnc_param; if(isNull _vehicle OR isNull _unit) exitWith {life_impound_inuse = false; (owner _unit) publicVariableClient "life_impound_inuse";life_garage_store = false;(owner _unit) publicVariableClient "life_garage_store";}; //Bad data passed. _vInfo = _vehicle getVariable["dbInfo",[]]; if(count _vInfo > 0) then { _plate = _vInfo select 1; _uid = _vInfo select 0; }; if(_impound) then { if(count _vInfo == 0) then { life_impound_inuse = false; (owner _unit) publicVariableClient "life_impound_inuse"; if(!isNil "_vehicle" && {!isNull _vehicle}) then { deleteVehicle _vehicle; }; } else { if(_impound_perm) then { diag_log "Impound Permanent"; _query = format["UPDATE vehicles SET active='2' WHERE pid='%1' AND plate='%2'",_uid,_plate]; } else { diag_log "Impound to Garage"; _query = format["UPDATE vehicles SET active='0' WHERE pid='%1' AND plate='%2'",_uid,_plate]; }; waitUntil {!DB_Async_Active}; _thread = [_query,1] call DB_fnc_asyncCall; //waitUntil {scriptDone _thread}; if(!isNil "_vehicle" && {!isNull _vehicle}) then { deleteVehicle _vehicle; }; life_impound_inuse = false; (owner _unit) publicVariableClient "life_impound_inuse"; }; } else { if(count _vInfo == 0) exitWith { [[1,(localize "STR_Garage_Store_NotPersistent")],"life_fnc_broadcast",(owner _unit),false] spawn life_fnc_MP; life_garage_store = false; (owner _unit) publicVariableClient "life_garage_store"; }; if(_uid != getPlayerUID _unit) exitWith { [[1,(localize "STR_Garage_Store_NoOwnership")],"life_fnc_broadcast",(owner _unit),false] spawn life_fnc_MP; life_garage_store = false; (owner _unit) publicVariableClient "life_garage_store"; }; diag_log "STORING VEHICLE IN GARAGE"; _query = format["UPDATE vehicles SET active='0' WHERE pid='%1' AND plate='%2'",_uid,_plate]; waitUntil {!DB_Async_Active}; _thread = [_query,1] call DB_fnc_asyncCall; //waitUntil {scriptDone _thread}; if(!isNil "_vehicle" && {!isNull _vehicle}) then { deleteVehicle _vehicle; }; life_garage_store = false; (owner _unit) publicVariableClient "life_garage_store"; [[1,(localize "STR_Garage_Store_Success")],"life_fnc_broadcast",(owner _unit),false] spawn life_fnc_MP; };Nun müsst ihr noch in eurem Datenbank-Programm folgenden code zur Funktion "resetLifeVehicle" hinzufügen:
WENN IHR FAHRZEUGE PERMANENT LÖSCHEN WOLLT ÄNDERT DEN LETZTEN CODE WIE FOLGT AB!
Ich glaube das wars... falls ihr Fehler findet bitte posten!
Hinweis zur Zukunft von Nodezone
Das neue Nodezone befindet sich in der finalen Entwicklungsphase. Mit dem geplanten Start wird das bisherige Forum auf Read Only umgestellt und künftig als Archiv erhalten bleiben.
Alle Informationen zur neuen Plattform, zur Accountübernahme und zum weiteren Ablauf findest du hier: Zum aktuellen Nodezone Beitrag
Das neue Nodezone befindet sich in der finalen Entwicklungsphase. Mit dem geplanten Start wird das bisherige Forum auf Read Only umgestellt und künftig als Archiv erhalten bleiben.
Alle Informationen zur neuen Plattform, zur Accountübernahme und zum weiteren Ablauf findest du hier: Zum aktuellen Nodezone Beitrag