Jump to content

cybercoco

Member
  • Content Count

    176
  • Joined

  • Last visited

  • Medals

Posts posted by cybercoco


  1. _test = "hello";
    
    with uiNamespace do {
    	my_awesome_progressBar = findDisplay 46 ctrlCreate ["RscProgress", -1];
    	my_awesome_progressBar ctrlSetPosition [ 0.345, 0.3 ];
    	my_awesome_progressBar progressSetPosition 0;
    	my_awesome_progressBar ctrlCommit 0;
    	
    	my_awesome_text = findDisplay 46 ctrlCreate ["RscStructuredText", -1];
    	my_awesome_text ctrlSetPosition [ 0.345, 0.3 ];
    	my_awesome_text ctrlCommit 0;
    };
    
    [ "TIMER", "onEachFrame", {
        params[ "_start", "_end" ];
        _progress = linearConversion[ _start, _end, time, 0, 1 ];
        (uiNamespace getVariable "my_awesome_progressBar") progressSetPosition _progress;
    	(uiNamespace getVariable "my_awesome_text") ctrlSetStructuredText parseText format["%1%2", round(100*_progress), "%"];
    
    	if ( _progress > 1 ) then {
    		[ "TIMER", "onEachFrame" ] call BIS_fnc_removeStackedEventHandler;
    		ctrlDelete (uiNamespace getVariable "my_awesome_progressBar");
    		ctrlDelete (uiNamespace getVariable "my_awesome_text");
    		/////
                    hint format ["%1", _test]; // HERE !
                    /////
    	};
    }, [ time, time + 20 ] ] call BIS_fnc_addStackedEventHandler;
    

    How can I present the var as a param and make the hint format work properly ?


  2. I would like to search if the player has a certain object in his person. If so, code will be executed.

    I've used the following :

    if (magazines player find FirstAidKit > 0)

    It works fine, but I would like to have a variable instead containing the object's id.

    I tried the code bellow, and it didn't work :

    _id = """FirstAidKit""" // _id is holding the name : "FirstAidKit"
    if (magazines player find _id > 0)
    

    Is it actually possible to make it work that way ?


  3.  

    Just can just use the condition, by someone do you mean player, AI or both.

     

     

     

    Just Player

    _type = "C_Offroad_01_F"; 
    {
     if (typeOf _x isEqualTo _type) then {
     _x addaction [format ["<t>Title Here</t>"],"jack\jack.sqf","",11, true, true, "", "_this distance _target < 3 and { !(player in _target))];
     };
     } foreach vehicles;

    any unit in vehicle inc player

    _type = "C_Offroad_01_F";
    {
    if (typeOf _x isEqualTo _type) then {
    _x addaction [format ["<t>Title Here</t>"],"jack\jack.sqf","",11, true, true, "", "_this distance _target < 3 and  (count crew _target == 0)"];
    };
    } foreach vehicles;

    Thank you, I just realised that I was actually using this double condition on my version but I didn't notice that the thing was working.


  4. Is there a way to delete the addAction if someone gets in the vehicle (only remove the addAction from this one vehicle) ? But then add it back when the player gets out...

     

    Tried it, but doesn't work :

    _type = "C_Offroad_01_F";
     {
        if (typeOf _x isEqualTo _type) 
          then {
            while { alive _x} do {
              if (!player in _x)
                then {
                  _x addaction ["Hello","jack.sqf","",11, true, true, "", "_this distance _target < 3"];
                }
                else {
    	      removeallactions _x;
    	    };
    	sleep 2;
          };
        };
    } foreach vehicles;
    
    

  5. _fnc_Hp = {
        private ["_return","_array"];
        _array = _this select 0;
        _return = [];
    
        {
            _return pushBack (round ((_x * -100) + 100))
        } foreach _array;
    
        _return;
    };
    
    _alldamage = [_all] call _fnc_Hp;
    

    I get how it's working now, thank you Greenfist.

     

     

    The next game update will introduce a new command which reduces this to:

    _fnc_Hp = {
        (_this select 0) apply {round ((_x * -100) + 100)}
    };

    That will be very handy indeed !

     

     

    In addition to what KK said, floor will not reduce an integer number by 1, which you are trying to do in floor (count _array). That means, you're still gonna select a nil value behind the last value of _array which will result in an error.

     

    And why are you not doing your stuff in a forEach loop anyway?

    _all = [0.515342,0.515342,0.515342];
    {
        _all set [_forEachIndex, floor (_x * 100) / 100];
    } forEach _all;
    hintSilent str _all; //[0.51,0.51,0.51]
    

    Thanks for the solution Heeeere's johnny!, it's a quick way to solve the problem.


  6. _fnc_Hp = {
        params ["_array", "_return", "_i"];
        _return = [];
    
             _array select _i from 0 to 2 do {
             round (((_array * -100) + 100));
         _return set [_i, _array];
             };
            _return;
        };
        
        _all = [0,0,0];
        _alldamage = [_all] call _fnc_Hp; // tested _all and [_all] and [0,0,0] 
        hint format ["%1", _alldamage];
    

    Tried with an array of [0,0,0], still doesn't work...


  7. Thanks Davidoss, however the code doesn't work yet :

    _all outputs [0,0,0]

    _alldamage outputs []

    	_fnc_Hp = {
    	params ["_array", "_return", "_i"];
    	_return = [];
    
             _array select _i from 0 to 2 do {
             round (((_array * -100) + 100));
    	 _return set [_i, _array];
             };
    		_return;
        };
        
    	_all = [_won getHit "motor",_won getHit "palivo",_won getHit "karoserie"];
    	_alldamage = [_all] call _fnc_Hp;
    
    // debugg
    	hint format ["%1", _all];
    	sleep 2;
    	hint format ["%1", _alldamage];
    

  8. If you only run this once then it should be no problem, if you want it on every vehicle in the mission.

    For applying the action to specific types only you can change it into something like this:

    _type = "C_Offroad_01_F";
    {
    if (typeOf _x isEqualTo _type) then {
    _x addaction [format ["<t>Title Here</t>"],"jack\jack.sqf","",11, true, true, "", "_this distance _target < 3"];
    };
    } foreach vehicles;

    Cheers

    Thanks mate !


  9.     _fnc_Hp = {
            _this select _i from 0 to 2 do {
                round (((_this * -100) + 100));
            };
        };
        
    _all = [_won getHit "motor",_won getHit "palivo",_won getHit "karoserie"];
        
    hint format ["%1", _all];
    sleep 2;   
    hint format ["%1", _all call _fnc_Hp];
    

    How do I take the array _all containing [_won getHit "motor",_won getHit "palivo",_won getHit "karoserie"] through the function _fnc_Hp


  10. Ok thank you very much, and if i want load in car some weapon or else?

     

    Not tested, might as well not work ...

    _veh = createVehicle ["B_G_Offroad_01_F", getMarkerPos "markerName"]; 
    _veh call compile format ["%1=_this select 0","vehicle1"];
    
    clearWeaponCargoGlobal vehicle1; // clears all weapons
    clearMagazineCargoGlobal vehicle1; // clears all mags
    vehicle1 addWeaponCargoGlobal ["hgun_Rook40_F", 1]; // adds a gun
    

    -EDITED-


  11. I have the following code in init.sqf :

    	_won = nearestObjects [player, ["C_Offroad_01_F"], 50];
    	_won = str _won select [1,5];
    	_won = call compile _won;
    	
    	// script for trigger
    	_trg = createTrigger ["EmptyDetector", getPos _won, false];
    	_trg setTriggerArea [3, 3, 0, false];
    	_trg setTriggerActivation ["WEST","PRESENT",true];
    	_trg setVariable ["won", _won];
    	_trg setTriggerStatements [    
    		"this &&  !(player in (thisTrigger getVariable 'won'))",
    		"(thisTrigger getVariable 'won') addaction [ '<t>Title</t>', 'jack\jack.sqf',"",11]",
    		"removeallactions (thisTrigger getVariable 'won') && hint ''"
    	];
    

    This will look for the nearest vehicle (id : C_Offroad_01_F) name and store it in _won.

    The result is that only one trigger has been created for only one vehicle (the nearest).

    What I would like is to have a "constant" search for the nearest vehicle for each player and then create a for this vehicle trigger.

     

    If you didn't understand the text above, then read this :

    Final objective would be to have an addaction on any vehicle that's in a 3 meters range of a player.


  12. Another test working, but I can't manage to delete the my_Awesome_Text with ctrlDelete ...

    with uiNamespace do {
    	my_awesome_progressBar = findDisplay 46 ctrlCreate ["RscProgress", -1];
    	my_awesome_progressBar ctrlSetPosition [ 0.345, 0.3 ];
    	my_awesome_progressBar progressSetPosition 0;
    	my_awesome_progressBar ctrlCommit 0;
    	
    	
        [ "TIMER", "onEachFrame", {
            params[ "_start", "_end" ];
            _progress = linearConversion[ _start, _end, time, 0, 1 ];
            (uiNamespace getVariable "my_awesome_progressBar") progressSetPosition _progress;
    		
    		with uiNamespace do {
    			my_awesome_text = findDisplay 46 ctrlCreate ["RscStructuredText", -1];
    			my_awesome_text ctrlSetPosition [ 0.345, 0.3 ]; //ctrlSetPosition [0,0,1,0.1]; //[0.5,0.1]; //
    			my_awesome_text ctrlCommit 0;
    			my_awesome_text ctrlSetStructuredText parseText format["%1%2", round(100*_progress), "%"];
    		};
    		// ctrlDelete (uiNamespace getVariable "my_awesome_text");	
    		if ( _progress > 1 ) then {
                [ "TIMER", "onEachFrame" ] call BIS_fnc_removeStackedEventHandler;
    			ctrlDelete (uiNamespace getVariable "my_awesome_progressBar");
    			hint "FINISHED";
    		
            };
        }, [ time, time + 20 ] ] call BIS_fnc_addStackedEventHandler;
    };
    

    Basically, this code outputs a % value and repeat the progress to 100%, the values overlay on each other !


  13.  

    Only change I would make to it, as with most of my old projects and such, I couldn't have the suspension, or it needed to move onto the next piece of code after the hint without waiting for the hint to complete, so I would spawn it in:

    _fnc_timedHint =
    {
    	params ["_hint","_time"];
    	hint _hint;
    	sleep _time;
    	hint "";
    };
    
    ["Spawning a vehicle ...",2] spawn _fnc_timedHint;
    
    "B_G_Offroad_01_F" createVehicle position player;
    
    ["Vehicle spawned near you",2] spawn _fnc_timedHint;
    

    Thanks for the trick ;)

×