Jump to content
Spatsiba

Grab info from external text file

Recommended Posts

Hey!

 

I'm trying to make a whitelist that's able to be updated whilst the server's running. So far I have this: 

Spoiler

### "whitelist.txt" located in the main game directory ###
  
adminUID = 
[
  "###",
  "###",
  "###"
];
pilotUID = 
[
  "###",
  "###",
  "###"
];
crewUID =
[
  "###",
  "###",
  "###"
];

 

 

Spoiler

### "whitelist.sqf" located in the missionfile executed by "execVM 'whitelist.sqf'" inside the "initPlayerLocal.sqf" file ###

if (isDedicated) exitWith {};
waitUntil {player == player};

_uid = getPlayerUID player;
_slot = vehiclevarname player;
call compile preprocessfile "\whitelist.txt"; 

//	Fill default items
execVM "scripts\whitelist\va\classes\default.sqf"; 


//	Whitelisted Slots.
if ((vehicle player) isKindOf "rhsusf_army_ocp_helipilot") then {
	if (_uid in pilotUID) then {
		execVM "scripts\whitelist\va\classes\pilot.sqf";
	} else {
		endMission "end1";
	};
};

if ((vehicle player) isKindOf "rhsusf_army_ocp_crewman") then {
	if (_uid in crewUID) then {
		execVM "scripts\whitelist\va\classes\crew.sqf";
	} else {
		endMission "end1";
	};
};


if ((vehicle player) isKindOf "rhsusf_socom_marsoc_cso") then {
	if (_uid in adminUID) then {
		execVM "scripts\whitelist\va\classes\operator.sqf";
	} else { 
		endMission "end1";
	};
};

//	Salmon Perks
if	(squadParams player select 0 select 0 == "Salmon") then {
	execVM "scripts\whitelist\va\classes\salmon.sqf";
} else {
	systemChat "To look tacticool";
	systemChat "Join The Tactical Salmon today!";
	systemChat "TacSalmon.me";
};

 

It works in single player but on the server it won't define "adminUID" etc etc.

Even if I use the debug on the server and do something like:

call compile preprocessfileLineNumbers "\whitelist.txt";
hint format ["%1", adminUID];

It won't work on the server. 

I've got -filePatching on the server too. 

 

Any help would be greatly appreciated. 

 

 

EDIT: I know the code isn't the greatest I'll optimise it when I get it working. It just won't work for now and I'm trying to make it as simple as possible. 

Also worth noting that I'm not a coder lol

 

EDIT2: It seems like the path is wrong. Is there anyway to check the logs for WHERE the game searches for "whitelist.txt"? 

Edited by Spatsiba
Additional info
  • Like 1

Share this post


Link to post
Share on other sites

.sqf

You can't use .txt without extension (I don't think - although loadFile Wiki states otherwise).

\ = Server root

How do you know it doesn't work? Is server dedicated or hosted? The hint won't show if dedicated. You need to remoteExec it or diag_log it for testing.

Take a look at Authority to see how I did it.

https://forums.bohemia.net/forums/topic/194184-authority-20-player-coop/?page=6&tab=comments#comment-3316572

  • Like 2

Share this post


Link to post
Share on other sites
On 2018-10-19 at 10:53 PM, HazJ said:

.sqf

You can't use .txt without extension (I don't think - although loadFile Wiki states otherwise).

\ = Server root

How do you know it doesn't work? Is server dedicated or hosted? The hint won't show if dedicated. You need to remoteExec it or diag_log it for testing.

Take a look at Authority to see how I did it.

https://forums.bohemia.net/forums/topic/194184-authority-20-player-coop/?page=6&tab=comments#comment-3316572

Thanks for the reply! I think it was all just me thinking the debug console provided with the game was capable of doing it. I've already came to the same conclusion but haven't tested it yet. I'll look into it and come back to you when done :) 

Share this post


Link to post
Share on other sites

Atleast in all my tests. FilePatching only works when the file also exists inside a pbo. If the game doesn't find it in a PBO it thinks it doesn't exist. However if it finds it in a pbo and if filePatching is enabled, it then looks in the same path in the Arma directory and loads the file from there if it exists.

So you probably want to make a dummy pbo with a dummy file inside it.

 

On 19.10.2018 at 4:21 PM, Spatsiba said:

EDIT2: It seems like the path is wrong. Is there anyway to check the logs for WHERE the game searches for "whitelist.txt"? 

 

Arma directory\filepath.
So your example would be
Arma directory\\whitelist.txt
the double backslash seems weird.

  • Confused 1

Share this post


Link to post
Share on other sites

@Dedmen - I didn't have to do that. Sadly, you have to file patching enabled just to check if the file exists or not, let alone to make it work.

  • Like 1

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

×