Jump to content

Bon

Member
  • Content Count

    556
  • Joined

  • Last visited

  • Medals

Posts posted by Bon


  1. I once tried to create a mod for Armed Assault based on BF2 PR where you can request a kit with specific weapons and the classes appropriate appearance, means, changing the unit's type dynamically.

    It did not take long for realizing this is not possible in-game. You can create a new switchable unit and let the player switch into it. But:

    - All the players properties (like name, vehicle inits and so on) will stay with the old unit and all that happened during Init.sqf execution will be gone.

    - It does not work in MP anyway.

    So afaik the best advice is to forget about this idea.

    To the 2nd question I just quote an example found on the page to the setVehicleVarName command:

    //Assign a variable to an object and be able to refer to that
    
    //object using the variable, in both single and multi player.
    
    _Object="M1A1" CreateVehicle (GetPos Player);
    _VarName="MYTANK";
    _Object SetVehicleVarName _VarName;
    _Object Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarName]; 


  2. Hi,

    to lock a vehicle its simply

    <vehicle> lock true

    But I don't know if this only effects locally, so maybe it will be locked then for all players.

    I usually use a vehicle-driver-check script, the one I currently use consists of the code:

    While{getDammage _vehicle < 1} do
    {
    WaitUntil{not(isNull driver _vehicle)};
    if((_vehicle isKindOf "Air" && typeOf (driver _vehicle) != "USMC_Soldier_Pilot") || (typeOf _vehicle in ["MtvrReammo","MtvrRepair","MtvrRefuel"] && typeOf (driver _vehicle) != "USMC_SoldierS_Engineer")) then
    {
    	_vehicle engineOn false; (driver _vehicle) action ["Eject",_vehicle];
    };
    WaitUntil{isNull driver _vehicle};
    };
    
    
    if(true) exitWith{};

    As you can see here only pilots can enter air vehicles as pilots and only engineers can drive the cars of types "MtvrReammo", "MtvrRepair", "MtvrRefuel". Should not be a big deal to fit this piece of code to your purposes.

    Then you have to write

    [this] execVM "scriptabove.sqf"

    into the vehicles init line or (probably you want to create this artillery dynamically or enable respawn) use the "setVehicleInit" command.


  3. [/color]Nope :(

    - I got a trigger Blufor, present, act: {[_x] execVM "checkType.sqf"} foreach thislist

    - A10 flying into it

    and

    I get the first hint saying "A10" and thats it. I tried switching the "Plane" with "Air" and "A10" but nothing.

    Hi,

    ok, first I have to mention that

    case <var> : exitWith{}

    is wrong syntax, do not use the exitWith here.

    Second, I made a mistake by using the switch command anyway, sorry for that.

    With "typeOf object" I get the exact type of the object returned, in the switch statement above I am checking not for the exact type but for a supercategory of it in CfgVehicles.

    Just write instead:

    if(_target isKindOf "Plane") exitWith{hint "we got something in the air!"};
    if(_target isKindOf "Man") exitWith{hint "whatsoever"};
    ...
    

    That'll do the trick.

    And as Rommel said already, if you want only the first person to be checked via script, change the activation code of the trigger to

    [thislist select 0] execVM "checkType.sqf"


  4. hi Bunny75,

    - Is there a way to restrict a radio trigger for only one person?

    - no, not afaik.

    - How can I pass the name of the unit that has activated the radio trigger to a .sqf?

    - not possible afaik

    You have to assign an action (via addAction) to the particular player which calls a script containing the activation code of your radio trigger. This scripts effects then are local.

    - How can I detect if the unit that has entered a trigger is a man, helo, plane, tank or a car?

    Activation code of the trigger:

    {[_x] execVM "checkType.sqf"} foreach thislist

    checkType.sqf then should contain something like:

    _unit = _this select 0;
    
    switch (typeOf _unit) do {
      case "Tank" : {your code};
      case "Plane" : {your code};
      case "Helicopter" : {your code};
      case "Man" : {your code};
      case "Car" : {your code};
    };
    

    Think this would be the most elegant way.


  5. The first problem was less so due to your code and more so due to me not using ' or "" inside the string for the setvehicleinit command. .

    Hi Impravido (and everyone else),

    such errors can take hours and hours to be detected, time that can be safed by starting ArmA with the additional command

     -showScriptErrors

    in the shortcut.

    Use it, it makes life much easier.


  6. Thanks for the input Bon, but that does not appear to be working. The items stated in the setvehicelinit command do not appear at all.

    Ok I tried it out for myself and it worked.

    I added an action to the player like this:

    _action = player addAction ["fill","fill.sqf",[],-1,false,true,"","(count nearestObjects[position player,['USBasicWeaponsBox'],2])>0"];

    Simple effect, when the player is close to a weaponcrate this action appears in his action menu. You didn't say exactly how you called your script, but I assume you do it at least a similar way, perhaps you add the action to the crate itself. However, should be better you show us your script and how it is called.

    Listen, if you do it the way I did, you CANNOT give the crate as an argument since the parameter is picked at the moment of action assignment and not in the moment of script execution.

    Then I just created the fill.sqf file with the content as written above:

    _crate = nearestObjects[position player,["USBasicWeaponsBox"],2] select 0;
    
    _crate setVehicleInit "this addWeaponCargo ['G36a',500]"; processInitCommands;

    Works in the editor preview, in singleplayer and in multiplayer as host as well as on dedicated server.


  7. Hi.

    The command for a bot controlled vehicle to fire on targets is doFire. I recently wrote a script that makes me able to desigante a target with laser, then call a bomber (AI controlled) to drop a bomb on it. Works nice.

    So whats the difference to use a UAV instead of an AV8? The difference is that I have a concrete atarget to aim at, and your purpose is for the UAV to search its targets.

    So look also at the commands doTarget and nearTargets. which might be helpful.

    My first idea is something like:

    //UAV on patrol
    if there are targets nearby AND the targets are enemy sided, then{
      {
         UAV doTarget _x; UAV doFire _x;
      } foreach neartargets;
    };
    // and so on
    

    This could work. All the scripting commands to implement this you have.

    EDIT: To find out the launcher of the UAV, did u simply try to write

    hint format["%1", weapons this]

    into its init line? Should list you all weapons.


  8. Respawning does not mean removing all damage from player and send him back to the respawn marker. It means creating a completely new entitiy, which then of course won't have: the previous weapon configuration, the previous varname, the assigned actions, and probably not the previously assigned eventhandlers.

    In my missions I always do it the way you wrote above:

    I create a separate playerInit.sqf which is called by the Init.sqf. The playerInit.sqf roughly consists of the code

    While{true} do{
      WaitUntil{not alive player};
      // save layout
      WaitUntil{alive player};
      // give back weapons
      // give back actions
    };
    

    which always works a charm for me.

    So try a mix of both your attempts:

    while {true} do {
       waitUntil {!alive player};
       _p = player;
       _weapons = weapons _p;
       _magazines = magazines _p;
       waitUntil {alive player};
       _p = player;
       removeAllWeapons _p;
       {_p addMagazine _x;} forEach _magazines;
       {_p addWeapon _x;} forEach _weapons;
       _primw = primaryWeapon _p;
       if (_primw != "") then {
           _p selectWeapon _primw;
           // Fix for weapons with grenade launcher
           _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
           _p selectWeapon (_muzzles select 0);
       };
      _Action = player addAction ["Team Status", "Scripts\TeamStatusDialog\TeamStatusDialog.sqf", [["Page", "Team"], "AllowPlayerInvites", "HideOpposition"], 0, false, true,""];
      // any other actions.....
    };
    


  9. Can someone explain to me how I can insert line breaks into control text?

    So I have a line in a script looks like

    ctrlSetText [_idc, "Text which is just too long to fit in the dialog appropriately, best would be to insert a line break some words before...."]; 

    I tried the following:

    Changed the textbox type to CT_STRUCTURED_TEXT as it is written here in the biki. Then tried both

    _control ctrlSetStructuredText parseText "First line<br/>Second line"

    as well as I tried

    _control ctrlSetStructuredText composeText["First Line", linebreak, "Second line"];

    but did not succedd yet. Any help would be appreciated.

    In both cases the text is not shown. Its no syntax errors (all arguments and parameters are of the needed type), so it must be just the wrong way.


  10. Using an action via action menu, the assigned scripts are running only on my own machine. So the other machines won't get the then added action to capture the VIP.

    If you want the action to the VIP being available on all machines, write

    <vipUnit> setVehicleInit <addaction statement>;
    processInitCommands;
    

    to dynamically put the addaction command into the vip units init line (what then will be executed globally).


  11. If this is really the code you use in your script it cannot work. Apart from some syntax errors your sound file is located in a folder "Sound", as you said, in the example the soundfile is in a folder "music".

    Try this example:

    class CfgSounds
    {
      sounds[] = {};   
      class intro1
      {
         name = "intro";
         sound[] = {"\sound\intro1.ogg", 1, 1};
         titles[] = {};
     };
    };
    

    Explanation (as good as I can):

    Declare a section class CfgSound { ... class content ... } so that the engine knows there are your custom sounds defined.

    Then define for every sound its own subclass, here we only have one class, called intro1.

    The class intro1 now contains all the needed information:

    - the name (used to access the sound ingame via the "say" command)

    - the location (here: "\sound\intro1.ogg")

    - cannot tell you for what the "titles[]" statement is good for atm.


  12. I assume you want someone to be able to create a vehicle when entering a specific area.

    Fine. Here a suggestion:

    - name your trigger, give it the name "SpawnVehicleArea", for example.

    - create an Init.sqf file, write in it:

    WaitUntil{not isNull player};
    _air = player addAction ["Spawn: A10","Spawn_Vec.sqf",["A10"],5,false,true,"","player in list SpawnVehicleArea"];
    _air1 = player addAction ["Spawn: AV8-B","Spawn_Vec.sqf",["AV8B2"],5,false,true,"","player in list SpawnVehicleArea"];
    _air2 = player addAction ["Spawn: AV-8B (LGB)","Spawn_Vec.sqf",["AV8B"],5,false,true,"","player in list SpawnVehicleArea"];
    _air3 = player addAction ["Spawn: C-130J","Spawn_Vec.sqf",["C130J"],5,false,true,"","player in list SpawnVehicleArea"];
    _air4 = player addAction ["Spawn: F-35B","Spawn_Vec.sqf",["F35B"],5,false,true,"","player in list SpawnVehicleArea"];
    _air5 = player addAction ["Spawn: SU-25","Spawn_Vec.sqf",["Su39"],5,false,true,"","player in list SpawnVehicleArea"];
    _air6 = player addAction ["Spawn: SU-34","Spawn_Vec.sqf",["Su34"],5,false,true,"","player in list SpawnVehicleArea"];
    

    This is the addAction command with a bit more arguments. The important one is the last, a condition which must be true to have this action enabled. Thats something new with ArmA2, i.e. was not there in Armed Assault. You can kick your Spawn_Menu_Aircraft.sqs.

    Also by committing the vehicle type as an argument you need only one Spawn script (instead of having one for every vehicle type).

    Now to the spawning itself. Here the Spawn_Vec.sqf:

    _type = (_this select 3) select 0;
    _vec = _type createVehicle (getMarkerPos "Spawn_Aircraft");
    _vec setDir 150;
    AllVecsSpawned = AllVecsSpawned + [_vec];
    publicVariable "AllVecsSpawned";
    

    Somewhere you must define an empty array named "AllVecsSpawned". Perhaps with placing a gamelogic in the editor, write

    AllVecsSpawned=[]

    into its init line.

    Now every vehicle being created is stored in this array and broadcasted to all machines.

    You can now define your remove function which should contain something like

    {deleteVehicle _x} foreach AllVecsSpawned;
    AllVecsSpawned=[];
    publicVariable "AllVecsSpawned";
    

    EDIT: There was a typo in my code.

×