Hallo, wie kann ich NUR den Polizisten beim Spawnen eines Autos folgende Init dem Fahrzeug zuweisen: this animate ["daylights_hide", 1];this animate ["Secondary", 1];this animate ["Switch_2", 1];this animate ["Lightbar", 1];
Fahrzeug Init beim Spawnen zuweisen.
-
PoweredByte -
30. Juli 2016 um 13:17 -
Geschlossen -
Erledigt
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
-
-
in server/Functions/Systems/fn_spawnVehicle.sqf so etwas in der Art einbauen:
if(_side isEqualTo west) then {_vehicle animate ..... } -
Ich habe das jetzt so gemacht:
if(_side isEqualTo west) then {this animate ["daylights_hide", 1];this animate ["Secondary", 1];this animate ["Switch_2", 1];this animate ["Lightbar", 1];};
Und es funktioniert leider nicht. Habe ich was falsch gemacht?
So sieht der Code nun aus:
Code: fn_spawnVehicle.sqf
Alles anzeigen#include "\life_server\script_macros.hpp" /* File: fn_spawnVehicle.sqf Author: Bryan "Tonic" Boardwine Description: Sends the query request to the database, if an array is returned then it creates the vehicle if it's not in use or dead. */ private["_vid","_sp","_pid","_query","_sql","_vehicle","_nearVehicles","_name","_side","_tickTime","_dir","_servIndex"]; _vid = [_this,0,-1,[0]] call BIS_fnc_param; _pid = [_this,1,"",[""]] call BIS_fnc_param; _sp = [_this,2,[],[[],""]] call BIS_fnc_param; _unit = [_this,3,ObjNull,[ObjNull]] call BIS_fnc_param; _price = [_this,4,0,[0]] call BIS_fnc_param; _dir = [_this,5,0,[0]] call BIS_fnc_param; _unit_return = _unit; _name = name _unit; _side = side _unit; _unit = owner _unit; if(EQUAL(_vid,-1) OR EQUAL(_pid,"")) exitWith {}; if(_vid in serv_sv_use) exitWith {}; serv_sv_use pushBack _vid; _servIndex = serv_sv_use find _vid; _query = format["SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel FROM vehicles WHERE id='%1' AND pid='%2'",_vid,_pid]; _tickTime = diag_tickTime; _queryResult = [_query,2] call DB_fnc_asyncCall; if(EXTDB_SETTING(getNumber,"DebugMode") == 1) then { diag_log "------------- Client Query Request -------------"; diag_log format["QUERY: %1",_query]; diag_log format["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)]; diag_log format["Result: %1",_queryResult]; diag_log "------------------------------------------------"; }; if(EQUAL(typeName _queryResult,typeName "")) exitWith {}; _vInfo = _queryResult; if(isNil "_vInfo") exitWith {serv_sv_use deleteAt _servIndex;}; if(EQUAL(count _vInfo,0)) exitWith {serv_sv_use deleteAt _servIndex;}; if(EQUAL(SEL(_vInfo,5),0)) exitWith { serv_sv_use deleteAt _servIndex; [1,format[(localize "STR_Garage_SQLError_Destroyed"),_vInfo select 2]] remoteExecCall ["life_fnc_broadcast",_unit]; }; if(EQUAL(SEL(_vInfo,6),1)) exitWith { serv_sv_use deleteAt _servIndex; [1,format[(localize "STR_Garage_SQLError_Active"),_vInfo select 2]] remoteExecCall ["life_fnc_broadcast",_unit]; }; if!(EQUAL(typeName _sp,typeName "")) then { _nearVehicles = nearestObjects[_sp,["Car","Air","Ship"],10]; } else { _nearVehicles = []; }; if(count _nearVehicles > 0) exitWith { serv_sv_use deleteAt _servIndex; [_price,_unit_return] remoteExecCall ["life_fnc_garageRefund",_unit]; [1,(localize "STR_Garage_SpawnPointError")] remoteExecCall ["life_fnc_broadcast",_unit]; }; _query = format["UPDATE vehicles SET active='1' WHERE pid='%1' AND id='%2'",_pid,_vid]; _trunk = [_vInfo select 9] call DB_fnc_mresToArray; _gear = [_vInfo select 10] call DB_fnc_mresToArray; [_query,false] spawn DB_fnc_asyncCall; if(typeName _sp == "STRING") then { _vehicle = createVehicle[(_vInfo select 2),[0,0,999],[],0,"NONE"]; waitUntil {!isNil "_vehicle" && {!isNull _vehicle}}; _vehicle allowDamage false; _hs = nearestObjects[getMarkerPos _sp,["Land_Hospital_side2_F"],50] select 0; _vehicle setPosATL (_hs modelToWorld [-0.4,-4,12.65]); sleep 0.6; } else { _vehicle = createVehicle [(_vInfo select 2),_sp,[],0,"NONE"]; waitUntil {!isNil "_vehicle" && {!isNull _vehicle}}; _vehicle allowDamage false; _vehicle setPos _sp; _vehicle setVectorUp (surfaceNormal _sp); _vehicle setDir _dir; }; _vehicle setFuel (_vInfo select 11); _vehicle allowDamage true; //Send keys over the network. [_vehicle] remoteExecCall ["life_fnc_addVehicle2Chain",_unit]; [_pid,_side,_vehicle,1] call TON_fnc_keyManagement; _vehicle lock 2; //Reskin the vehicle [_vehicle,_vInfo select 8] remoteExecCall ["life_fnc_colorVehicle",_unit]; _vehicle setVariable["vehicle_info_owners",[[_pid,_name]],true]; _vehicle setVariable["dbInfo",[(_vInfo select 4),_vInfo select 7]]; _vehicle setVariable["Trunk",_trunk,true]; _vehicle disableTIEquipment true; //No Thermals.. They're cheap but addictive. [_vehicle] call life_fnc_clearVehicleAmmo; if (count _gear > 0) then { _items = _gear select 0; _mags = _gear select 1; _weapons = _gear select 2; _backpacks = _gear select 3; 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 (_weapons select 0)) - 1) do { _vehicle addWeaponCargoGlobal [((_weapons select 0) select _i), ((_weapons 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)]; }; }; if(_side isEqualTo west) then {this animate ["daylights_hide", 1];this animate ["Secondary", 1];this animate ["Switch_2", 1];this animate ["Lightbar", 1];}; //Sets of animations if(EQUAL(SEL(_vInfo,1),"civ") && EQUAL(SEL(_vInfo,2),"B_Heli_Light_01_F") && !(EQUAL(SEL(_vInfo,8),13))) then { [_vehicle,"civ_littlebird",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit]; }; if(EQUAL(SEL(_vInfo,1),"cop") && (SEL(_vInfo,2)) in ["C_Offroad_01_F","B_MRAP_01_F","C_SUV_01_F","C_Hatchback_01_sport_F","B_Heli_Light_01_F","B_Heli_Transport_01_F"]) then { [_vehicle,"cop_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit]; }; if(EQUAL(SEL(_vInfo,1),"med") && EQUAL(SEL(_vInfo,2),"C_Offroad_01_F")) then { [_vehicle,"med_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit]; }; [1,"Your vehicle is ready!"] remoteExecCall ["life_fnc_broadcast",_unit]; serv_sv_use deleteAt _servIndex; -
Ich versuche es mal mit meinem Laienwissen in Informatik zu erklären:
this zeigt immer auf sich selbst.
Du möchtest aber dein Fahrzeug animieren. Und das ist hier in der Datei durch _vehicle definiert.
Also musst du this durch _vehicle austauschen -
So sieht mein Code jetzt aus -> if(_side isEqualTo west) then {_vehicle animate ["daylights_hide", 1]; _vehicle animate ["Secondary", 1]; _vehicle animate ["Switch_2", 1]; _vehicle animate ["Lightbar", 1]; _vehicle setVariable ["Red", 0, TRUE]; _vehicle setVariable ["Green", 0, TRUE]; _vehicle setVariable ["Blue", 0.4, TRUE];};
Die Zeile: _vehicle setVariable ["Red", 0, TRUE]; _vehicle setVariable ["Green", 0, TRUE]; _vehicle setVariable ["Blue", 0.4, TRUE]; ist dafür da um dem Auto einen leichten Blauton zu verschaffen, aufjedenfall funktioniert es nicht

-
Probier mal bitte
C
Alles anzeigen#include "\life_server\script_macros.hpp" /* File: fn_spawnVehicle.sqf Author: Bryan "Tonic" Boardwine Description: Sends the query request to the database, if an array is returned then it creates the vehicle if it's not in use or dead. */ private["_vid","_sp","_pid","_query","_sql","_vehicle","_nearVehicles","_name","_side","_tickTime","_dir","_servIndex"]; _vid = [_this,0,-1,[0]] call BIS_fnc_param; _pid = [_this,1,"",[""]] call BIS_fnc_param; _sp = [_this,2,[],[[],""]] call BIS_fnc_param; _unit = [_this,3,ObjNull,[ObjNull]] call BIS_fnc_param; _price = [_this,4,0,[0]] call BIS_fnc_param; _dir = [_this,5,0,[0]] call BIS_fnc_param; _unit_return = _unit; _name = name _unit; _side = side _unit; _unit = owner _unit; if(EQUAL(_vid,-1) OR EQUAL(_pid,"")) exitWith {}; if(_vid in serv_sv_use) exitWith {}; serv_sv_use pushBack _vid; _servIndex = serv_sv_use find _vid; _query = format["SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel FROM vehicles WHERE id='%1' AND pid='%2'",_vid,_pid]; _tickTime = diag_tickTime; _queryResult = [_query,2] call DB_fnc_asyncCall; if(EXTDB_SETTING(getNumber,"DebugMode") == 1) then { diag_log "------------- Client Query Request -------------"; diag_log format["QUERY: %1",_query]; diag_log format["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)]; diag_log format["Result: %1",_queryResult]; diag_log "------------------------------------------------"; }; if(EQUAL(typeName _queryResult,typeName "")) exitWith {}; _vInfo = _queryResult; if(isNil "_vInfo") exitWith {serv_sv_use deleteAt _servIndex;}; if(EQUAL(count _vInfo,0)) exitWith {serv_sv_use deleteAt _servIndex;}; if(EQUAL(SEL(_vInfo,5),0)) exitWith { serv_sv_use deleteAt _servIndex; [1,format[(localize "STR_Garage_SQLError_Destroyed"),_vInfo select 2]] remoteExecCall ["life_fnc_broadcast",_unit]; }; if(EQUAL(SEL(_vInfo,6),1)) exitWith { serv_sv_use deleteAt _servIndex; [1,format[(localize "STR_Garage_SQLError_Active"),_vInfo select 2]] remoteExecCall ["life_fnc_broadcast",_unit]; }; if!(EQUAL(typeName _sp,typeName "")) then { _nearVehicles = nearestObjects[_sp,["Car","Air","Ship"],10]; } else { _nearVehicles = []; }; if(count _nearVehicles > 0) exitWith { serv_sv_use deleteAt _servIndex; [_price,_unit_return] remoteExecCall ["life_fnc_garageRefund",_unit]; [1,(localize "STR_Garage_SpawnPointError")] remoteExecCall ["life_fnc_broadcast",_unit]; }; _query = format["UPDATE vehicles SET active='1' WHERE pid='%1' AND id='%2'",_pid,_vid]; _trunk = [_vInfo select 9] call DB_fnc_mresToArray; _gear = [_vInfo select 10] call DB_fnc_mresToArray; [_query,false] spawn DB_fnc_asyncCall; if(typeName _sp == "STRING") then { _vehicle = createVehicle[(_vInfo select 2),[0,0,999],[],0,"NONE"]; waitUntil {!isNil "_vehicle" && {!isNull _vehicle}}; _vehicle allowDamage false; _hs = nearestObjects[getMarkerPos _sp,["Land_Hospital_side2_F"],50] select 0; _vehicle setPosATL (_hs modelToWorld [-0.4,-4,12.65]); sleep 0.6; } else { _vehicle = createVehicle [(_vInfo select 2),_sp,[],0,"NONE"]; waitUntil {!isNil "_vehicle" && {!isNull _vehicle}}; _vehicle allowDamage false; _vehicle setPos _sp; _vehicle setVectorUp (surfaceNormal _sp); _vehicle setDir _dir; }; _vehicle setFuel (_vInfo select 11); _vehicle allowDamage true; //Send keys over the network. [_vehicle] remoteExecCall ["life_fnc_addVehicle2Chain",_unit]; [_pid,_side,_vehicle,1] call TON_fnc_keyManagement; _vehicle lock 2; //Reskin the vehicle [_vehicle,_vInfo select 8] remoteExecCall ["life_fnc_colorVehicle",_unit]; _vehicle setVariable["vehicle_info_owners",[[_pid,_name]],true]; _vehicle setVariable["dbInfo",[(_vInfo select 4),_vInfo select 7]]; _vehicle setVariable["Trunk",_trunk,true]; _vehicle disableTIEquipment true; //No Thermals.. They're cheap but addictive. [_vehicle] call life_fnc_clearVehicleAmmo; if (count _gear > 0) then { _items = _gear select 0; _mags = _gear select 1; _weapons = _gear select 2; _backpacks = _gear select 3; 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 (_weapons select 0)) - 1) do { _vehicle addWeaponCargoGlobal [((_weapons select 0) select _i), ((_weapons 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)]; }; }; if(_side isEqualTo west) then {this animate ["daylights_hide", 1];this animate ["Secondary", 1];this animate ["Switch_2", 1];this animate ["Lightbar", 1];}; //Sets of animations switch((SEL(_vInfo,1))) do { case "cop": { [_vehicle,"cop_offroad",true] spawn life_fnc_vehicleAnimate; _vehicle animate ["daylights_hide", 1]; _vehicle animate ["Secondary", 1]; _vehicle animate ["Switch_2", 1]; _vehicle animate ["Lightbar", 1]; _vehicle setVariable ["Red", 0, TRUE]; _vehicle setVariable ["Green", 0, TRUE]; _vehicle setVariable ["Blue", 0.4, TRUE]; if((SEL(_vInfo,2)) in ["C_Offroad_01_F","B_MRAP_01_F","C_SUV_01_F","C_Hatchback_01_sport_F","B_Heli_Light_01_F","B_Heli_Transport_01_F"]) then { [_vehicle,"cop_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit]; }; }; case "civ": { if((SEL(_vInfo,2)) in ["C_Offroad_01_F"])then{ [_vehicle,"civ_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit]; }; if(EQUAL(SEL(_vInfo,2),"B_Heli_Light_01_F") && !(EQUAL(SEL(_vInfo,8),13))) then { [_vehicle,"civ_littlebird",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit]; }; }; case "med": { if((SEL(_vInfo,2)) in ["C_Offroad_01_F","B_MRAP_01_F","C_SUV_01_F","C_Hatchback_01_sport_F","B_Heli_Light_01_F","B_Heli_Transport_01_F"]) then { [_vehicle,"med_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit]; }; }; }; [1,"Your vehicle is ready!"] remoteExecCall ["life_fnc_broadcast",_unit]; serv_sv_use deleteAt _servIndex;