Jump to content

poweruser

Member
  • Content Count

    248
  • Joined

  • Last visited

  • Medals

Posts posted by poweruser


  1. Frizen, search ...

    Or let someone stupid like me write you a script (The heck with it, just for the fun of scripting)

    Goes into the init line of the plane:

    this addaction ["boost", "boost.sqf"];

    boost.sqf:

    private["_valid","_plane","_vel","_boost_interval",

    "_max_velocity","_boost_factor","_vector","_x","_y","_z","_dir"];

    _boost_interval = 0.5; // in sec.

    _max_velocity = 130; // in meter/sec. good bet: (config max speed)/3.6

    _boost_factor = 1.5;

    _valid = true;

    _plane = _this select 0;

    if(player != driver _plane) then {

    _valid = false;

    hint "You're not the pilot";

    } else {

    if(fuel _plane < 0.01) then {

    _valid = false;

    hint "Not enough fuel";

    } else {

    if(getpos _plane select 2 > 5) then {

    _valid = false;

    hint "You've already taken off";

    };

    };

    };

    if(_valid) then {

    _plane vehiclechat format ["Boosting your %1", typeof _plane];

    _vel = velocity _plane;

    _vector = sqrt((_vel select 0)^2 + (_vel select 1)^2 + (_vel select 2)^2);

    while {_vector < _max_velocity} do {

    _dir = getDir _plane;

    _x = (_vel select 0) * _boost_factor * (sin _dir);

    _y = (_vel select 1) * _boost_factor * (cos _dir);

    _z = abs((_vel select 2) * _boost_factor);

    _plane setVelocity [_x, _y, _z];

    sleep _boost_interval;

    _vel = velocity _plane;

    _vector = sqrt((_vel select 0)^2 + (_vel select 1)^2 + (_vel select 2)^2);

    };

    _plane vehiclechat "Shuting booster off";

    };

    Play around with the variables _boost_interval , _max_velocity and _boost_factor to get the desired results.


  2. Does this part: if(isServer) then { [] execvm "scriptname.sqf"; };

    go in a trigger, and if so, is the "isServer" in the Condition and the {execVM...} in the Activation? Or should another script be used to fire that line?

    When you use a trigger, all of it goes into the 'On Activation' field. You can also use another script to do it, whatever you like. Like I said, run it at the time you want the groups to start attacking, where you do it is up to you.

    I tried it using a trigger to test for server and call for the script. It's firing the script, but it's not moving the groups.

    Then you haven't either defined the two arrays in the init.sqf. Or you didn't set up the waypoints of the groups, the way I suggested it at the beginning of my last post.


  3. Ok, here's one way to implement it then:

    A waypoint has a condition, when it's false the group perfroms that waypoints (the one with condition being 'false') orders but then waits for the condition to become 'true' before performing the next waypoint.

    Give those waypoints that send the groups at the place where they shall wait first, before being sent to attack, following conditions:

    for the 1st group:

    1 in attackorders

    for the 2nd group:

    2 in attackorders

    and so on..

    In the mission init script, define this:

    squadarray = [1,2,3,4,5];
    attackorders = [];
    

    And this is the complete script. Only execute it once, at the time you want the groups to start attacking.

    if(isServer) then { [] execvm "scriptname.sqf"; };

    scriptname.sqf:

    private["_rnd"];
    while {count squadarray > 0} do {
    [indent]_rnd = squadarray select (floor(random(count squadarray)));
    squadarray = squadarray - [_rnd];
    attackorders = attackorders + [_rnd];
    sleep (90 + random 20);[/indent]
    
    
    };

    ================================================

    @while loop in first post script example:

    you have to use the double equals sign == ,when you want to check whether two values are equal. Single equal signs = are used for assignments.

    The OR is correct there, I usually use ||, it does the same thing.

    Additionally the syntax of your 2nd while loop is wrong.

    And you need to define the variable 'c' first, before you use it. (same goes for the other while loop)

    c = round ((random 4) + 0.5);
    while {c==a OR c==b} do
    {
     c = random 4;
     c = c + 0.5;
     c = round c;
    };


  4. Just a quick thought:

    Additional to the Turret and Gun Animations with the sources 'mainTurret' and 'mainGun' defined in the cfgModels class, you could add the same animations again (different class names ofc.), but this time both with the source 'user'. That enables you to rotate/elevate the cannon by scripts (command 'animate').

    Then simply add some useractions to the cannon (or some other fancy interface) with which the player can script-rotate the cannon by a certain number of degrees, to speed up the rotation process. And for the rotation speed values in the config leave the low ones.


  5. You can do this a lot easier and with only one script, instead of one for each draw.

    In the mission init script, define an array containing your five squads, like:

    squadarray = [1,2,3,4,5];

    Instead of the numbers you can also store the groups directly, then you don't have to translate from the number to the group later. (l1 be the leader of squad1, l2 be the leader of squad2, and so on...)

    squadarray = [group l1, group l2, group l3, group l4, group l5];

    then thats the whole sqf script:

    EDITED: fixed a typo, updated entry selection

    private["_array","_rnd"];

    _array = _this select 0;

    _rnd = _array select (floor(random(count _array))); // picks a random entry of the array 'squadarray'

    _array = _array - [_rnd]; // removes the picked entry from the array

    executed with:

    [squadarray] execVm "scriptname.sqf";

    The clue here is to memorize the set of entries that are valid to pick, and after you picked something you remove the picked one from the set. That avoids writing extra scripts for each time.

    The local variable _rnd is the selected entry from the set, it corresponds to the variable 'x' in your scripts

    ADDED:

    Multiplayer notes:

    Make sure that you run this script only on the server as otherwise every connected machine would generate a different random number.


  6. execVM/call this on the init-event of the vehicle:

    
    
    if(isnil "UniqueGlobalVariable") then {
    
    
    
    [indent]UniqueGlobalVariable = true;
    VariableForBroadcast = [];
    "VariableForBroadcast" addPublicVariableEventHandler {
    [indent]if (time - ((_this select 1) select 3) < 10) then {
    [indent](_this select 1) execVM "pop_smoke.sqf";   // adjust script-path here[/indent]
    
    
    };[/indent]
    
    };[/indent]
    };
    
    
    

    lets say this is the code that is executed when the gunner hits the action

    [TANKOBJECT,MAINGUN,RELOADTIME] execVM "pop_smoke.sqf";

    extend it to:

    [TANKOBJECT,MAINGUN,RELOADTIME] execVM "pop_smoke.sqf";
    VariableForBroadcast = [TANKOBJECT,MAINGUN,RELOADTIME,time];
    publicVariable "VariableForBroadcast";

    and in the script pop_smoke.sqf use 'createVehicleLocal' instead of 'createvehicle'.

    ======================================

    Note: the check with the time (when the variable is published and when its received is required, to avoid smokeshells being fired off, on the last vehicle that has done it, for jip-players right after they join. Thats because of the vehicles in the mission being init-ed before the published variables are being syncronised for jip-players

    ======================================

    Another mp issue that is being resolved that way (which you are probably not aware of right now) is the reload status.

    'setVariable' has local effect only, meaning that the vehicle is marked as reloading the smokeshells only for the player that has shot them (in your script). That can be exploited.


  7. Take a minute and think about your shar.sqs script again. The first line doesnt really make sense, and the second creates your rear-vehicle at the position [0,0,0]. The init-event is executed on all connected machines in a multiplayer game, that means that multiple rear-vehicles will be created per front?-vehicles in a mp game.

    It should be more like this, shouldn't it?

    private["_pos","_vehicle"];
    if(isServer) then {
    
    [indent]_pos = getPos (_this select 0);
    _vehicle = "Rear" createVehicle _pos;[/indent]
    
    
    };
    exit;


  8. It's a urban legend that the line

    if (!isServer) exitWith {};

    does the same as (in sqs scripts)

    ?(!isServer): exit 

    They are NOT and do NOT the same!

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

    exitWith exits the execution of a loop defined by one of commands do, for, count or forEach. When you use exitWith not inside a loops, the behaviour is undefined - sometimes it may exit the script, sometimes some other scope, but this is not intended and designed behaviour of this command, and it is not guaranteed to work reliably.

    It exits the loop only, not the script.

    Do it this way instead:

    if (isServer) then {
       // code to be executed on the server only
    };


  9. It is.

    You have to have to overwrite the class 'SoundEnvironExt' (which is defined in the base class 'CAManBase') within your new units class.

    
    
    class CfgVehicles {
    [indent]class someBaseClass;
    class yourunit: someBaseClass {
    [indent]class SoundEnvironExt {
    [indent]// define the new movement sounds here[/indent]
    
    
    };[/indent]
    };
    [/indent]
    };
    


  10. The init script is run on all connected machines once at mission start (server, clients and jip-clients). That means that on a dedicated server with #X clients the script is executed 1+#X times and as the command 'createVehicle' has global effect, the 'LAND_A_*' objects objects are created 1+#X as well. To make sure that some code is only run once on mission start, put this if-clause around it:

    if(isServer) then {
         // code to be run only on the server
    };


  11. In sqf:

    private["_x","_y","_xpos","_ypos","_xspread","_yspread","_flares","_flare1"];
    if(isServer) then {
    sleep 4;
    _xpos = (getpos middle) select 0;
    _ypos = (getpos middle) select 1;
    _xspread = 250;
    _yspread = 500;
    _flares = ["F_40mm_White","F_40mm_Red","F_40mm_Green","F_40mm_Yellow"];
    while { autoflares } do {
    	_x = _xpos + ((random _xspread) - _xspread / 2);
    	_y = _ypos + ((random _yspread) - _yspread / 2);
    	_flare1 = (_flares select (random 3)) createvehicle [_x,_y,120];
    	sleep (10 + random 10);
    };
    };
    
    true

    It doesn't require a game logic with the name 'server' anymore, but it still requires an object with the name 'middle'. I've set the variable 'autoflares' as condition of the loop, so you're able to shut it off in the mission by setting it to 'false'.


  12. Here's the compensation for the latency of variable distribution you fear:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if(isNil "MYADDON") then {

            MYADDON = (_this select 0);

            sleep 3;

            if(MYADDON == (_this select 0)) then {

            // Your code goes here

           };

    };

    Any additional instances that pass the isNil check will either overwrite the already set variable or their value will be overwritten by some other instance. There can only be one instance executing the distribution as the last one. Then all instances will wait to make sure that all other instances have done that as well. After the timeout, the instance that executed it as last will continue, all others will exit.


  13. You can avoid having multiple instances of your script, by adding this to your init script:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

    if(isNil "MYADDON_initialised") then {

           MYADDON_initialised = true;

           // Your code goes here

    };

    Or use xehs PreInit or PostInit EHs

    (but: PreInit only available in XEH v1.9 and later; PostInit only available in XEH v1.91 and later)

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class Extended_PreInit_EventHandlers {

       MYADDON_init = " _this execVM ""\MYADDON\init.sqf""; ";

    };

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class Extended_PostInit_EventHandlers {

       MYADDON_init = " _this execVM ""\MYADDON\init.sqf""; ";

    };

    Quote[/b] ]... running the same server script 100 times if 100 men are local to the server

    The init event is global.


  14. I don't think that you can access this detailed info directly, only the sum of all scores with the command 'score'.

    But you can record this info during the mission:

    Add a killed-Eventhandler to all units (or extend an already existing one). This EH returns the destroyed object and the one who destroyed it.

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addeventhandler["killed", {_this execVM "score.sqf";}];

    score.sqf

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private["_obj", "_killer", "_type"];

    _obj = _this select 0;

    _killer = _this select 1;

    if(_obj iskindof "Man") then {

           // _killer killed a soldier

    } else {

           _type = getNumber (configFile >> "CfgVehicles" >> (typeOf _obj) >> "type");

           if(_type == 0) then {

                   //_killer killed a soft vehicle

           };

           if(_type == 1) then {

                   // _killer killed a tank

           };

           if(_type == 2) then {

                   // _killer killed a aircraft

           };

    };

    Then you have to think of some datastructure where you store and maintain these infos for each player.


  15. I've been trying to find a workaround for this. So far I can read the available weapons/magazines of the gear menu, whenever the client accesses it. Just have to find a way now to find out at what object (corpse, ammo box, vehicle, nothing) the player looked at, at that time, to assign the content to the right object.


  16. Update:  New version of the bridge addon Themis v1.0.1.02

    Our bridge addon Themis v1.0 or v1.0.1.01 does not work well together with the latest versions of the

    Extended Eventhandlers addon (released along with ACE v1.01 and ACE v1.02), if at all.

    There have been player reports that ECS will work with ACE v1.01 by using the old Themis (v1.0), but this is not true.

    With this configuration almost none of the game events will reach ECS (only from vehicles of the type "LandVehicle" (Cars and Tanks)).

    To prove these players wrong: In the mission editor, put only yourself as soldier on the map and preview. ECS won't initialise then.

    That's why we release a new version of Themis v1.0.1.02 which is compatible with all public versions of the Extended Eventhandlers addon

    (tested down to v1.4) and should stay compatible with future versions of it.

    The old versions 1.0 and 1.0.1.01 are obsolete from now on and shall be replaced with v1.0.1.02

    Download as usual on our site: ECS Website - Downloads

×