Jump to content

riouken

Member
  • Content Count

    570
  • Joined

  • Last visited

  • Medals

Posts posted by riouken


  1. Maybe an example from one of my missions will help you.

    This is a set of scripts that allow the user to select a locations via mapclick and color of the flare and will rain down flares on the selected location.(The dialog and a few other parts were not shown to not cloud the example) All of the options are made locally, then the script is ran on the server so that everyone in MP can see the flares as well.

    In the init.sqf

    // This is the eventhandler that we are adding to the server and the clients.
    "flare_start" addPublicVariableEventHandler {[] execVM "opcom\scripts\flares\flaremain.sqf";};
    

    This is from my dialog(which is local, it is just like you starting it from an addaction).

    class flrstrtbtn: RscShortcutButton
    {
    idc = 1701;
    text = "Start";
    x = 0.285417 * safezoneW + safezoneX;
    y = 0.176667 * safezoneH + safezoneY;
    w = 0.113888 * safezoneW;
    h = 0.0938889 * safezoneH;
           onButtonClick = "execVM 'opcom\scripts\flares\flarego.sqf'";
    };
    

    this is the flarego.sqf.

    // Opcom Interface , By Oliver 15thMEU(SOC).
    
    flare_start = true;
    
    publicVariable "flare_start"; 
    

    and this is the flaremain.sqf:

    // Opcom Interface , By Oliver 15thMEU(SOC).
    
    if (!isServer) exitWith {};
    // _flrinpcolor = lbCurSel 2100;
    // _flrinptime = lbCurSel 2101;
    _flrcolor = "";
    _flrtime = "";
    
    switch (true) do {
       case (flrinpcolor == 0) : { _flrcolor = "F_40mm_Red";};
       case (flrinpcolor == 1) : { _flrcolor = "F_40mm_Green";};
       case (flrinpcolor == 2) : { _flrcolor = "F_40mm_White";};
    };
    
    switch (true) do {
       case (flrinptime == 0) : { _flrtime = 30;};
       case (flrinptime == 1) : { _flrtime = 60;};
       case (flrinptime == 2) : { _flrtime = 120;};
       case (flrinptime == 3) : { _flrtime = 180;};
       case (flrinptime == 4) : { _flrtime = 300;};
       case (flrinptime == 5) : { _flrtime = 600;};
       case (flrinptime == 6) : { _flrtime = 1800;}; 
    };
    
    _starttime = time + 0;
    
    //_xflrpos = newflrpos select 0;
    //_yflrpos = newflrpos select 1
    
    while {time <(_starttime + _flrtime)} do
    {
    
       flare = _flrcolor createVehicle [newflrpos select 0, newflrpos select 1,150];
    
       sleep 21;
       flars_are_running = true; 
    };
    
    
    if (time >(_starttime + _flrtime)) then
    {
       flars_are_running = false;
       [nil,opcom,"loc",rHINT,"Flares have ended."] call RE;
    };
    

    ---------- Post added at 12:37 PM ---------- Previous post was at 12:30 PM ----------

    The only problem with publicVariableEventhandler's are that the EH will not fire on the client that is sending the publicVariable, so if your testing it on local host or in the editor it will not work, but a work around for this is this:

    flarego.sqf.

    // Opcom Interface , By Oliver 15thMEU(SOC).
    
    if (isServer) then {
    
         flare_start = true;
         _nop = [] execVM 'opcom\scripts\flares\flarego.sqf;
    
    } else {
    
        flare_start = true;
        publicVariable "flare_start";
    };
    


  2. I dont work with UPSMON very much but check MON_SPAWN.sqf and see if it is limiting the script to only run on the server.

    For your script you should put this at the top, it will ensure that it only runs on the server, you dont want an AI spawning script running on all clients(You would have a set for each client +server.)

    This will tell everything except the server to exit.(Works for Dedi as well as local hosted.).

    if (!isServer) exitWith {};
    

    I have a feeling this is due to how your calling the script, can you post more detail about how your calling it so we can debug it some more.

    ---------- Post added at 07:13 AM ---------- Previous post was at 07:10 AM ----------

    Ok just saw your updated post, just as I thought, your calling the script from a client and the script your calling (MON_SPAWN.SQF) has a check to only run on the server. So your problem is that your calling it from a client, I need some more details though to help with how your calling it.


  3. RSLO Updated to version 2.0!

    Updates for ver 2.0:

    *Added GUI

    *Upped total loadouts to 5

    *User can name each loadout in thier config and it will show up in the box ingame.

    *Can now set view distance and terrain detail with RSLO.

    *Improved scripts for better performance.

    Download ver 2.0 - http://www.multiupload.com/SID1U468TM

    *Updated first post.

    Sorry for the long wait on the update everyone, I had to take some time off due to real life, but I am glad I could get this done and out to everone. I hope you enjoy using it.

    Thanks.:bounce3:


  4. It may be from starting the script from the init.sqf. I have had some problems with dedicated hosting and getting scripts to run correctly especially with jip. Try this:

    Start the script from two triggers:

    On each trigger in the on-activation field execVM your script.

    One with a condition of:

    isServer
    

    The other with a condition of :

    local player
    

    That should ensure that your script is running on every client and the server even for JIP.


  5. -;2048452']Anyone know the command to check if the player has a specific type of magazine ? I know for weapon is hasWeapon but i can't find it for magazine' date=' anyone have a idea how I'll do that.[/quote']

    magazines

    _mags = magazines player;
    
    _magtocheck = "30Rnd_556x45_Stanag";
    
    if (_magtocheck in _mags) then
      {
           hint "You have a magazine for the M16!";
      };
    

    That is just one way to do it. If you post some of your code and a bit more detail on what your trying to do we may be able to help you more.


  6. edit: never mind I didn't read your code right the first time.

    re-edit:

    Your trying to use setVehicleInit on a group, it just needs to run on the leader.

    _enemyCount=12
    _name=dubrovkaspawn
    _grpbuild1 = [getPos _name, east, _enemyCount] call BIS_fnc_spawnGroup;
    
    [color="Red"]leader _grpbuild1[/color]  setVehicleInit "_grpbuild1 execVM "PlaceInBuilding.sqf";
    processInitCommands;
    

    ---------- Post added at 06:46 AM ---------- Previous post was at 06:22 AM ----------

    Also I dont think you really need to use setVehicleInit in this case, if this script is running on the server where the AI is local then you can just exicute the command strait out.

    _grpbuild1 execVM "PlaceInBuilding.sqf";
    

    If the script is not running on the server, then you could use the CBA event system or public variable eventhandler to execute the PlaceInBuilding.sqf.


  7. is there a way to put this on trigger for only active player (me) and not my other unit?

    i created a mission i don't want to put this script to every units cause i don't want them can use unlimited ammo when i'm not playing them so a trigger like radio call could be useful

    // This is used in the init of the unit in the mission.
    this addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}];
    
    // This is used to add the eventhandler at a later time.
    _unitname addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1}];
    


  8. I just tested it, the Fire command does not appear to be working correctly, I could get the other commands to work but fire would not return 1 even when pressed.

    I would add a small sleep command to your script though:

    while{true}do{ 
    if(inputAction "fire" != 0)then{hint "fire button pressed!"};
    [color="Red"]sleep .01;[/color] 
    };
    

    But if your looking at doing something when the pilot fires you would always use an Fired eventhandler.

    http://community.bistudio.com/wiki/ArmA:_Event_Handlers#Fired

×