Jump to content
  • 0

Donator- / Adminskins Issues in server_playerlogin.sqf


VentZer0

Question

Hello,
I am currently working on a method to make it possible for admins (or maybe even donators) to spawn in the skin of their choice.
But I've run into a wall here. I get weird errors that make no sense whatsoever.

private ["_isInfected","_doLoop","_hiveVer","_isHiveOk","_playerID","_playerObj","_primary","_key","_charID","_playerName","_backpack","_isNew","_inventory","_survival","_model","_mags","_wpns","_bcpk","_config","_newPlayer"];
AdminNewspawn = ["10419590","94149318"];
_playerID = _this select 0;
_playerObj = _this select 1;
_playerName = name _playerObj;
if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
if (isNil "sm_done") exitWith {diag_log ("Login cancelled, server is not ready. " + str(_playerObj));};
if (count _this > 2) then {dayz_players = dayz_players - [_this select 2];};
//Variables
_inventory = [];
_backpack = [];
_survival = [0,0,0];
_isInfected = 0;
_model = "";
if (_playerID == "") then {_playerID = getPlayerUID _playerObj;};
if ((_playerID == "") || (isNil "_playerID")) exitWith {diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");};
diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
//Do Connection Attempt
_doLoop = 0;
while {_doLoop < 5} do {
	_key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
	_primary = _key call server_hiveReadWrite;
	if (count _primary > 0) then {
		if ((_primary select 0) != "ERROR") then {
			_doLoop = 9;
		};
	};
	_doLoop = _doLoop + 1;
};
if (isNull _playerObj || !isPlayer _playerObj) exitWith {diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));};
if ((_primary select 0) == "ERROR") exitWith {diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];};
//Process request
_newPlayer = _primary select 1;
_isNew = count _primary < 7; //_result select 1;
_charID = _primary select 2;
#ifdef DZE_SERVER_DEBUG
diag_log ("LOGIN RESULT: " + str(_primary));
#endif
/* PROCESS */
_hiveVer = 0;
if (!_isNew) then {
	//RETURNING CHARACTER		
	_inventory = _primary select 4;
	_backpack = _primary select 5;
	_survival =	_primary select 6;
	_model = _primary select 7;
	_hiveVer = _primary select 8;
	if (!(_model in AllPlayers)) then {_model = "Survivor2_DZ";};
} else {
	if (DZE_PlayerZed) then {
		_isInfected = _primary select 3;
	} else {
		_isInfected = 0;
	};
	_model = _primary select 4;
	_hiveVer = _primary select 5;
	if (isNil "_model") then {
		_model = "Survivor2_DZ";
	} else {
		if (_model == "") then {
			_model = "Survivor2_DZ";
		};
	};
	//Record initial inventory only if not player zombie 
	if(_isInfected != 1) then {
		_config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
		_mags = getArray (_config >> "magazines");
		_wpns = getArray (_config >> "weapons");
		_bcpk = getText (_config >> "backpack");
		if(!isNil "DefaultMagazines") then {_mags = DefaultMagazines;};
		if(!isNil "DefaultWeapons") then {_wpns = DefaultWeapons;};
		if(!isNil "DefaultBackpack") then {_bcpk = DefaultBackpack;};
		//_randomSpot = true;
		//Wait for HIVE to be free
		_key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
		_key call server_hiveWrite;
	};
};
//diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj) + " at location: " + (getPosATL _playerObj));
_isHiveOk = false;
if (_hiveVer >= dayz_hiveVersionNo) then {_isHiveOk = true;};
if (worldName == "chernarus") then {([4654,9595,0] nearestObject 145259) setDamage 1;([4654,9595,0] nearestObject 145260) setDamage 1;};
if ((getPlayerUID player) in AdminNewspawn) then {
	if ((_model = "Survivor2_DZ") && (_playerID = "10419590")) then {_model = "BAF_Soldier_Officer_MTP";};
	if ((_model = "Survivor2_DZ") && (_playerID = "94149318")) then {_model = "UN_CDF_Soldier_Officer_EP1";};
};
dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
(owner _playerObj) publicVariableClient "dayzPlayerLogin";



Down in line #83 "if (_playerID in AdminNewspawn) then {" , the RPT file gives out an error stating expression error its apparently missing an ")"  though the if-statement is just as it should be.
I was able to make Adminloadouts using the same method without ANY errors.

Would be much apprechiated if someone could test this on their server, and see if it happens to produce an error.

Link to comment
Share on other sites

25 answers to this question

Recommended Posts

  • 0

Just a shot in the dark here but you are setting variables in your boolean statement instead of comparing them.  In C++ or C#, this would return a true but in arma2 I think it returns an error

 

 

= != ==

 

a = 1; // set a to 1

a == 1; //return true if a is equal to 1

 

your code

if ((_model = "Survivor2_DZ") && (_playerID = "10419590")) then {_model = "BAF_Soldier_Officer_MTP";};
if ((_model = "Survivor2_DZ") && (_playerID = "94149318")) then {_model = "UN_CDF_Soldier_Officer_EP1";};

should be

if ((_model == "Survivor2_DZ") && (_playerID == "10419590")) then {_model = "BAF_Soldier_Officer_MTP";};
if ((_model == "Survivor2_DZ") && (_playerID == "94149318")) then {_model = "UN_CDF_Soldier_Officer_EP1";};

Edit: also, I don't think this will be enough to spawn in with the skin.  I'd link you my player_login.sqf but I'm holding my cards close to my chest.

 

You want to set the model value in the "if(_isInfected != 1) then {" block

Link to comment
Share on other sites

  • 0

one thing, if you're on 1.63 getPlayerUID will return the steamID, I believe getPlayerUIDOld will retrieve the UID's that you have in the brackets. Also, if you're using 1051 why not just use 

if ((getPlayerUID player) in ["xxx"]) then { DZE_DefaultSkin = [["maleskin"],["femaleskin"]]; };

in the init.sqf

Link to comment
Share on other sites

  • 0

Also, the issue with your script might be here : 

	if ((_model = "Survivor2_DZ") && (_playerID = "10419590")) then {_model = "BAF_Soldier_Officer_MTP";};
	if ((_model = "Survivor2_DZ") && (_playerID = "94149318")) then {_model = "UN_CDF_Soldier_Officer_EP1";};

try doing 

	if ((_model = "Survivor2_DZ") && ((_playerID) = "10419590")) then {_model = "BAF_Soldier_Officer_MTP";};
	if ((_model = "Survivor2_DZ") && ((_playerID) = "94149318")) then {_model = "UN_CDF_Soldier_Officer_EP1";};
Link to comment
Share on other sites

  • 0

you cant use "player" in a serverside script.

 

but im sure its parsed through in there somewhere (_playerID i guess) ... however, it wont work changing the model there as it is changed again somewhere in player_monitor.fsm.

 

I assure you I change models through player_monitor.sqf regularly.  However I do it dynamically based on db calls.

Link to comment
Share on other sites

  • 0

I assure you I change models through player_monitor.sqf regularly.  However I do it dynamically based on db calls.

 

not sure what you are trying to say here?

 

player_monitor.sqf is like 7 lines i think and the file he is showing is server_playerlogin.sqf.

 

however his line 83 looks like this:

if ((getPlayerUID player) in AdminNewspawn) then {

and that wont work in a serverside script, it should be something like:

if ((getPlayerUID _playerObj) in AdminNewspawn) then {

but it still wont work changing it here serverside, when it is changed again clientside in player_monitor.fsm before the player spawns.

Link to comment
Share on other sites

  • 0

one thing, if you're on 1.63 getPlayerUID will return the steamID, I believe getPlayerUIDOld will retrieve the UID's that you have in the brackets. Also, if you're using 1051 why not just use 

if ((getPlayerUID player) in ["xxx"]) then { DZE_DefaultSkin = [["maleskin"],["femaleskin"]]; };

in the init.sqf

because the skins i want to use are not available as clothing parcels which the default skin thingy of 1.0.5 needs

Link to comment
Share on other sites

  • 0

Just a shot in the dark here but you are setting variables in your boolean statement instead of comparing them.  In C++ or C#, this would return a true but in arma2 I think it returns an error

 

 

= != ==

 

a = 1; // set a to 1

a == 1; //return true if a is equal to 1

 

your code

if ((_model = "Survivor2_DZ") && (_playerID = "10419590")) then {_model = "BAF_Soldier_Officer_MTP";};
if ((_model = "Survivor2_DZ") && (_playerID = "94149318")) then {_model = "UN_CDF_Soldier_Officer_EP1";};

should be

if ((_model == "Survivor2_DZ") && (_playerID == "10419590")) then {_model = "BAF_Soldier_Officer_MTP";};
if ((_model == "Survivor2_DZ") && (_playerID == "94149318")) then {_model = "UN_CDF_Soldier_Officer_EP1";};

Edit: also, I don't think this will be enough to spawn in with the skin.  I'd link you my player_login.sqf but I'm holding my cards close to my chest.

 

You want to set the model value in the "if(_isInfected != 1) then {" block

well, going to see if that works. please dont tease me with your version if you don't want to share it :P

I disabled the whole playerzed stuff, _isInfected is always 0

Link to comment
Share on other sites

  • 0

not sure what you are trying to say here?

 

player_monitor.sqf is like 7 lines i think and the file he is showing is server_playerlogin.sqf.

 

however his line 83 looks like this:

if ((getPlayerUID player) in AdminNewspawn) then {

and that wont work in a serverside script, it should be something like:

if ((getPlayerUID _playerObj) in AdminNewspawn) then {

but it still wont work changing it here serverside, when it is changed again clientside in player_monitor.fsm before the player spawns.

lol you're right.  Too much ginger ale tonight... was thinking player_login.sqf

Link to comment
Share on other sites

  • 0

ok it works in a way.

If I die and respawn, select gender etc ... i spawn in as normal survivor, if I relog i spawn as the skin I want to have.
The gear however is not working correctly yet.

I guess I need to fiddle around in the player_monitor.fsm

Link to comment
Share on other sites

  • 0

ok it works in a way.

If I die and respawn, select gender etc ... i spawn in as normal survivor, if I relog i spawn as the skin I want to have.

The gear however is not working correctly yet.

I guess I need to fiddle around in the player_monitor.fsm

did you ever get that to work? I'm doing something similar and ran into a wall. All works until I die.

Link to comment
Share on other sites

  • 0

did you ever get that to work? I'm doing something similar and ran into a wall. All works until I die.

yes I got it work basically you need to alter ALL the skin assigning parts in both files, player_setup.sqf and player_monitor.fsm, let it check for playerUID and according to that assign a specific model. messy but it works.

its better to use the ESS system thats the enhanced spawn system, lets you choose your spawn location and class/loadout, which can all be modified pretty easily.

http://opendayz.net/threads/release-ess-enhanced-spawn-selection.19998/

Link to comment
Share on other sites

  • 0

yes I got it work basically you need to alter ALL the skin assigning parts in both files, player_setup.sqf and player_monitor.fsm, let it check for playerUID and according to that assign a specific model. messy but it works.

its better to use the ESS system thats the enhanced spawn system, lets you choose your spawn location and class/loadout, which can all be modified pretty easily.

http://opendayz.net/threads/release-ess-enhanced-spawn-selection.19998/

I'm trying to incorporate random(ish) loadouts into playerLogin, and it's happening just as you say. I already edited player_monitor.fsm, will take a look at player_setup. As of right now, it only works the very first time you log in, if you dont completely exit and come back in you wont get a loadout.

Link to comment
Share on other sites

  • 0

U do realise that a default feature in epoch?

Who said I was doing this in epoch? Also, it's not random unless you make it.  I'm testing it on epoch (my test server is epoch and i'm too lazy to reconfigure) but ultimately it's for my buddies overwatch server, the one time I asked him to test it live, it did the exact same thing I described above.

Link to comment
Share on other sites

  • 0

Who said I was doing this in epoch? Also, it's not random unless you make it.  

 

Well it's the official Epoch forums ( so i expect anything where epoch is the base structure is ) ^^.

 

2nd, it is random:

 DZE_DefaultSkin = [["maleskin","maleskin2"],["femaleskin","femaleskin2"]];

It will chose RANDOMly ^^ one of the skins ( according u are (fe)male).

 

And yes, for overwatch u would do overwatch coding. their server structure is abit different.

 

DZE = DayZ Epoch variables.

Link to comment
Share on other sites

  • 0

Well it's the official Epoch forums ( so i expect anything where epoch is the base structure is ) ^^.

 

2nd, it is random:

 DZE_DefaultSkin = [["maleskin","maleskin2"],["femaleskin","femaleskin2"]];

It will chose RANDOMly ^^ one of the skins ( according u are (fe)male).

 

And yes, for overwatch u would do overwatch coding. their server structure is abit different.

 

DZE = DayZ Epoch variables.

you replied to my comment, when you meant to reply to VentZer0 then. I don't care / need to randomize their skin, as that's easy to do anyways. Also, last I checked that variable doesn't work 100%. I'm talking loadouts, not skin buddy.

Link to comment
Share on other sites

  • 0

 

then add some BIS select randoms on the following vars

DefaultMagazines = 
DefaultWeapons =
DefaultBackpack = 

yeah, cause that'd work in overwatch. What you seem to not understand is that i'm testing this on epoch without the pre-created vars for use in other mods. The reason i'm not testing on overwatch etc is because I don't have an overwatch server and it's a pain to completely re-do.

Link to comment
Share on other sites

  • 0

.............................

 

i lolled reading that.. What does that has to do with it?

has do to with this : DZE_DefaultSkin = [["maleskin"],["femaleskin"]];

afaik you need to put in the skinparcel names like 'skin_soldier_dz'

but hey glad to amuse you

 

Link to comment
Share on other sites

  • 0

has do to with this : DZE_DefaultSkin = [["maleskin"],["femaleskin"]];

afaik you need to put in the skinparcel names like 'skin_soldier_dz'

but hey glad to amuse you

 

 

ya but since u aer changing the player_monitor.fsm already, do the following:

  "	if (dayz_selectGender == ""Survivor2_DZ"") then {" \n
       "		_rand = (DZE_defaultSkin select 0) call BIS_fnc_selectRandom;" \n
       "		_model = _rand; //MALE" \n
       "		if (_model == """") then {" \n
       "		_model = dayz_selectGender;" \n
       "		};" \n
       "	} else {" \n
       "		_rand = (DZE_defaultSkin select 1) call BIS_fnc_selectRandom;" \n
       "		_model = _rand; //FEMALE" \n
       "		if (_model == """") then {" \n
       "			_model = dayz_selectGender;" \n
       "		};" \n
       "	};" \n

then u can use it without the Skin_

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...