Jump to content
Sign in to follow this  
dixon13

Need help - execute script located on server

Recommended Posts

I have a script that is located in the userconfig folder of the server folder that I want to execute and broadcast to clients. I am doing this for security reasons as the file that I want to execute contains Player UID's. Now my problem is that I don't think the script is being broadcasted to clients so the clients don't see the script. Here is what I have so far...

Clients - init.sqf:

diag_log format["########################%1########################",missionName];
diag_log format["Executing init.sqf"];

waitUntil {!(isNull player)};

"playerUID" addPublicVariableEventHandler {
_value = _this select 1;
hint format["value of playerUID = %1",_value];
diag_log format["value of playerUID = %1",_value];
};

if (isServer) then {
null = [] execVM "\Userconfig\pubserver\MemberUIDs.sqf";
};

Server file - Userconfig\pubserver\MemberUIDs.sqf:

waitUntil {(getPlayerUID player) != ""};

_uid = getPlayerUID player;

playerUID = switch(_uid)do 
{  
case "############": // player-name (Template)
	{
	hint format["Hello %1 Welcome", name player];

player setRank "SERGEANT"; // PRIVATE (Recruit/nonmember), CORPORAL(Member), SERGEANT (PFC), LIEUTENANT (SGT), CAPTAIN (SSG), MAJOR (SFC) or COLONEL (2LT)

	};

	default
   {
	hint format["Hello %1 Welcome To The 71st Special Operations Group. Please visit our website for more information.", name player];	
player setRank "PRIVATE";
	};
};
playerUID;
publicVariable "playerUID";
diag_log format["value of playerUID = %1",playerUID];

I don't get anything on the client side in my rpt file even though I used...

diag_log format[bla-blah];

I am not getting any errors either.

Share this post


Link to post
Share on other sites

waitUntil {(getPlayerUID player) != ""};

If you run that on the server, it will NEVER happen.

Share this post


Link to post
Share on other sites

ah ok thanks will test this. Didn't think about that.

---------- Post added at 15:48 ---------- Previous post was at 15:34 ----------

waitUntil {(getPlayerUID player) != ""};

If you run that on the server, it will NEVER happen.

Removed that and still the same problem exists and still nothing in my rpt on both my computer and the server's.

Share this post


Link to post
Share on other sites

Do you realize that there is no "player" object on a dedicated Server?

There are two ways in which you could do this.

1. by transmitting the list of UIDs to all clients and let the check run locally for them when they join

2. using a onPlayerConnected eventhandler on the server, do the check there and then transmit your message to the client via BIS_fnc_MP

Edited by Tajin

Share this post


Link to post
Share on other sites
Do you realize that there is no "player" object on a dedicated Server?

Totally just realized that. Hmmm... this script is going to have to get more complicated lol. Thanks for the help. I will post findings and/or solutions if I can come up with one.

Share this post


Link to post
Share on other sites

You could use the initPlayerServer.sqf file, passed arguments are player and isJIP:

_player = (_this select 0);
_uid = getPlayerUID _player;

playerUID = switch(_uid)do 
{  
case "############": // player-name (Template)
	{
	hint format["Hello %1 Welcome", name _player];

_player setRank "SERGEANT"; // PRIVATE (Recruit/nonmember), CORPORAL(Member), SERGEANT (PFC), LIEUTENANT (SGT), CAPTAIN (SSG), MAJOR (SFC) or COLONEL (2LT)

	};

	default
   {
	hint format["Hello %1 Welcome To The 71st Special Operations Group. Please visit our website for more information.", name _player];	
_player setRank "PRIVATE";
	};
};
playerUID;
publicVariable "playerUID";
diag_log format["value of playerUID = %1",playerUID];

Share this post


Link to post
Share on other sites

Just an update I haven't found any success yet with the server side script talking to the client. I haven't had much time either been busy with school and work, but I am still investigating this.

Share this post


Link to post
Share on other sites
Just an update I haven't found any success yet with the server side script talking to the client. I haven't had much time either been busy with school and work, but I am still investigating this.

Here you go this guy was having somewhat similar issues, I would read all posts in the thread as there are some other tidbits of key information that would help you in further usage of files located on the server:

http://forums.bistudio.com/showthread.php?185835-Draw-Arguments-from-txt-file

Post #18 especially:

http://forums.bistudio.com/showthread.php?185835-Draw-Arguments-from-txt-file&p=2823842&viewfull=1#post2823842

Edited by JShock

Share this post


Link to post
Share on other sites
Here you go this guy was having somewhat similar issues, I would read all posts in the thread as there are some other tidbits of key information that would help you in further usage of files located on the server:

http://forums.bistudio.com/showthread.php?185835-Draw-Arguments-from-txt-file

Post #18 especially:

http://forums.bistudio.com/showthread.php?185835-Draw-Arguments-from-txt-file&p=2823842&viewfull=1#post2823842

Thanks this is exactly what I was looking for. I will test this out when I get a chance again.

Share this post


Link to post
Share on other sites
Thanks this is exactly what I was looking for. I will test this out when I get a chance again.

It works, I tested this when I first read that post. Now you just have to make sure your script will run okay

Share this post


Link to post
Share on other sites

Ok I have not gotten this to work yet. This is what I have so far...

Init.sqf

private["_MemberUIDs"];
_uid = getPlayerUID player;

_MemberUIDs = [];
_MemberUIDs = call compile preprocessFileLineNumbers "\Userconfig\71stsog_serv\71st_Rank.sqf";

hint format["_MemberUIDs = %1",_MemberUIDs];
diag_log format["_MemberUIDs = %1",_MemberUIDs];

if (_uid in _MemberUIDs) then {
hint "You are a member...";
} else {
hint "You are not a member...";
};

71st_Rank.sqf

_MemberUIDs = [
#############, 
#############, 
#############  
];
_MemberUIDs;

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  

×