Jump to content

sarogahtyp

Member
  • Content Count

    2494
  • Joined

  • Last visited

  • Medals

Posts posted by sarogahtyp


  1. okay, i read another topic and it says that u cant execute a script with remoteExec. I would do a preprocessed and precompiled function for it then.

    you can use this in the init.sqf:

     

    fnc_my_function = compileFinal preprocessFile "your.sqf";
    then u can use (call or spawn) it where ever u want with:

     

    return_value = [param1, param2] call fnc_my_function;
    or
    [param1, param2] call fnc_my_function;
    or
    param1 call fnc_my_function;
    or
    [] call fnc_my_function;
    
    
    and u can use remote exec then.

  2. i ll post here what comes in my mind with ur code in order as it came with or without relation to ur problem. i will edit this post every time i ve a new suggestion.

    possibleSpies = possibleSpies + [_x];

    replace that with this cause its alot faster:

    possibleSpies pushBack _x;

    I did not understood where the specified problem occurs but the solution should be to find a string in a string like that:

    if ((_element_of_all_units find _player_Str) < 0) then
    {
     hint "player string is NOT inside of playable units";
    }
    else
    {
     hint "player string is inside of playable units";
    };

  3. Sorry, until now i dont know what the script is exactly for.

    Could u explain what the object is which should be attached and which object it should be attached to. A real example could me help to understand what u like to do.

    Another question is why u need to manipulate vectordir and vector up. Because if u have to do that every frame then I think its useless to attach the object cause the advantage of attachTo is that u dont need to worry about those vectors. if that is needed you could setpos instead.

     

     

    EDIT:

    The following line is definetly wrong. There must be an angle of 90 degree at every time between vector dir and vector up. In that code they r pointing in the same direction which is not allowed.

    _object setVectorDirAndUp [[0,0,1],[0,0,1]];
    it could be

    _object setVectorDirAndUp [[0,0,1],[0,1,0]];
    or

    _object setVectorDirAndUp [[0,1,0],[0,0,1]];

    What is that line for? getting worlds center position in model space? for me it seems to be without of sense.

    _v = _attachToObject worldToModel [0,0,0];

  4. heliFuelTruck should be the name of a vehicle. i think it is not and for that your 2nd error shows up
    currentAO should be a markers name but it seems to be not. thats the 3rd error.
    server should be an objects name or whatever but u have no thing named server... 4th.

    I think medicTruck_1_1 should be the name of a vehicle,too ... 1st

     

    just read that rpt snippets urself, its telling u the error:

    Error Undefined variable in expression: helifueltruck
    Error position: <heliFuelTruck) then {heliFuelTruck setF>

    means that heliFuelTruck is used in the script but is unknown at the time of running it


  5. Ok guys I think I got it working. But it needs some more optimizing I think.

    Its useless below 10 meters too but the crosshair is nearly in the center above 10 m.

    I think we should forbid measuring below 50 meters to avoid strange behavior.

    But there are some delays sometimes and that shoul be optimized.

    Also I didnt test with other weapons but i think it should work for it.

    _perfect_start = [0.12,0.57,0.52];
    
    while{true} do
    {
     while {player isIRLaserOn currentWeapon player} do
     {
      if (cameraView == "GUNNER") then
      {
       _txtXhair = "";
       _posXhair = positionCameraToWorld [0, 0, 10000];
    
       _dir = player weaponDirection (currentWeapon player);
       _corr = [(_perfect_start select 0), (_perfect_start select 1), (_perfect_start select 2)];
    
       _posLaser = AGLToASL (player modelToWorld _corr);
       _posXhair = _posLaser vectorAdd (_dir vectorMultiply 4999);
    
       _hitLaser = lineIntersectsSurfaces [_posLaser, _posXhair, player,objNull, true, 1, "GEOM","NONE"];
    
       if (0 < count _hitLaser) then
       {
        _posXhair = (_hitLaser select 0) select 0;
        _txtXhair = str(round(_posLaser distance _posXhair));
       };
    
        _perfect_end = AGLToASL screenToWorld [0.5,0.5];
    
    // reverse calculation of perfect start point with use of perfect end point
    
         _reverse_start = _perfect_end vectorAdd (_dir vectorMultiply -5000);
         _array = lineIntersectsSurfaces [_perfect_end, _reverse_start, objNull,objNull, false, 100, "GEOM","NONE"];
    
         if (0 < (count _array)) then
         { 
          {  
           if((_x select 2) == player)  then
           {   
            _perfect_start = player worldToModel ASLToAGL(_x select 0);
           };
          } forEach _array;
         };
    
      _posXhair = ASLToAGL _posXhair;
      drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\weapon_ca.paa", [0,0.2,0,1], _posXhair, 1, 1, 0, _txtXhair, 0, 0.02, "TahomaB", "center", false];
      }; // gunner check end
     sleep 0.03;
     }; // while IR on end
    sleep 5;
    };

    Status: running with some minor bugs.

    EDIT: I ve tested some other weapons now and it works. I think the laserpointer has the same position at every weapon cause i found no weapon where I noticed a different position.


  6. You are using the wrong Syntax for the Event handler.

     

    You have

    addeventhandler ["STRING","STRING"];
    when it should be

    addEventHandler ["STRING", {CODE}];
    
    Example:

    _this addeventhandler ["respawn",{nil = _this execvm 'rifle.sqf'}];

    i think u r right but in the init line it shoul look:

    this addeventhandler ["respawn",{nil = _this execvm 'rifle.sqf'}];

     

    _d = this addEventHandler ["respawn",{_d = _this execvm 'rifle.sqf'}];


  7. _perfect_start = [0.12,0.57,0.52];
    _timestamp = diag_tickTime;
    
    while{true} do
    {
     while {player isIRLaserOn currentWeapon player} do
     {
      if (cameraView == "GUNNER") then
      {
       _txtXhair = "";
       _posXhair = positionCameraToWorld [0, 0, 10000];
    
       _dir = player weaponDirection (currentWeapon player);
       _corr = [(_perfect_start select 0), (_perfect_start select 1), ((_dir select 2) * (_perfect_start select 2))];
       _posLaser = AGLToASL (player modelToWorld _corr);
       _posXhair = _posLaser vectorAdd (_dir vectorMultiply 4999);
    
       _hitLaser = lineIntersectsSurfaces [_posLaser, _posXhair, player,objNull, true, 1, "GEOM","NONE"];
    
       if (0 < count _hitLaser) then
       {
        _posXhair = (_hitLaser select 0) select 0;
        _txtXhair = str(round(_posLaser distance _posXhair));
       };
       _posXhair = ASLToAGL _posXhair;
    
    // correction should be calculated every second
       _time = diag_tickTime;
       if((_timestamp + 1) < _time) then
       { 
        _timestamp = _time;
    
    //first test if screenToWorld provides correct values and if _posXhair has a different value
        _perfect_end = screenToWorld [0.5,0.5];
        _verify_STW = screenToWorld [0.5,0.499];
        _verify = _perfect_end distance _verify_STW;
        _err = _perfect_end distance _posXhair;
        if((_verify > 0.04) and (_err > 0)) then
        {
    
    // reverse calculation of perfect start point with use of perfect end point
    
         _reverse_start = _perfect_end vectorAdd (_dir vectorMultiply -5000);
         _array = lineIntersectsSurfaces [_perfect_end, _reverse_start, objNull,objNull, false, 100, "GEOM","NONE"];
    
         if (0 < (count _array)) then
         { 
          {  
           if(((_x select 2) == player) or ((_x select 3) == player))  then
           {   
            _perfect_start = player worldToModel ASLToAGL(_x select 0);
            if ((_dir select 2) != 0) then
            {
             _perfect_start = [(_perfect_start select 0), (_perfect_start select 1), ((_perfect_start select 2)/(_dir select 2))];
            };
           };
          } forEach _array;
         };
        }; // check STW and error end
       }; // time check end
      drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\weapon_ca.paa", [0,0.2,0,1], _posXhair, 1, 1, 0, _txtXhair, 0, 0.02, "TahomaB", "center", false];
      }; // gunner check end
     sleep 0.03;
     }; // while IR on end
    sleep 5;
    }; 

    Status: running but very buggy now.

     

    In this version u can see the crosshair only above a distance of 250 m because auto correction is not working until now. (If it ever will?)

     

    Main problem is that I cant get an object or its position from lineintersects return array (line 44).

    It is always returning only 1 element even if their r some objects in the way.

    That element is objNull and the parent object is objNull, too. 

     

    Im tired now. goin to bed.


  8. I should write withs thos ''d'' or just null ?

     

    Sweet it kinda work now :) Just question what i where i need change to get better loot  in your code ? Becous in that scrip 1-3 is , 1 civilian, 2mility and 3is military. I need for 3 so have big guns :P        

    And when i have spawns what need , then im ready to play withs friends ? Or i need scrip somthing else for MP ?

     

    ...ewUnit,3] execVM "fnc_generate...

     

    You can use that eventhandler in the init line of each player in multiplayer

×