Jump to content
Sign in to follow this  
dayz10k

Multiplayer: Help creating a serverwide message upon script execution

Recommended Posts

I'm trying to fire an event (either serverwide or using a 4km "local" radius), but having no luck--where ever I put it, the script seems to crap out after.

I have tried using rHINT, rSPAWN (a titletext), rSPAWN (BIS_fnc_infoText), etc

This would be based upon one of the refuel scripts (scroll wheel->refuel) when at a gas station.

can anyone help me with the syntax?

thanks!

---------- Post added at 10:19 ---------- Previous post was at 10:18 ----------

script code

private ["_target", "_caller", "_id", "_isNearFeed"]; 

_target = _this select 0; 
_caller = _this select 1; 
_id = _this select 2; 

if (isNil "ib_refueling_in_progress") then { ib_refueling_in_progress = false; }; 

if (!ib_refueling_in_progress) then  
{ 
       _isNearFeed = count ((position _caller) nearObjects ["Land_A_FuelStation_Feed", 10]) > 0; 

       if (!_isNearFeed) then 
       { 
               titleText ["You must be near a fuel station pump.", "PLAIN DOWN", 3]; 
               titleFadeOut 3; 
       } 
       else 
       { 
               ib_refueling_in_progress = true; 

               titleText ["Refueling", "PLAIN", 3]; 

               while {(vehicle _caller == _target) and (local _target)} do 
               {  
                       private ["_velocity", "_fuel", "_pos"]; 

                       _velocity = velocity _target; 
                       _fuel = fuel _target;
                       _pos = position _target;

                       if ((_velocity select 0 > 1) or (_velocity select 1 > 1) or (_velocity select 2 > 1)) exitWith { };
                       if (_position select 2 > 0.5) exitWith {}; 
                       if (_fuel >= 1.0) exitWith { }; 

                       sleep 0.5; 

                       _fuel = _fuel + 0.007; 

                       if (_fuel >= 1.0) then { _fuel = 1.0; }; 

                       _target setFuel _fuel; 
               }; 

               titleFadeOut 1; 

               ib_refueling_in_progress = false; 
       }; 
};

---------- Post added at 10:22 ---------- Previous post was at 10:19 ----------

Things I've tried

[nil,nil,rHINT,"You hear the rumblings of a gas pump in the distance."] call RE;

[nil, nil, rSPAWN, [], {rHINT,"You hear the rumblings of a gas pump in the distance."}] call RE;

[nil,nil,,rTITLETEXT,format["You hear the rumblings of a gas pump in the distance.", (name _caller)],"PLAIN DOWN"] call RE;

and using rSPAWN to call BIS_fnc_infoText

Share this post


Link to post
Share on other sites

have you got the functions module down so that you can use the Multiplayer frame work?

the script seems to crap out after.
at what point - does the refueling work? or is the hint just not working? have you tried hinting locally to the caller? does that work?

[nil,nil,rHINT,"You hear the rumblings of a gas pump in the distance."] call RE; -- that should work regardless where it is placed.

You can always try the addPublicVariableEventHandler approach to have the script run for everyone - but you will also need to hint for the person calling the script.

Share this post


Link to post
Share on other sites

without the hint, etc it works (obviously).

I have tried entering it once the refueling state is set to true

               ib_refueling_in_progress = true; 

               titleText ["Refueling", "PLAIN", 3]; 

as well as in the /while/ loop as it is actively refueling

while {(vehicle _caller == _target) and (local _target)} do 

in either case, the refueling seems to stop (meaning I may have to spam scroll wheel for the addaction repeatedly) or fail.

Share this post


Link to post
Share on other sites

You need to make sure the Mp framework has been initialized before using it with waitUntil{!(isNil "BIS_MPF_InitDone")};. And also, if you're using bis_fnc_info text you need to make sure the functions module is initilized by waitUntil{!(isNil "BIS_Fnc_Init")};. Ofcourse place a functions module on the map aswell.

Share this post


Link to post
Share on other sites

this is within DayZ multiplayer, so I believe MPF is already in place and initialized in the server-side PBO.

I'll take another look, though...other than that, does syntax look correct? and logic--am I causing any issues that might be a loop? Was hoping for a small message right when someone clicks the addAction "refuel" and

ib_refueling_in_progress = true;

Thanks!

Share this post


Link to post
Share on other sites

Don't assume anything you aren't sure of. If you need something initialized, make sure it is initialized before you use it. Otherwise you'll never know if this is the problem or perhaps the problem is something else. As far as I know, the waitUntil command only delays the script by 1 frame if the condition is true and not super-complicated.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×