Jump to content
Sign in to follow this  
skimmer8824

Dedicated server not responding to publicVariable

Recommended Posts

Hi, I have been trying to get this simple piece of code to work. It is properly executed in SP and on a listen server; however, it fails to work on a dedicated server. The code gives the player an action to print "Hello" to all clients. What have I overlooked? Thanks!

init.sqf:

// init.sqf
waituntil {!(isnil "bis_fnc_init")};

showChat true;
enableSaving [False, False];

gc_function = {(_this select 0) globalchat (_this select 1)};
sayHello = FALSE; 
publicVariable "sayHello";

if(!isDedicated) then
{
player addAction ["Say Hello","talk.sqf"];
};

if (isServer) then
{    
while {true} do
{
	waitUntil {sayHello};
	[[player, "Hello"], "gc_function"] call BIS_fnc_mp;
	sayHello = FALSE;
	publicVariable "sayHello";
};
}; 

talk.sqf:

sayHello = TRUE;
publicVariable "sayHello"; 

Share this post


Link to post
Share on other sites

use addPublicVariableEventHandler instead of non-sleep cycle.

i.e.:

// init.sqf 
waituntil {!(isnil "bis_fnc_init")}; 

showChat true; 
enableSaving [False, False]; 

gc_function = {(_this select 0) globalchat (_this select 1)}; 

if(!isDedicated) then 
{ 
   player addAction ["Say Hello","talk.sqf"]; 
}; 

if (isServer) then 
{     
   "sayHello" addPublicVariableEventHandler {
	if (_this select 1) then {
		[[player, "Hello"], "gc_function"] call BIS_fnc_mp;
		sayHello = false;
	};
};
};

talk.sqf:

sayHello = true;
publicVariableServer "sayHello";

Share this post


Link to post
Share on other sites

Thanks for the quick reply. This works in a listen server environment, but I still can't get it to work on a dedicated server.

The RPT file contains repeated entries of "Handler not present".

Edited by skimmer8824

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  

×