Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×

Smart Games

Member
  • Content Count

    191
  • Joined

  • Last visited

  • Medals

Everything posted by Smart Games

  1. You want something like this: ??? description.ext (to load the file into a function) class CfgFunctions { class JF { class Scripts { class RandomPos {file = "RandomPos.sqf"}; }; }; }; RandomPos.sqf params ["_positions", "_units"]; if ((count _positions) == 0 || (count _units) == 0) exitWith {hint "ERROR"}; private _pos = selectRandom _positions; private _unit = selectRandom _units; _positions deleteAt (_positions find _pos); _units deleteAt (_units find _unit); private _hostage = (createGroup civilian) createUnit [_unit, _pos, [], 0, "FORM"]; [_positions, _units, _hostage] the file you call the function from private _positions = [[3105.73,6287.15,0], [3069.41,6329.24,0], [3123.77,6294.1,0]]; private _units = ["C_Man_casual_4_v2_F", "C_man_polo_5_F"]; private _handle = [_positions, _units] call JF_fnc_RandomPos; //returns array: [_positions, _units, _hostage] //now you could work with _hostage and assign a task
  2. Smart Games

    TitleText dissapears too fast

    Very important advice!
  3. Smart Games

    TitleText dissapears too fast

    @sizraide, I'll take a look on it in a few hours. Please send me the mission folder.
  4. Smart Games

    TitleText dissapears too fast

    @sarogahtyp, I totally agree with you. I'd like to add, that I had a lot of problems with TitleText as well. For example I had to call it in a separate function to make it work. God knows, why. I still do not understand the problem. @sizraide, your code seems to be correct. It's most likely something else. I'd recommend you to try my approach: Put the code in a separate function and spawn it.
  5. I had my problems with the respawn vehicle module as well. The easiest solution would be to add this line into the Expression box of your Vehicle Respawn Module: clearMagazineCargoGlobal (_this select 0); clearWeaponCargoGlobal (_this select 0); clearItemCargoGlobal (_this select 0); clearBackpackCargoGlobal (_this select 0); Do not forget to sync the vehicle with the module.
  6. Good morning! Here is my suggestion: description.ext: (to load the function) class CfgFunctions { class JF { class Wasteland { class createRandomSoldierC {file = "createRandomSoldierC.sqf"}; }; }; }; initServer.sqf: (i am not sure in what context you are calling the function, but i highly recommend you to call the function within initServer.sqf or one of it's functions) [createGroup east, [4831,5112,0]] spawn JF_fnc_createRandomSoldierC; //creates one random unit createRandomSoldierC.sqf: params ["_group", "_position"]; private _soldierTypes = ["LIB_US_rifleman", "LIB_US_FC_rifleman", "LIB_US_smgunner", "LIB_SOV_rifleman", "LIB_SOV_LC_rifleman","LIB_SOV_scout_smgunner", "LIB_GER_rifleman", "LIB_GER_ober_rifleman", "LIB_GER_mgunner"]; private _weaponTypes = ["LIB_P38","LIB_MP40","LIB_K98","LIB_G43","LIB_TT33","LIB_M9130","LIB_M1895","LIB_PPSh41_m","lib_f1","LIB_M1A1_Thompson","LIB_M1_Carbine","LIB_M1_Garand","LIB_Colt_M1911","LIB_US_Mk_2"]; private _soldier = _group createUnit [selectRandom _soldierTypes, _position, [], 0, "NONE"]; private _oldMagazinesP = [primaryWeapon _soldier] call BIS_fnc_compatibleMagazines; private _oldMagazinesS = [secondaryWeapon _soldier] call BIS_fnc_compatibleMagazines; removeAllWeapons _soldier; { for [{_i = 0}, {_i < count _x}, {_i = _i+1}] do { _soldier removeMagazines (_x select _i); }; } forEach [_oldMagazinesP, _oldMagazinesS]; _soldier addWeapon (selectRandom _weaponTypes); private _magazine = ([(weapons _soldier) select 0] call BIS_fnc_compatibleMagazines) select 0; _soldier addMagazines [_magazine, 3]; //adds 3 mags to the unit _soldier call setMissionSkill; //not sure if that's right _soldier addEventHandler ["Killed", server_playerDied]; //same here _soldier //do you really need to return the unit? I'd work with it in this file or at least create all units here and return the group I'd also define _soldierTypes and _weaponTypes somewhere else to make it easier to edit later on. (I got an error at some time. Double check your weapon classnames, one might be wrong. Maybe it was me and it's allready fixed. Don't know ^^)
  7. Smart Games

    Help with Custom Loadout

    @beno_83au, that's where I like to use Config files for. Makes it much easier to read. I simply load them into the game at the start of the mission to get the same format as you.
  8. If anyone is interested, here is the main part of the solution: [] call JF_fnc_Options; player addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; private _cTarget = cursorTarget; private _types = missionNamespace getVariable "types"; if ((typeOf _cTarget) in _types) then { deleteVehicle _projectile; private _hit_already = _cTarget getVariable "saro_hit_num"; private _phase = _cTarget animationSourcePhase "terc"; if ( _hit_already < (HIT_NUM - 1)) then { _cTarget setVariable ["saro_hit_num", (_hit_already + 1), true]; } else { _cTarget animateSource ["terc", 1.5]; _cTarget setVariable ["saro_hit_num", 0, true]; }; hint parseText format ["<t color='#FFFFFF'>The Target <t color='#23D9C1'> %1 <t color='#FFFFFF'> has been hit <t color='#23D9C1'> %2 <t color='#FFFFFF'> times. </t>", _cTarget, _hit_already+1]; }; } ]; And here's the mission folder: https://ufile.io/4dt0g2ke
  9. Smart Games

    Air Breathing Script?

    updated.
  10. Smart Games

    Air Breathing Script?

    Cool idea! player setVariable ["air", 1000]; //players air tank volume private _clothes = ["H_Hat_Tinfoil_F", "U_I_CombatUniform"]; //clothes that ensure that player takes no damage (in this example only headgear and uniform) while {alive player} do { private _uniform = uniform player; private _headgear = headgear player; private _air = player getVariable "air"; private _hasAir = true; player setVariable ["air", _air - 1]; if (_air <= 100) then { hint parseText format ["<t color='#FFFFFF'>Warning: Check your air tank! Volume left:<t color='#23D9C1'> %1<t color='#FFFFFF'>/1000!</t>", _air]; //Option1 }; if (_air <= 0) then { _air = 0; hint parseText format ["<t color='#FFFFFF'>Critical Warning: Check your air tank! Volume left:<t color='#23D9C1'> %1<t color='#FFFFFF'>/1000!</t>", _air]; //Option1 _hasAir = false; }; { if !(_x in _clothes) then { _hasAir = false; }; } forEach [_uniform, _headgear]; if (_hasAir == false) then { player setDamage (getDammage player + 0.01); hint parseText format ["<t color='#FFFFFF'>Hi, <t color='#23D9C1'>%1 <t color='#FFFFFF'>, you took some damage. Better check your <t color='#23D9C1'> clothing <t color='#FFFFFF'>! Your current health: <t color='#23D9C1'> %2 <t color='#FFFFFF'> percent!</t>", name player, (1 - getDammage player) * 100]; //Option2 }; sleep 1; }; To refill the air tank add this to the init of an object: this addAction ["Refill Air Tank", {player setVariable ["air", 1000]; hint "Air Tank refilled!"}]; You can take it further and check for more equipment like the vest or the backpack. Right now it's very very basic + if you run out of air and you get any damage, the hint system is broken. Chose Option 1 or Option 2. But as I said, it's more of an example and very basic.
  11. I helped him and I think we already fixed the problem. At least it looks like he has no more questions.
  12. Smart Games

    Help with Custom Loadout

    Use the Config Viewer, this path does not exist.
  13. Smart Games

    Help with Custom Loadout

    I primarily changed the structure of the code, but it is definitely working: private _group = ["CUP_O_RU_Soldier_TL_M_EMR","CUP_O_RU_Soldier_M_EMR","CUP_O_RU_Soldier_M_EMR","CUP_O_RU_Crew_M_EMR","CUP_O_RU_Medic_M_EMR","CUP_O_RU_Soldier_AR_M_EMR","CUP_O_RU_Soldier_Marksman_M_EMR"]; private _weaponsPrimary = ["arifle_MX_F","arifle_Katiba_F","srifle_DMR_01_F","SMG_01_F","arifle_MX_khk_F","arifle_AK12_F","arifle_AKM_F","srifle_DMR_07_blk_F","LMG_Mk200_F","LMG_Zafir_F"]; private _weaponsSecondary = ["hgun_Rook40_F","hgun_ACPC2_snds_F","hgun_PDW2000_F","hgun_P07_khk_F"]; private _optics = ["","","optic_Yorris","optic_MRD","CUP_optic_Kobra","optic_Aco","optic_ACO_grn","optic_Aco_smg","optic_ACO_grn_smg","CUP_optic_SB_11_4x20_PM","optic_Holosight","optic_Holosight_smg","optic_Arco","optic_Hamr","optic_Arco_AK_blk_F","optic_Arco_blk_F","optic_ERCO_blk_F","optic_MRCO","CUP_optic_PechenegScope","CUP_optic_PSO_1","CUP_optic_PSO_1_AK","optic_DMS","optic_SOS","CUP_optic_LeupoldMk4"]; private _flashLights = ["","","acc_flashlight","acc_flashlight_smg_01","acc_flashlight_pistol","CUP_acc_ANPEQ_15_Black","acc_pointer_IR","muzzle_snds_L","CUP_muzzle_snds_MicroUzi","muzzle_snds_M","CUP_muzzle_snds_KZRZP_AK545","muzzle_snds_H","CUP_muzzle_snds_KZRZP_AK762","muzzle_snds_B","CUP_muzzle_snds_KZRZP_SVD","CUP_muzzle_snds_SCAR_H","muzzle_snds_338_black","CUP_muzzle_snds_AWM","bipod_01_F_blk","bipod_02_F_blk","bipod_03_F_blk","bipod_02_F_lush","CUP_optic_ekp_8_02"]; private _unitforms = ["U_O_R_Gorka_01_camo_F","U_O_R_Gorka_01_black_F","U_O_R_Gorka_01_brown_F","U_O_R_Gorka_01_camo_F"]; private _vests = ["","V_Rangemaster_belt","V_BandollierB_blk","V_HarnessOSpec_gry","V_TacVest_blk_POLICE","V_Press_F","V_PlateCarrierIA1_dgtl","V_PlateCarrier1_rgr","V_PlateCarrier2_blk","V_SmershVest_01_F","V_Chestrig_khk","V_TacVest_oli","V_TacChestrig_oli_F","V_HarnessOGL_ghex_F"]; private _backpacks = ["","","B_AssaultPack_blk","B_Bergen_blk","B_Carryall_oucamo","B_FieldPack_oucamo","B_Kitbag_rgr_Exp","B_AssaultPack_mcamo_AA"]; private _behaviour = ["STEALTH","SAFE"]; private _group1 = [[4862,7985.24,0], EAST, _group] call BIS_fnc_spawnGroup; //i just used two custom positions, no markers [_group1, [4949.73,7922.12,0]] call BIS_fnc_taskDefend; _group1 setBehaviour (selectRandom _behaviour); _group1 allowFleeing 0; { _weaponPrimary = selectRandom _weaponsPrimary; _weaponSecondary = selectRandom _weaponsSecondary; _magazinePrimary = selectRandom ([_weaponPrimary] call BIS_fnc_compatibleMagazines); _magazineSecondary = selectRandom ([_weaponSecondary] call BIS_fnc_compatibleMagazines); removeAllWeapons _x; removeAllItems _x; removeAllAssignedItems _x; removeUniform _x; removeVest _x; removeBackpack _x; removeHeadgear _x; removeGoggles _x; _x setSkill ["spotDistance",0.8]; _x setSkill ["aimingShake",0.6]; _x setSkill ["spotTime",0.65]; _x removeItem "NVGoggles"; _x unassignItem "NVGoggles"; _x addWeapon _weaponPrimary; _x addPrimaryWeaponItem (selectRandom _optics); _x addPrimaryWeaponItem (selectRandom _flashLights); _x addWeapon _weaponSecondary; _x forceAddUniform (selectRandom _unitforms); _x addVest (selectRandom _vests); _x addBackpack (selectRandom _backpacks); _x linkItem "ItemMap"; _x linkItem "ItemCompass"; _x linkItem "ItemWatch"; _x linkItem "ItemRadio"; for "_i" from 1 to 4 do {_x addItemToUniform _magazinePrimary}; for "_i" from 1 to 4 do {_x addItemToVest _magazineSecondary}; for "_i" from 1 to 4 do {_x addItemToBackpack _magazinePrimary}; for "_i" from 1 to 4 do {_x addItemToBackpack _magazineSecondary}; } forEach (units _group1);
  14. Smart Games

    Help with Custom Loadout

    i am working on it, jsut give me some time ^^
  15. Smart Games

    Help with Custom Loadout

    Add this section to the forEach loop. What you did is to select a random weapon and apply it to every unit of the group instead of selecting a random weapon for every unit of the group. Should fix the first part of the problem. Let me take a look one the script to fix the other problem as well.
  16. Hi there, I noticed some very strange problems when I tested my mission with two instances of ArmA running. Nr 1 was Player and Server Nr 2 was Player As expected everything worked fine on Nr 1, but when I played around with Nr 2 some scripts wouldn't really work. I have two guesses: 1) Nr 2 can't access all the mission config data (sounds weird, ik: dialogs are loading but it won't create a HUD with cutRsc -> all working fine on Nr1) 2) Nr 2 can't access the missionNamespace (for example there's a script that needs an array of locations create by initServer.sqf and stored in the mission namespace. When calling it it just returns ANY) These problems are driving me crazy. Do you have any ideas or is it definitely a problem made by me?
  17. Smart Games

    MP scripting issues

    @pierremgi, I had to write the cutRsc command in a separate function to make it work. For sure it's not efficient, but it's working.
  18. Smart Games

    MP scripting issues

    @pierremgi, it checks wheter the unit is a squad leader. That's important for some other scripts as well. I used a Config to make it easier to work with in the future, as I plan to use it as a template. I already fixed the problem. I had to use remoteExec but now it's working fine.
  19. Smart Games

    MP scripting issues

    Maybe the second problem is something similar: description.ext (just the important information😞 class RscTitles { #include "Core\Headers\Gui\Cooldown.hpp" }; Cooldown.hpp: #define JF_TELE_X (safeZoneXAbs) #define JF_TELE_Y (safeZoneY + safeZoneH *.97) #define JF_TELE_W (safeZoneWAbs) #define JF_TELE_H (safeZoneH *.03) class JF_Cooldown { idd = -1; duration = 99999999999; onLoad = "uiNamespace setVariable ['JF_Cooldown', _this select 0]"; class controls { class JF_Txt: RscText { idc = 70001; x = JF_TELE_X; y = JF_TELE_Y; w = JF_TELE_W; h = JF_TELE_H; SizeEx = GUI_TEXT_SIZE_SMALL; style = ST_CENTER; colorBackground[] = {0,0,0,0}; }; }; }; JF_fnc_LeaderTest (= called in OnPlayerRespawn.sqf): params []; player setVariable ["isLeader", "false"]; private _config = getMissionConfig "JF_SquadLeader"; for [{_i = 0}, {_i < count _config}, {_i = _i+1}] do { if ((getText ((_config select _i) >> "name")) == (getDescription player) select 0) then { player setVariable ["isLeader", "true"]; ("TAG_myLayer" call BIS_fnc_rscLayer) cutRsc ["JF_Cooldown", "PLAIN"]; }; }; Problem: As i have mentioned before, JF_fnc_LeaderTest is called on every client in OnPlayerRespawn.sqf. The HUD (it shows the cooldown of some special abilitys of the squad leader) should only be displayed if the unit is a "leader". Same game as before: The HUD won't show on Nr 2. Is there any need to remoteExec a function and create the HUD within?
  20. Smart Games

    MP scripting issues

    Solved the problem, thanks! Es sind auch wirklich immer solche Kleinigkeiten, die einem so unglaublich viel Aufwand bescheren. Ich könnte heulen ^^
  21. Smart Games

    MP scripting issues

    Well let's go... that's going to be a lot! initServer.sqf (just the important stuff -> SL_CENTER is defined in JF_fnc_Options) [] call JF_fnc_Options; [SL_CENTER] call JF_fnc_SortLocations; the script executed by an addaction to call the dialog: createDialog "JF_Teleport"; private _isLeader = player getVariable "isLeader"; if (_isLeader == "true") then { [getPos player] call JF_fnc_SortLocations; } else { private _locations = [getPos player] call JF_fnc_SortLocationsLocal; [_locations] call JF_fnc_Location_ListBox_Fill; }; JF_fnc_SortLocations: params ["_center"]; private _locations = getMissionConfig "JF_Locations"; private _allLocations = []; for [{_p = 0}, {_p < count _locations}, {_p = _p+1}] do { private _loc = _locations select _p; private _name = getText (_loc >> "name"); private _air = getText (_loc >> "air"); private _land = getText (_loc >> "land"); private _coordinates = getText (_loc >> "coordinates"); private _style = getText (_loc >> "style"); private _pos = parseSimpleArray _coordinates; private _distance = _center distance2D _pos; _allLocations pushBack [_name, _air, _land, _coordinates, _style, _distance]; }; private _sortedLocations = [_allLocations, [], {_x select 5}, "ASCEND"] call BIS_fnc_sortBy; missionNamespace setVariable ["sorted_locations", _sortedLocations]; JF_fnc_SortLocationsLocal: params ["_center"]; private _locations = getMissionConfig "JF_Locations"; private _allLocations = []; for [{_p = 0}, {_p < count _locations}, {_p = _p+1}] do { private _loc = _locations select _p; private _name = getText (_loc >> "name"); private _air = getText (_loc >> "air"); private _land = getText (_loc >> "land"); private _coordinates = getText (_loc >> "coordinates"); private _style = getText (_loc >> "style"); private _pos = parseSimpleArray _coordinates; private _distance = _center distance2D _pos; _allLocations pushBack [_name, _air, _land, _coordinates, _style, _distance]; }; private _sortedLocations = [_allLocations, [], {_x select 5}, "ASCEND"] call BIS_fnc_sortBy; _sortedLocations; Location_ListBox_Fill: (function to fill a listbox) disableSerialization; params ["_locations"]; private _parent = uiNamespace getVariable "JF_Teleport"; private _ctrl = _parent displayctrl 50001; lbClear _ctrl; for [{_i = 0}, {_i < count _locations}, {_i = _i+1}] do { private _loc = _locations select _i; _ctrl lbAdd format ["%1", _loc select 0]; }; _ctrl lbSetCurSel 0; Location_ListBox_GetInfo: (displays some information in the dialog (just the important part) disableSerialization; params ["_lb", "_index"]; private _parent = uiNamespace getVariable "JF_Teleport"; private _ctrl = _parent displayctrl 50002; private _bt_land = _parent displayctrl 50003; private _bt_air = _parent displayctrl 50004; private _map = _parent displayctrl 50005; _locations = missionNamespace getVariable "sorted_locations"; private _loc = _locations select _index; private _air = _loc select 1; private _land = _loc select 2; private _coordinates = _loc select 3; _ctrl ctrlSetText format ["air = %1 | land = %2 | coordinates = %3", _air, _land, _coordinates]; Now to the problem: -When Nr 2 spawns as a "non leader" character, the ListBox is filled (because JF_fnc_SortLocationsLocal is called), but the dialog doesn't show the extra information (because the "sorted_locations" are stored in the missionNamespace [they really are, i checked it with Nr 1s debug console] and Nr 2 propably can't access them) -When Nr 2 spawns as a "leader" character , the ListBox is filled just after the second time he opens the dialog (the first time the "sorted_locations" are stored in the missionNamespace -> he can't access it?!, than he calls JF_fnc_SortLocations and stores them himself), after the second time everything is working. That makes me think, that the missionNamespace (used by the server) can't be accessed (or is unknown) by the client.
  22. _flag addAction [ "Create Respawn Position", { params ["_target", "_caller", "_actionId", "_arguments"]; private _name = [getPos _target] call JF_fnc_NearestLocationName; private _pos = [getPos _target, 1, 50, 3, 0, 20, 0] call BIS_fnc_findSafePos; [west, _pos , _name] spawn BIS_fnc_addRespawnPosition; [_target, _actionId] remoteExecCall ["JF_fnc_RemoveAction", allPlayers]; private _blackListLocations = missionNamespace getVariable "blacklist_locations"; _blackListLocations pushBack _name; missionNamespace setVariable ["blacklist_locations", _blackListLocations]; }, nil, 1.5, true, true, "", "true", 5, false, "", "" ]; ERRORS: setmarkertypelocal _type //... Error: undefined variable in expressions _type //in fn_drawRespawnPositions.sqf line 33 _map drawicon [ //... Error: type any, expected string //in fn_showRespawnMenuPositionMapDraw.sqf line 39 I really don't know what's going on here. It creates the respawn position (i can select it and spawn there), but it shows these error messages as well. The little map marker on the spawn position won`t draw. Actually, I should not have any influence on these functions and produce errors. Do you know the reason for this?
  23. I found the problem and once more it was me, who didn't read well enough. BIS_fnc_findSafePos is supposed to return an array of type [x,y]. Most of the other BIS functions (including my own functions) need an array of type [x,y,z] to work properly. I just rewrote the function to return an array of the right type and everything is working like a charm.
  24. Lets say I spawn 200 groups with 600 units. I want the units out of range of the player to be hidden so that I get more performance. In my opinion, this is much easier to implement with hideObject than if I delete each unit, save all the data and then create it again later. Only it would be important for me to know how big the performance difference between hideObject and deleteVehicle in such a large scale scenario is.
×