Jump to content

SpaydCBR

Member
  • Content Count

    99
  • Joined

  • Last visited

  • Medals

  • Medals

Posts posted by SpaydCBR


  1. Hello all,

     

    It appears the Revive respawn template no longer works. When I start my misison it says something like "Revive respawn template was not found", and sure enough, there's no Revive entry under CfgRespawnTemplates (did they forget to add it?). I tried using the Revive options in the editor as well. That didn't give me any errors, but didn't seem to do anything.

     

    Any thoughts?


  2. Modified from davidoss suggestion:

    //Call from initServer.sqf
    
    this disableAI "MOVE";
    if (isServer) then {
      {
        _x spawn {
    
            params ["_unit"];
                
            while {alive _unit} do {
                
                if ((behaviour _unit) == "COMBAT") then {_unit enableAI "MOVE"}
                else {_unit disableAI "MOVE"};
                    
                sleep 5;
            };
        };
      } forEach allUnits;
    };

    Untested, but something like that should work.


  3. I just tested the objectVar function and this is what I found:

    1. BIS_fnc_objectVar uses setVehicleVarname. The effect of setVehicleVarname is local only to the machine which called BIS_fnc_objectVar (but is executed again when locality is changed.)

    2. The variable name is stored in the object's variable space (set/getVariable) is transmitted to all clients but you need to call BIS_fnc_objectVar again to fetch it.

    Like I said in my previous post switch out:

    _name = format ["%1_grp", vehicleVarName vehicle player];

    with:

    _name = format ["%1_grp", vehicle player call BIS_fnc_objectVar];

    That should do the trick. If not you can upload the mission file and I can take a closer look.

     

    That worked! Everything seems to be working fine now. Thanks mrcurry! I guess I just assumed that if an object already had a name then BIS_fnc_objectVar and vehicleVarName did essentially the same thing.


  4. Thanks mrcurry :)

     

    I'm at work right now, but last night I did some dedicated environment tests. I used system chat to display the variable names of the vehicles at the start of the mission and they did in fact have valid names, but when I got IN them 'vehicleVarName vehicle player' returned an empty string, but ONLY when they're attached to the vehicle respawn module. If I remove the line that adds the vehicle respawn module, then everything seems to work fine. (Maybe not with posted code, the code has been slightly changed). I'll update the OP when I get home, as it can be much shorter now that I've narrowed down the problem.

     

    I will try your solution when I get home and let you know what happens. If it doesn't work I will upload the small test mission I'm using to demonstrate this problem.

     

    I realize that I could simply give all the vehicles names in the editor and that would probably fix my problem, but I would like to learn what's going on here :)


  5. I'm no scripting wizard, but I think you can use the "Fired" event handler and check if the thing that fired was an explosive. Then maybe you could check if the explosive is within an acceptable distance to markers you've placed on either end of the bridge.

     

    Not sure if there's a way to detect that the explosives actually exploded, and I don't think bridges are destructible.

     

    That's all I got, sorry :)


  6. From the Wiki, BIS_fnc_objectVar: "Return an unique object variable. The variable is preserved after unit respawn."

     

    By test mission I simply mean that while I am making a mission, I usually have 1 or 2 other missions where I test individual features before copying them into my main mission. These other test missions are under the same environment, or at least I assume so.

     

    Right now the problem is from _name = format["%1_grp", vehicleVarName vehicle player];

    That statement is simply returning nothing, whereas in my test mission, it returns the correct name, which is the one set by the objectVar function call earlier.

     

    What I've been doing now is I've started a new clean mission, and one by one I'm copying features into it until I get the same problem and hopefully that'll give me a clue as to what's causing it. I'm at work right now, but so far everything is still working fine, including the part that this topic is about, so I'm guessing there's something with my other code that's messing things up.


  7. @barbolani

    I'm not sure. I don't use the .rpt I don't even know where it is haha. I just use the debug console :)

     

    @Bnae

    I'm not sure what it is I'm looking for in that link. I think I'm using getVariable fine. I think the problem is 'vehicleVarName vehicle player' is returning a different name than was set by 'BIS_fnc_objectVar', and again, it's working fine in my test mission :(


  8. Please, for the love of all that is holy, somebody help with this. I've been racking my brain for days trying to figure this out. Basically I have a bit of code that works perfectly in one mission, but not in another, even though it was copy and pasted from the one that worked! :391:

     

    This is what I have. I have 2 groups of infantry squads, and 2 pairs of hunters. I want to assign each pair of hunters to one group, so that only members of that group can spawn at or drive that pair of hunters.

     

    Each pair of hunters is synced to a logic module, and both of those logic modules (one for each pair of hunters) are synced to one main logic module that has the following in it's init:

    [this, west] remoteExec ["CBR_fnc_assignVehicle",2]
    

    In CBR_fnc_assignVehicle I have the following, and as far as I can tell, it works fine but maybe the problem is here somewhere:

    //CBR_fnc_assignVehicle
    
    params ["_logic","_side"];
    _logics = synchronizedObjects _logic;
    
    //Get all groups for side
    _groups = [];
    {
    	if (side _x isEqualTo _side) then {
    		_groups pushBack _x;
    	}
    } forEach allGroups;
    
    //array for tracking in the debugger watch
    vehs = [];
    
    //Assign each group to a group of vehicles
    for "_i" from 0 to (count _groups) - 1 do
    {
    	{
    		if (typeOf _x isKindOf "AllVehicles") then {
    		
    			//set up respawn position
    			_displayName = getText(configFile >> "CfgVehicles" >> typeOf _x >> "displayName");
    			_group = _groups select _i;
    			[_group, _x, format["%1 - %2", _displayName, _group]] call BIS_fnc_addRespawnPosition;
    			
    			//save vehicle group in missionNamespace
    			_name = format ["%1_grp", _x call BIS_fnc_objectVar]; //shouldn't objectVar create a unique variable name that always stays with the vehicle?
    			missionNamespace setVariable [_name, _group];
    			publicVariable _name;
    			
    			vehs pushBack _name; //just for debugging, and returns a valid list of variable names
    			
    			//set up vehicle respawn
    			[_x,5,0,-1,
    				{
    					params ["_newVeh", "_oldVeh"];
    					
    					//attach marker to new vehicle
    					_newVeh remoteExec ["CBR_fnc_marker", 0, true];
    				}
    			,0,2,1,true,true,0,false] call BIS_fnc_moduleRespawnVehicle;
    		};
    	} forEach synchronizedObjects (_logics select _i);
    };
    

    As far as I can tell, there's nothing wrong with this part.

     

    Now I also have some code in onPlayerRespawn.sqf

    //Start Arsenal on spawn
    ["Open",[nil, AmmoBox, player]] call BIS_fnc_Arsenal;
    
    //run crewCheck
    [] spawn CBR_fnc_crewCheck;
    

    So everytime the respawns I want him to run my crewcheck function, which I think is where I'm having the trouble

    //CBR_fnc_crewCheck
    //called from onPlayerRespawn
    
    //another array for debugging
    crewCheckVehs = [];
    
    while {alive player} do
    {
    	//Check if player is the driver of a vehicle
    	waitUntil {sleep 0.5; vehicle player != player && driver vehicle player == player};
    
    	//Eject player if not helicopter pilot
    	if (vehicle player isKindOf "Helicopter") then {
    		if (typeOf player != "B_Helipilot_F" && typeOf player != "O_Helipilot_F") then {
    			player action ["GetOut", vehicle player];
    			waitUntil {sleep 0.5; vehicle player == player};
    			hint "You are not a helicopter pilot";
    		};
    	};
    	
    	//Eject driver from car if wrong group
    	if (vehicle player isKindOf "Car") then {
    
                    //should be same one as created from the objectVar call in assignVehicle, but it's something else
                    //also displaying in the form "B Alpha1-1:1 (SpaydCBR)(bis_o2_xxxx)" where bis_o2_xxxx is not in the vehs array
    ​                //should be in the form "bis_o2_xxxx" . Without the player info in the beginning and be in the vehs array
    		_name = format ["%1_grp", vehicleVarName vehicle player];
    		
    		crewCheckVehs pushBack _name; 				//says "_grp". WHY???
    		_group = missionNamespace getVariable [_name, grpNull]; //so this returns grpNull
    		
    		if (group player != _group) then {
    			player action ["GetOut", vehicle player]; //vehicle player is returning 
    			waitUntil {sleep 0.5; vehicle player == player};
    			hint format ["Only members of %1 are allowed to drive this vehicle", _group];
    		};
    	};
    };
    

    I see where it's going wrong, but I don't know why? As I said, this same exact code works perfectly fine in my test mission, but not the main mission that I copied it to.

     

    I thought variable names generated by BIS_fnc_objectVar stay with the vehicle always, but it looks like it's changing (again only in the main mission. Works fine in my test mission).

     

    The only thing I can think of is that it's running these scripts at a different order than in the other mission, but it really shouldn't.

     

    Any ideas?


  9. Thanks for the responses guys, but I already have a working Arsenal with whitelisted items that's attached to an ammobox in the world. My problem is that an AT guy could simply 'drop' his launcher for a non AT guy to pick up, then the AT guy can get another one for himself thus bringing in more launchers than allowed into the world.

     

    My question was how do I start the Virtual Arsenal BEFORE they respawn, like maybe in the respawn menu. Just like in Battlefield where you can only select your loadout before you spawn. The MenuInventory template let's you do this, but I don't like it. I was hoping there was a way I could replace it with the Virtual Arsenal where it's accessible from the respawn position menu.


  10. Unless you use a script outside of the editor I think you'll have to stick with using the 21 ands (which shouldn't be a problem, it just looks ugly). The stamina part depends on what type of mission you're creating. Do you have respawns for the player? Is it a single player or multiplayer mission? If there are no respawns for the player (single or multiplayer) then putting "player enableStamina false;" in the init field (without the quotes) of every playable unit will disable stamina. If there are respawns in a single player game, then put this in the init field of the playable unit: 

    player enableStamina false;
    this addEventHandler["respawn",{player enableStamina false;}];
    

    If this is a multiplayer game with respawns then put this in the init field of every playable unit:

    player enableStamina false;
    this addMPEventHandler["mprespawn",{player enableStamina false;}];
    

    I know this works because I just solved this issue for myself a couple hours ago :)

    I think you could also just put it in the initPlayerLocal.sqf right?


  11. I want my players to pick their loadout before they spawn into the game to limit the number of restricted items there are in the world (e.g. There should be no more Rocket Launchers than there are AT soldiers) for balancing reasons. I've looked into MenuInventory, but it seems that I'd have to choose the loadouts for them and I don't want to do that. I was wondering if there's a way to replace it with the Virtual Arsenal, where when you're in the Respawn menu, you click on the right arrow to go to the change loadout screen (as you normally would for MenuInventory), but you're taken to the Virtual Arsenal instead, where you can build your loadout from a predefined set of items.

     

    Would this be possible? I have no clue how to do this, as I have absolutely no idea how the respawn templates actually work (perhaps there are guides I can read). I'm also open to other suggestions on how to do this, but I think this way would be the ideal User Experience, since players would not be bothered by the Arsenal when they're respawning (and spawn with their last loadout) unless they want to change their loadouts.

×