Jump to content

cybercoco

Member
  • Content Count

    176
  • Joined

  • Last visited

  • Medals

Posts posted by cybercoco


  1. I'm sure there's a way to minimize the number of lines in this code.

    I have three variables, each of them needs to get through a simple math function : f(x)=10x.

    _var1 = 0.2;
    _var2 = 0.7;
    _var3 = 0.5;
    _array = [_var1,_var2,_var3];
    
    _var1 = _var1 * 10;
    _var2 = _var2 * 10;
    _var3 = _var3 * 10;

    If I have let say ten vars, is it better to use the brute way (see snip above), use a foreach command or use a function (optimization wise).

    Probably the function, isn't it ?


  2. Indeed, I didn't mention it, but even with the "addons" folder :

     

    Structure :

     

    @NRD_Items

         - mod.cpp

         - addons

              - NRD_Items.pbo

                   - config.cpp

                   - item_olives.paa

     

    config.cpp

    class CfgMagazines
    {
        class CA_Magazine;
        class nrd_item_olives: CA_Magazine
        {
            author = "Coco";
            displayName = "nrd_item_olives";
            model = "\A3\weapons_F\ammo\mag_univ.p3d";
            count = 1;
            scope = 2;
            mass = 2;
            picture = "\NRD_Items\item_olives.paa";
            descriptionShort = "des";
        };
    };
    

    Ingame

    this additem "nrd_item_olives";

  3. I figured it out after a little while...

     

    test\export.sqf

    _var1 = "1";
    _var2 = "2";
    hint format ["Testing vars : %1 and %2",_var1, _var2];
    [_var1,_var2] execVM "test\import.sqf";
    hint "vars exported";
    
    // -------TESTING IF SCRIPT WORKS AFTER EXECUTING THE OTHER-------
    player sidechat "hello1";
    sleep 2;
    player sidechat "hello2";
    sleep 2;
    player sidechat "hello3";
    sleep 2;
    player sidechat "hello4";
    sleep 2;
    player sidechat "hello5";
    sleep 2;
    // -------OF COURSE IT DOES-------
    

    test\import.sqf

    sleep 2;
    hint "vars imported";
    sleep 2;
    _var1 = _this select 0;
    _var2 = _this select 1;
    hint format ["Testing vars : %1 and %2",_var1, _var2];
    

    However I don't understand why you added that (below) in the first script.

    [_args] execVM "mysqf.sqf"; // ?
    [_moreargs] call fnc_myfnc; // ?
    

    Thanks for the help harmdhast


  4. Thank you for your help,

    Well, I see what you want to do, but " _health " and "_ammo" do not exist inside the "_fnc_getFile" function, so this is syntactically not correct. Also, if you compare two variables, the comparison will only be regarding the value. So even i f your code would work, it would always go into one of the two first cases if "_health " and "_ammo" were the same value.

    I understand what you're saying. I think I'm going to go with combining the two similar files into one.

    I may have to send variables to this unique file, is that correct ?

     

    Thanks again !

    And Happy Christmas to you all !!!


  5. Thank you for the explanation. Is there a way to give two inputs (or more) and get multiple outputs.

    Does it work if I input a array instead of a variable in the function ?

     

    Another thing, am I allowed to do this ?

        _health = 0.7;
        _ammo = 0.4;
         
        _fnc_getFile = {
            switch true do {
                case (_this < 0.5 and _this == _health): {
                    "healthlow.sqf"
                };
    
                case (_this > 0.5 and _this == _health): {
                    "healthhigh.sqf"
                };
    
                case (_this < 0.5 and _this == _ammo): {
                    "ammolow.sqf"
                };
    
                case (_this > 0.5 and _this == _ammo): {
                     "ammohigh.sqf"
                };
            };
        };
        
        player addaction ["Health Status", _health call _fnc_getFile]
        player addaction ["Ammo Status", _ammo call _fnc_getFile]
    

  6. Thank you for the reply, however it didn't work.

    Here's the structure :

     

    @NRD_Items

         - mod.cpp

         - NRD_Items.pbo

              - config.cpp

              - item_olives.paa

     

    config.cpp

    class CfgMagazines
    {
        class CA_Magazine;
        class nrd_item_olives: CA_Magazine
        {
            author = "Coco";
            displayName = "nrd_item_olives";
            model = "\A3\weapons_F\ammo\mag_univ.p3d";
            count = 1;
            scope = 2;
            class ItemInfo
                {
                        mass = 2;
                };
            picture = "\NRD_Items\item_olives.paa";
            descriptionShort = "des";
        };
    };
    

    I can't see what's wrong with that code... And ingame when I do :

    this additem "nrd_item_olives";
    

    I don't get anything in my inventory.


  7. i'm wondering  if is possible have the csat uniform just with pants and T shirt.

    someone has tried?

    Check this page

     

    sample config :

    class CfgPatches
     {
     	class YourTAG_ReplacementSet_With_AddonName
     	{
     		units[] = {};
     		weapons[] = {};
     		requiredVersion = 0.1;
     		requiredAddons[] = {"DependencyToAddonsCfgPatchesClass"};
     	};
     };
     class CfgVehicles
     {
     	class SoldierWB;
     	class B_Soldier_base_F: SoldierWB
     	{
     		model = "\A3\characters_F\BLUFOR\b_soldier_01.p3d";
     		nakedUniform = "U_BasicBody";
     		uniformClass = "U_B_CombatUniform_mcam";
     		hiddenSelections[] = {"Camo"};
     		hiddenSelectionsTextures[] = {"\a3\characters_f\blufor\data\clothing1_co.paa"};
     		linkedItems[] = {"V_PlateCarrier1_rgr","H_HelmetB","ItemMap","ItemCompass"};
     		respawnLinkedItems[] = {"V_PlateCarrier1_rgr","H_HelmetB","ItemMap","NVGoggles"};
     		class Wounds
     		{
     			tex[] = {};
     			mat[] = {"A3\Characters_F\BLUFOR\Data\clothing1.rvmat",...};
     		};
     	};
    };
    

    Id of tee-shirt and pants need to be added on line "linkedItems [] = {........}"


  8.  

    Use structured text to colorize your code. The color can be determined using a simple switch statement.

    _health = 0.7;
    _ammo = 23;
    _ammoMax = 100;
    
    _fnc_getColor = {
        switch true do {
            case (_this < 0.25): {
                "#ff0000"    //red
            };
            
            case (_this < 0.5): {
                "#ff8800"    //orange
            };
            
            case (_this < 0.75): {
                "#ffff00"    //yellow
            };
            
            default {
                "#00ff00"    //green
            };
        };
    };
    
    hintSilent parseText format ["
        <t align='left'>Health:</t><t align='right' color='%2'>%1</t><br/>
        <t align='left'>Ammo:</t><t align='right' color='%4'>%3</t>
    ", _health, _health call _fnc_getColor, _ammo, (_ammo / _ammoMax) call _fnc_getColor];
    

    Nice, thank you Heeeere's johnny!, I didn't know we could use %1 inside the style of <t>.

    Also, If I understand this correctly _fnc_getColor is a function right ?

    And why have "_ammo / _ammoMax" ?

     

    C.Coco


  9. I am trying to create a hint which will display several variable, for exemple _health and _ammo.

    That's easily done, however what I would like to do is display the variable with a specific color, according to the importance...

     

    For exemple if player is at 50% health and as 100% ammo on him then hint _health orange and _ammo green.

    If the player is at 25% health and 50% ammo, then it will be _health in red and _ammo in orange.

     

    I don't want to make a "if, then" statement for each possible way. Is there a smarter solution ?

     

    Thanks in advance,

     

    C.Coco


  10. Hi all,

     

    I would like to create a new item, I looked at this post  and tried it, but failed...

     

    mod file is @test, in there I have mod.cpp and test.pbo. In test.pbo I have :

     

    config.cpp

    class CfgPatches
    {
        class test
        {
            units[]={};
            weapons[]={};
            requiredVersion=1;
        };
    };
    
    class CfgMagazines
    {
        class CA_Magazine;
        class the_antibiotic: CA_Magazine
        {
            displayName = "Antibiotic";
            scope=2;
            picture = "antibiotic.paa";
            model="\A3\structures_f_epa\Items\medical\antibiotic_F";
    	};
    };
    

    and antibiotic.paa

     

    In the main screen I can see that my mod has been loaded (the logo appears).

    After, in the editor, I place a unit with :

    this addMagazines ["the_antibiotic", 1];
    

    It doesn't work ...


  11. Thank you so much for the help, that's very encouraging.

    I think i'm done now, maybe not, there's always something to do...

    _won = nearestObjects [player, ["C_Offroad_01_F"], 50];
    _won = str _won select [1,5];
    _won = call compile _won; // stores it into a variable ? an object ??
    
    _won addaction ["working fine","niania.sqf"];
    
    _hpmotor = _won getHit "motor";
    
    hint format ["%1's health : %2",_won,_hpmotor];
    
    

    And it works !


  12. Hey, thank you for your response.

    I have tried :

    str_motorhealth = wonno getHit "motor";
    player sidechat format ["%1",str_motorhealth];
    sleep 4;
    _lite = wonno addAction ["%1",str_motorhealth,""];
    sleep 4;
    wonno removeaction _lite;
    
    

    You can see in the code, i've included "sidechat format" to debugg it and it does output it on sidechat.

    However it doesn't work as a addaction title...

     

    Hope there's a way !

×