Jump to content

riouken

Member
  • Content Count

    570
  • Joined

  • Last visited

  • Medals

Posts posted by riouken


  1. why not just go with something like this ?

    _locs= ["infoloc1","infoloc2","infoloc3","infoloc4","infoloc5"] call BIS_fnc_selectRandom;
    
    _suitcase= "Land_Suitcase_F" createVehicle (getMarkerPos  _locs);
    
    

    Normaly I would say you are correct but I would adviase against using BIS_fnc_selectRandom right now(Unless they have fixed it and I missed that).

    https://dev-heaven.net/issues/69439

    Edit: Nevermind I just checked in the function viewer and they did stealth fix this for Arma 3.

    scriptName "Functions\arrays\fn_selectRandom.sqf";
    /************************************************************
       Random Select
       By Andrew Barron / Rewritten by Warka
    
    
    Parameters: array
    
    
    This returns a randomly selected element from the passed array.
    
    
    Example: [1,2,3] call BIS_fnc_selectRandom
    Returns: 1, 2, or 3
    ************************************************************/
    
    
    private ["_ret","_i"];
    
    
    if(count _this > 0) then
    {
       _i = floor random (count _this);           //random index
    
    
       _ret = _this select _i;           //get the element, return it
    };
    _ret
    
    
    

    Thanks Warka:)


  2. I'm creating a mission framework/template (called "NAMF") where I have a set of (public) variables "attached" to an object ("nsf_oJIP"). These variables will always be syncronized to all platforms (ie. clients and server).

    In this template, I've also created a function ("nsf_fJIPn") that will return a boolean result; the purpose is to check if a public variable (in the "NSF_oJIP" "namespace") is declared or not. I want this function to handle all sorts of inputs, but it is primarily expecting a nsf_oJIP attached variable. My current code is as follows;

    nsf_fJIPn = {
       if     ( ( !isNil "_this" ) and ( typeName _this == "STRING" ) )
       then { isNil { nsf_oJIPns getVariable _this; };}
       else  { true;};
     };
    

    I see 4 scenarios which I want the function to handle;

    The parameter...

    a) ...is already declared, but wrong format (not a string).

    b) ...supplied, but isn't declared at all (isNull true).

    c) ...is missing (no parameter input)

    d) ...the parameter is correct (string)

    I'm not having problems with a), c) and d), but b) is a major pain you-know-where.

    Do anyone know if it is possible to check for this scenario?

    I have a follow-up question to c);

    It seems to me that if you use "call" without any parameters, _this becomes -1; can anyone confirm this? If this is true, if ( !isNil "_this" ) could never be false, and one can not really determine if the call function was supplied with a parameter or not. I'd rather _this = nil (undeclared), hence it would be easy to determine if a parameter was supplied or not.

    Example;

    hint format["%1", call {_this;}];
    

    .. returns -1

    Regards,

    Kenneth aka. ZNorQ

    The solution is a lot easier than you think ,

    With getVariable you can set a default value to return if the the var is not defined. Then check for that default vaule for your case B.

    _varTest = nsf_oJIPns getVariable [_this,"myVarIsNul"];
    
    if (_varTest == "myVarIsNul") then {
      hint "You did not declare the variable!";
    };
    
    
    

    http://community.bistudio.com/wiki/getVariable

    defaultValue: Any Value - Value to return if variable doesn't existReturn Value:Any Value

    Returns defaultValue if the variable doesn't exist.

    Returns Anything if the object is undefined.


  3. :cool:

    hmm 5 years php 2 years c# and u re telling me that it do what its supposed to do ? ...wow ....thank you

    when user decide to limit both score and time.... what u will do ? ....if u will stick with that u will end up with another loop... and prove me that not... so... why two loops ?

    u re simply ignoring what the code says.. its hard then......

    Maybe english isn't your first language and that is the communication problem. Have fun...


  4. And once again you do not understand at all, your question is WRONG, the whole idea, the way your coding etc...

    It does not matter what you put in the if statement, as you can see from your test, the difference is imperceptible. What matters is that your completing the if statement. If you already have the var, or bool figured out, before the if statement (Like in your example A) then why do you need to complete the if Statement?

    theoretical because there is sleep command which slows that down..................

    in fact... im afraid that you re missing the point....

    there wasnt problem at all..

    i had question about performance of IF statement in loop

    question was...

    is faster

    if ( false ) [color=#ff0000]// No need to do this at all. Why do you need to evaluate something that is hard coded that you already know. Why not just take out this whole step , and then it really will be faster than the option below.[/color]
    
    

    or

    if ( 0 > 0 )
    

    i wasnt sure if engine will take true as true or it will try to figure out if true is true..

    ---------- Post added at 08:47 PM ---------- Previous post was at 08:35 PM ----------

    Let me explain it another way.

    if (scoreLimit > 0) then
    {
     limitScore = true;
    };
    
    
    if (timeLimit > 0) then
    {
     limitTime = true;
    };
    
    [color=#ff0000]// Everything above this line only runs once in this script. And you set limitScore & limitTime based on the if statements above. This only happens once.[/color]
    
    
    
    while { true }
    {
     if (limitScore) then [color=#ff0000]// Next you are checking the above variable and if its true then you do stuff. But this is in a loop, and it will keep running over and over. There is no reason to spend this proc power on this unless limitScore will be changing. And
                              // if its going to be changing then your test is moot because at some point your going to have to evaluate limitScore so you can just do it here if that is the case. [/color]
     {
       if (scoreLimit..........) then
       {
         do something....
       };
     };
    
    
     if (limitTime) then
     {
       if (timeLimit ..........) then
       {
         do something....
       };
     };
    
    
     sleep 1;
    };
    
    
    


  5. hi

    whats better ?

    method 1:

    while { true }
    {
     if (myVariable > 0) then
     {
       do something....
     };
    
     sleep 1;
    };
    

    method 2:

    processMyVar = false;
    
    if (myVariable > 0) then
    {
     processMyVar = true;
    };
    
    while { true }
    {
     if (processMyVar ) then
     {
       do something....
     };
    
     sleep 1;
    };
    

    sure.. method 2 creates more variables (so using more memory) but my question is... will it save processor time ?

    hups ? :j:

    ...im sorry but u know what.. ..we know what we re talking about.. do u ?

    Yes I do but i'm afraid you're missing the point.

    There is no need to check an if statement you know it to be true... that is where the real processing time come from. There is no need to put an if statement in a loop unless you need to check the statement each iteration.

    Method 2 could look something like this.

    if (myVariable > 0) then
    {
    
     while {true}
     {
        do something....
    
    
       sleep 1;
     };
    
    };
    
    
    

    processMyVar = false;
    
    
    if (myVariable > 0) then
    {
     processMyVar = true;
    };
    
    
    while { true }
    {
     if (processMyVar ) then [color=#ff0000]// There is no need for this statement, why spend the time checking this if you already know it to be true in your if statement above. The only time you need to check would be if this var would be changing.[/color]
     {
       do something....
     };
    
    
     sleep 1;
    };
    


  6. Lol. Your not getting it. The engine does the same exact same thing in both your examples. The engine just checks if the statement is true or not. The only way you could see an impact is if you checked one single condition on one and multipul conditions on the other.

    That doe sent even take into account your deviation in your results.

    Your test for all intents and purposes is the exact same.


  7. Your still not comparing anything In your last example.

    To compare two functions you need a few things.

    1. They need to do the same job.

    -- ie how long would it take to spawn 100 opfor vs spawning 10 tanks.

    2. They need to work at least slightly different.

    -- ie. If I was trying to spawn 100 ai would it be faster to spawn 10 groups of 10 air or a 100 groups of 1 ai.

    Each of these example accomplished the same thing the just did it in different ways. Then you can test to see which one is best.


  8. Those two examples in your first post don't even function the same way. No since trying to figure out if one is faster or anything.

    I don't think you quite understand how those would run.

    In your first example your while true block would begin to run in a loop and each cycle it would execute the if statement.

    Your second example the first if statement would execute one time. Then the while true loop would begin to run and it would execute the if statement inside the while loop each cycle.

    The two algorythims don't function the same so you can't compare them.

    Like another poster said when you start running functions hundreds or thousands of times a frame or your running hundreds of loops. You probably don't need to worry about it. But there is nothing wrong with learning about it.


  9. Use RscPicture:

    http://community.bistudio.com/wiki/DialogControls-Text#Static_Pictures

    to deal with layers, the way you define the elements differs how they are treated.

    For instance you can specifically define something as the background to your UI and it will always be the first layer:

    class RSLO_dlg {
       idd = -1;
       movingEnable = false;
       onLoad = "execVM 'RSLO\RSLO_ui_setup.sqf';uiNamespace setVariable ['RSLO_main_dlg', (_this select 0)];"
       objects[] = {};
       class controlsBackground {
    
    
    [color=#ff0000]        class background: RSLO_RscPicture[/color]
    [color=#ff0000]            {[/color]
    [color=#ff0000]                idc = 1200;[/color]
    [color=#ff0000]                text = "\ca\ui\data\ui_background_controls_ca.paa";[/color]
    [color=#ff0000]                x = 0.0138894;[/color]
    [color=#ff0000]                y = 0.194989;[/color]
    [color=#ff0000]                w = 0.810784;[/color]
    [color=#ff0000]                h = 0.629413;[/color]
    [color=#ff0000]                moving = false;[/color]
    [color=#ff0000]            };[/color]
       };
    
    
    
    
       class controls {
    
    
           class extbtn: RSLO_RscShortcutButton
               {
                   idc = 1700;
                   text = "Close";
                   x = 0.47304;
                   y = 0.721132;
                   w = 0.16536;
                   h = 0.110893;
                   action = "closeDialog 0";
               };
           class mainframe: RSLO_RscFrame
               {
                   idc = 1800;
                   text = "RSLO";
                   x = 0.0228757;
                   y = 0.254902;
                   w = 0.616339;
                   h = 0.480174;
               };
           class loadoutbox: RSLO_RscCombo
               {
                   idc = 2100;
                   x = 0.0988562;
                   y = 0.342048;
                   w = 0.181699;
                   h = 0.0324619;
                   tooltip = "Select a loadout from the list box.";
               };
           class terraindetbox: RSLO_RscCombo
               {
                   idc = 2101;
                   x = 0.0972222;
                   y = 0.488018;
                   w = 0.180882;
                   h = 0.0357298;
                   tooltip = "Select a Terrain Detail level from the list box.";
               };
           class looadouttxt: RSLO_RscText
               {
                   idc = 1000;
                   text = "Loadouts";
                   x = 0.126634;
                   y = 0.281046;
                   w = 0.168627;
                   h = 0.0400872;
               };
           class gearbtn: RSLO_RscShortcutButton
               {
                   idc = 1702;
                   text = "Gear Up";
                   x = 0.402778;
                   y = 0.303922;
                   w = 0.16536;
                   h = 0.110893;
                   action = "execVM 'RSLO\loadouts.sqf';";
               };
           class terrdetbtn: RSLO_RscShortcutButton
               {
                   idc = 1701;
                   text = "Set";
                   x = 0.403595;
                   y = 0.454248;
                   w = 0.16536;
                   h = 0.110893;
                   action = "execVM 'RSLO\settr.sqf';";
               };
           class terrndettxt: RSLO_RscText
               {
                   idc = 1001;
                   text = "Terrain Detail";
                   x = 0.104575;
                   y = 0.430284;
                   w = 0.168627;
                   h = 0.0400872;
               };
           class viewdisttxt: RSLO_RscText
               {
                   idc = 1002;
                   text = "View Distance";
                   x = 0.250817;
                   y = 0.559912;
                   w = 0.168627;
                   h = 0.0400872;
               };
           class RscSlider_1900: RSLO_RscSlider
               {
                   idc = 1900;
                   x = 0.138889;
                   y = 0.666667;
                   w = 0.379412;
                   h = 0.0488018;
                   onSliderPosChanged = "_this call RSLO_set_vd_fnc;";
                   tooltip = "Slide to set View Distance.";
               };
           class viewdistnumb: RSLO_RscText
               {
                   idc = 1100;
                   text = "1000";
                   x = 0.294935;
                   y = 0.610022;
                   w = 0.168627;
                   h = 0.0400872;
               };
       };
    };
    

    Also the order in which you define the controls will define their layers, so the first control you define will be your lowest layer or your first.

    class RscTitles
    {
       titles[]={};
       class dis_divecomp
           {
           idd = -1;
           fadeout=0;
           fadein=0;
           duration = 99999;
           name = "dis_divecomp";
           onLoad = "uiNamespace setVariable ['dis_divecomp', _this select 0]";
           controls[]=
               {
                   [color=#ff0000]background,[/color]
                   remaintime,
                   bottomtime,
                   tempture1,
                   depth,
                   gassname
               };
    
    
    [color=#ff0000]            class background: DIS_RscPicture
               {
                   idc = IDC_DIVECOMPUTER_BACKGROUND;
                   text = "\DIS\pics\divercomp.paa";
                   x = -28 * GUI_GRID_W + GUI_GRID_X;
                   y = 0.5 * GUI_GRID_H + GUI_GRID_Y;
                   w = 25.5 * GUI_GRID_W;
                   h = 19 * GUI_GRID_H;
                   shadow = 0;
               };[/color]
               class remaintime: DIS_RscText
               {
                   idc = IDC_DIVECOMPUTER_REMAINTIME;
                   text = "00:00";
                   x = -25.01 * GUI_GRID_W + GUI_GRID_X;
                   y = 6.73 * GUI_GRID_H + GUI_GRID_Y;
                   w = 8.0505 * GUI_GRID_W;
                   h = 3.41583 * GUI_GRID_H;
                   colorText[] = 
                   {
                       0,
                       0,
                       0,
                       1
                   };
                   SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 2)";
                   shadow = 0;                
               };
               class bottomtime: DIS_RscText
               {
                   idc = IDC_DIVECOMPUTER_BOTTOMTIME;
                   text = "00:00";
                   x = -25 * GUI_GRID_W + GUI_GRID_X;
                   y = 11.5 * GUI_GRID_H + GUI_GRID_Y;
                   w = 8 * GUI_GRID_W;
                   h = 3 * GUI_GRID_H;
                   colorText[] = 
                   {
                       0,
                       0,
                       0,
                       1
                   };
                   SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 2)";
                   shadow = 0;
    
    
               };                
    
    
               class tempture1: DIS_RscText
               {
                   idc = IDC_DIVECOMPUTER_TEMP;
                   text = "68";
                   x = -10.5 * GUI_GRID_W + GUI_GRID_X;
                   y = 7 * GUI_GRID_H + GUI_GRID_Y;
                   w = 5.5 * GUI_GRID_W;
                   h = 3.5 * GUI_GRID_H;
                   colorText[] = 
                   {
                       0,
                       0,
                       0,
                       1
                   };
                   SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 2)";
                   shadow = 0;
               };
               class depth: DIS_RscText
               {
                   idc = IDC_DIVECOMPUTER_DEPTH;
                   text = "100";
                   x = -10.5 * GUI_GRID_W + GUI_GRID_X;
                   y = 11.5 * GUI_GRID_H + GUI_GRID_Y;
                   w = 5.5 * GUI_GRID_W;
                   h = 3 * GUI_GRID_H;
                   colorText[] = 
                   {
                       0,
                       0,
                       0,
                       1
                   };
                   SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 2)";
                   shadow = 0;
               };
               class gassname: DIS_RscText
               {
                   idc = IDC_DIVECOMPUTER_GASSNAME;
                   text = "P0.7";
                   x = -16 * GUI_GRID_W + GUI_GRID_X;
                   y = 11.5 * GUI_GRID_H + GUI_GRID_Y;
                   w = 4.5 * GUI_GRID_W;
                   h = 3 * GUI_GRID_H;
                   colorText[] = 
                   {
                       0,
                       0,
                       0,
                       1
                   };
                   SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 2)";
                   shadow = 0;
               };
    
    
           };
    


  10. NTRUDER;2336015']Thanks for the script' date=' Riouken! It works really well and saves a lot of time after spawn/respawn.

    One question though:

    Is there some trick to getting the NLAW ammo saved to a loadout? I don't seem to be able to get it right..

    Cheers! :)[/quote']

    Your welcome!. Thanks.

    No trick that I know of, it should save it. But I will look into it some more. A3 is still in alpha ofcourse, and this gear system is a lot diffrent.

    That said, I found a small bug in my code with the backpacks, this may be affecting you, that I will release an updated version soon, if all goes well along side the addon version of RSLO 3.

    I am glad people are enjoying this project!

    Thanks,

    Rio


  11. @zorrobyte, NVG's are working fine for me. Are you trying to load the NVG's without a vest or backpack?

    Also you should be aware, wearing clothes that are not your faction, while it can be forced by a scirpt, is limited by the game, and after you force it on the player it becomes a client side only effect. So in a mp game other people will not be able to see the clothes if your wearing civ clothes as a bluefor.


  12. RSLO 3.0 - Riouken's Selectable loadouts - Module

    RSLO 3.0 is a set of scripts that allows the user to save up to 10 loadouts and have them persist even after you shut down the game. This is mission based and I have re-writen my RSLO from arma 2 to not require an addon.

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    [Disclaimer] This addon writes to your profile var. file. Please make a back up before using. I am not responsible for any damage/errors/corruption that may occur.

    Please back up these files before use.

    -user/documents/Arma3 Alpha - Other Profiles/username/username.vars

    -user/documents/Arma3 Alpha - Other Profiles/username/username

    replace the username with your Arma 3 in game profile name.

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Thanks Eggbeast for a few ideas and some code.

    Thanks to all the guys in [TFA] Task Force Apache for helping me test this all day.

    Features

    -10 User nameable loadouts

    -Loadouts will persist with you profile, even after you shut down the game.

    -You can change loadout names on the fly.

    -You can delete loadouts on the fly.

    -Saves all Gear including:

    -Backpacks.

    -Backpack Contents.

    -Clothes.

    -Vests.

    -Vest items.

    -Goggles.

    -Helmets.

    -All equiped items.

    -All wepon attachments for all three weapons.

    - And of course all weapons and ammo.

    ------------Installation-----------------------

    • Place the [rslo] folder into your mission.

    • Copy these lines from the description.ext file into your description.ext file

    
    #include <rslo\gui.hpp>
    

    • Place this line of text into your ammo box init field.

    this addAction ["RSLO","rslo\gui_start.sqf"];
    

    There are two files included, the MP .pbo file and the mission editor file.

    I have included my other projects in this release as well, My ammo box script as well as my Rio Gear Menu.

    For more information about these projects please see these links:

    http://forums.bistudio.com/showthread.php?147892-Riouken-s-Gear-Menu-Alpha

    http://forums.bistudio.com/showthread.php?147962-Working-MP-ammo-box-script

    ----------Preview-------------

    2013030700001t.th.jpg

    -------Readme---------------

    ///////////////////////////////////////////////////////////

    ///////// RSLO 3.0 ////////////////////////

    ///////// By: Riouken ////////////////////////

    ///////// ////////////////////////

    /// http://forums.bistudio.com/member.php?64032-Riouken //

    ///////////////////////////////////////////////////////////

    ----------README-----------

    RSLO 3.0 is a user configurable load out set of scripts that allows the user to save up to 10 loadouts and have them persist even after you shut down the game.

    [Disclaimer] This addon writes to your profile var. file. Please make a back up before using. I am not responsible for any damage/errors/corruption that may occur.

    License - You may use this work in any Arma 3 mission/addon. But you must provide credit back to me. You may not use this work for any (for-profit) product. Any derivative must be non-profit based work.

    ------Installation--------

    • Place the [rslo] folder into your mission.

    • Copy these lines from the description.ext file into your description.ext file

    #include <rslo\gui.hpp>

    • Place this line of text into your ammo box init field.

    this addAction ["RSLO","rslo\gui_start.sqf"];

    I have included my other projects in this release as well, My ammo box script as well as my Rio Gear Menu.

    For more information about these projects please see these links:

    http://forums.bistudio.com/showthread.php?147892-Riouken-s-Gear-Menu-Alpha

    http://forums.bistudio.com/showthread.php?147962-Working-MP-ammo-box-script

    -------RSLO Use-------

    Once you have your gear the way you would like open the rslo gui from the ammo box. Select and empty loadout from the list box. Then type a new name into the Loadout name box. Then hit save loadout.

    Then you will be able to retrieve this loadout even after you leave the game and re-connect.

    If you wish to delete a load out just select it from the box on the left and hit the delete loadout button.

    If you wish to re-name a loadout select it from the left and type the new name into the text box and hit the re-name button.

    ----------Beta----------

    This is a beta 1.0 version and as such there may be bugs. If you find one please make a post in the RSLO 3.0 thread on the BI forums.

    My user profile on BI forums.

    http://forums.bistudio.com/member.php?64032-Riouken

    ------Download----------

    http://arma2.co/download?file=79322-RSLO%203.0.zip

    news_download_a3_3.png

    [ALPHA] Riouken's Selectable loadouts - Module v1.0 beta


  13. @lo0se

    hmm. Ill have to check into the editor version.(edit - I see the problem, i include the wrong editor file, i will fix it tommorow and update along with a few other things)

    I may add a few more things like goggles and a a few other features, but this is mostly for me to learn the new gear system and gui in preparation for RSLO 3.0. I'm just getting started with it but it will have wealth of features and be your go to one stop shop for load-out related addons.


  14. your do not have the correct scope to use the magic variable "this". Use player instead.

    _unit = _this select 0;
    if (!local _unit) exitWith {};
    player removeItemFromPrimaryWeapon "optic_Arco";
    player removeItemFromPrimaryWeapon "optic_Aco";
    player removeItemFromPrimaryWeapon "optic_Hamr";
    player removeItemFromPrimaryWeapon "optic_holosight";
    player addprimaryweaponitem "optic_Aco_grn";
    

×