Creating a "Battlefield Updates" chat script (need help though)

  1. 4 months ago

    WHAT I'M TRYING TO ACHIEVE


    OK, so, I'm currently writing a script that will achieve the following;

    Every 5 minutes (arbitrary number) the AI will post in side chat a "Battlefield Update" showing the current force pool and current number of profiles for BLUFOR.

    However, I cannot for the life of me get it to pickup the values for force pool and profile count.

    Some things to consider:

    • I'd like this to show for every player in the game (hence the initPlayerLocal.sqf)
    • If possible, I'd like this to run regardless of host type (i.e. a dedicated server or someone just hosting a multiplayer game from within the client)

    MY CURRENT CODE


    In my initPlayerLocal.sqf (this just pulls from a param, the host can turn these updates on/off;

    // Battlefield updates Param
    if ((paramsArray select 12) == 1) then
    {
    [] execVM "battleUpdates.sqf";
    };

    In battleUpdates.sqf;

    // Get number of BLUFOR profiles
    _profilesBySide = [ALiVE_profileHandler,"profilesBySide"] call ALIVE_fnc_hashGet;
    _profilesBySide = _profilesBySide select 1;
    
    // Get current BLUFOR force pool
    _currentBLUFORForcepool = [ALIVE_globalForcePool,"BLU_F"] call ALIVE_fnc_hashGet;
    
    // While loop to display chat from HQ using above variables
    while {true} do {
    
    	sleep 10;
    	[west, "HQ"] sideChat "BATTLEFIELD STATUS UPDATE";
    	[west, "HQ"] sideChat "We have " + str _profilesBySide + " units currently deployed in the AO. Our reinforcement pool currently stands at " + str _currentBLUFORForcepool + ".";
    
    		if (_currentBLUFORForcepool < 20) then {
    			[west, "HQ"] sideChat "Our reinforcement pool is low soldier!";
    		};
    
    		if (_currentBLUFORForcepool > 100) then {
    			[west, "HQ"] sideChat "We have a surplus of reinforcements. Put them to work soldier!";
    		};
    
    };

    The problem

    The error I get is _currentBLUFORForcepool and _profilesBySide are undefined, even though they are defined at the top of the file?

    I really appreciate anyone who can help me with this :)

    Thanks all!

  2. Edited 4 months ago by marceldev89

    You'll need to move the _profilesBySide and _currentBLUFORForcepool stuff within the while loop. You'll also have to wait for ALiVE to have finished initializing before the while loop with

    waitUntil {player getvariable ["alive_sys_player_playerloaded",false]};

    or

    waitUntil {ALIVE_main getVariable ["startupComplete", false]};

    or

    waitUntil {ALIVE_require getVariable ["startupComplete", false]};

    ...

  3. Tupolov

    Aug 7 Administrator

    Would it not be better to just include this information in the tablet somewhere? That way players can get the information on demand and avoids a possible performance hogging while loop.

  4. Thanks for the response guys.

    I'll give that a try marceldev89, thanks!

    Yeah that would be cool Tupolov. Can mission makers influence what appears on the tablet, or do you mean for a future ALiVE update?

    Some kind of battle report screen would be a nice addition, showing information such as the number of objectives in the mission, which faction controls how many etc (raw numbers and a percentage breakdown etc). I know we can see the objectives on the intel screen but I don't believe it gives any raw numbers.

    It would be a nice addition for stats junkies at least :D

 

or Sign Up to reply!