Allgemeines
Der folgende Code bewirkt, dass über einem gekauften Fahrzeug (Truck oder PKW) sich ein Pfeil befindet. Dieser ist kein rigidBody und man kann nicht mit diesem kollidieren.
Script
Zu bearbeitende Dateien:
- fn_vehicleShopBuy.sqf
1. fn_vehicleShopBuy.sqf
Öffnet die fn_vehicleShopBuy.sqf in Altis_Life.Altis\core\shops. Fügt den folgenden Code ans Ende ein, sodass der letzte Call ersetzt wird und davor die Variablen stehen.
Code
_box = boundingBox _vehicle;
_offset = _box select 1; //Gets an array with the maximum bounding values
_offset = _offset select 2; //Gets the Maxmimum Z height
_offset = _offset + 0.8; //Just a few inches more...
_sp = visiblePosition _vehicle;
_sp = _sp vectorAdd [0,0,_offset];
_vh = createVehicle ["Sign_Arrow_Large_F", _sp ,[],0,"NONE"];
_vh setPos _sp;
[0] call SOCK_fnc_updatePartial;
closeDialog 0; //Exit the menu.
true;
sleep 10;
deleteVehicle _vh;
Alles anzeigen
Zum Vergleich ist hier die fn_vehicleShopBuy.sqf von mir:
Spoiler anzeigen
Code: fn_vehicleShopBuy.sqf - TerraGaming
/*
File: fn_vehicleShopBuy.sqf
Author: Bryan "Tonic" Boardwine
Description:
Does something with vehicle purchasing.
*/
private["_mode","_spawnPoints","_className","_basePrice","_colorIndex","_spawnPoint","_vehicle"];
_mode = _this select 0;
if((lbCurSel 2302) == -1) exitWith {hint localize "STR_Shop_Veh_DidntPick"};
_className = lbData[2302,(lbCurSel 2302)];
_vIndex = lbValue[2302,(lbCurSel 2302)];
_vehicleList = [life_veh_shop select 0] call life_fnc_vehicleListCfg; _basePrice = (_vehicleList select _vIndex) select 1;
if(_mode) then {_basePrice = round(_basePrice * 1.5)};
_colorIndex = lbValue[2304,(lbCurSel 2304)];
//Series of checks (YAY!)
if(_basePrice < 0) exitWith {}; //Bad price entry
if(life_cash < _basePrice) exitWith {hint format[localize "STR_Shop_Veh_NotEnough",[_basePrice - life_cash] call life_fnc_numberText];};
if(!([_className] call life_fnc_vehShopLicenses) && _className != "B_MRAP_01_hmg_F") exitWith {hint localize "STR_Shop_Veh_NoLicense"};
_spawnPoints = life_veh_shop select 1;
_spawnPoint = "";
if((life_veh_shop select 0) == "med_air_hs") then {
if(count(nearestObjects[(getMarkerPos _spawnPoints),["Air"],35]) == 0) exitWith {_spawnPoint = _spawnPoints};
} else {
//Check if there is multiple spawn points and find a suitable spawnpoint.
if(typeName _spawnPoints == typeName []) then {
//Find an available spawn point.
{if(count(nearestObjects[(getMarkerPos _x),["Car","Ship","Air"],5]) == 0) exitWith {_spawnPoint = _x};} foreach _spawnPoints;
} else {
if(count(nearestObjects[(getMarkerPos _spawnPoints),["Car","Ship","Air"],5]) == 0) exitWith {_spawnPoint = _spawnPoints};
};
};
if(_spawnPoint == "") exitWith {hint localize "STR_Shop_Veh_Block";};
life_cash = life_cash - _basePrice;
hint format[localize "STR_Shop_Veh_Bought",getText(configFile >> "CfgVehicles" >> _className >> "displayName"),[_basePrice] call life_fnc_numberText];
//Spawn the vehicle and prep it.
if((life_veh_shop select 0) == "med_air_hs") then {
_vehicle = createVehicle [_className,[0,0,999],[], 0, "NONE"];
waitUntil {!isNil "_vehicle"}; //Wait?
_vehicle allowDamage false;
_hs = nearestObjects[getMarkerPos _spawnPoint,["Land_Hospital_side2_F"],50] select 0;
_vehicle setPosATL (_hs modelToWorld [-0.4,-4,12.65]);
_vehicle lock 2;
[[_vehicle,_colorIndex],"life_fnc_colorVehicle",true,false] spawn life_fnc_MP;
[_vehicle] call life_fnc_clearVehicleAmmo;
[[_vehicle,"trunk_in_use",false,true],"TON_fnc_setObjVar",false,false] spawn life_fnc_MP;
[[_vehicle,"vehicle_info_owners",[[getPlayerUID player,profileName]],true],"TON_fnc_setObjVar",false,false] spawn life_fnc_MP;
_vehicle disableTIEquipment true; //No Thermals.. They're cheap but addictive.
} else {
_vehicle = createVehicle [_className, (getMarkerPos _spawnPoint), [], 0, "NONE"];
waitUntil {!isNil "_vehicle"}; //Wait?
_vehicle allowDamage false; //Temp disable damage handling..
_vehicle lock 2;
_vehicle setVectorUp (surfaceNormal (getMarkerPos _spawnPoint));
_vehicle setDir (markerDir _spawnPoint);
_vehicle setPos (getMarkerPos _spawnPoint);
[[_vehicle,_colorIndex],"life_fnc_colorVehicle",true,false] spawn life_fnc_MP;
[_vehicle] call life_fnc_clearVehicleAmmo;
[[_vehicle,"trunk_in_use",false,true],"TON_fnc_setObjVar",false,false] spawn life_fnc_MP;
[[_vehicle,"vehicle_info_owners",[[getPlayerUID player,profileName]],true],"TON_fnc_setObjVar",false,false] spawn life_fnc_MP;
_vehicle disableTIEquipment true; //No Thermals.. They're cheap but addictive.
};
//Side Specific actions.
switch(playerSide) do {
case west: {
[_vehicle,"cop_offroad",true] spawn life_fnc_vehicleAnimate;
};
case civilian: {
if((life_veh_shop select 2) == "civ" && {_className == "B_Heli_Light_01_F"}) then {
[_vehicle,"civ_littlebird",true] spawn life_fnc_vehicleAnimate;
};
};
case independent: {
[_vehicle,"med_offroad",true] spawn life_fnc_vehicleAnimate;
};
};
_vehicle allowDamage true;
//life_vehicles set[count life_vehicles,_vehicle]; //Add err to the chain.
life_vehicles pushBack _vehicle;
[[getPlayerUID player,playerSide,_vehicle,1],"TON_fnc_keyManagement",false,false] spawn life_fnc_MP;
if(_mode) then {
if(!(_className in ["B_G_Offroad_01_armed_F","B_MRAP_01_hmg_F"])) then {
[[(getPlayerUID player),playerSide,_vehicle,_colorIndex],"TON_fnc_vehicleCreate",false,false] spawn life_fnc_MP;
};
};
_box = boundingBox _vehicle;
_offset = _box select 1; //Gets an array with the maximum bounding values
_offset = _offset select 2; //Gets the Maxmimum Z height
_offset = _offset + 0.8; //Just a few inches more...
_sp = visiblePosition _vehicle;
_sp = _sp vectorAdd [0,0,_offset];
_vh = createVehicle ["Sign_Arrow_Large_F", _sp ,[],0,"NONE"];
_vh setPos _sp;
[0] call SOCK_fnc_updatePartial;
closeDialog 0; //Exit the menu.
true;
sleep 10;
deleteVehicle _vh;
Alles anzeigen
1.2. Damit das Script funktioniert, müsst ihr bei private die Variablen angeben.
Fügt in Zeile 8 folgendes ein bzw. ersetzt es: