Jump to content

[Fix/Workaround] Character/Gender Selection Screen


jahangir13

Recommended Posts

Hi,

 

Here I provide a fix/workaround for the Gender/Character Selection Screen issue which does not shop up in the Epoch Linux Version.

I call it Workaround as I hope that Devd will take a look into this and update the LInux Server files so that this is not needed anymore. Until this happens I am using this as it is working very well so far.

 

 

gender_selection.jpg

 

Reason is that the condition in dayz_code.pbo / player_monitor.fsm for showing the screen (_isNew = true and _IsInfected = 0) is always not met in our version.

 

As always: Take a backup of your mission.pbo and your dayz_server.pbo as well as of the database and cache files before you change anything!!

 

This cannot be mentioned often enough...I am also very lazy and crashed my server completely yesterday and needed 2h to figure out that the problem was ;)

 

 

Instructions:

 

1.)

This is the link to the modified server_playerLogin.sqf (which can be found in dayz_server.pbo in folder compile):

http://pastebin.com/9Y1fMgwp

 

Copy this over the original one and repack the pbo and upload it to the server.

 

2.)

I did not update/change anything in the code of the writer.pl and I hoped that this will not get neccessary. However, I've changed 2 things on the files Devd provided on the file system:

 

a.)

The start gear/custom loadout in the constants section of writer.pl I've changed to the following:

INVENTORY => '[[],[]]',
BACKPACK  => '["",[],[]]',
MODEL     => '"Survivor2_DZ"'

b.)

In the cache/players directory I've changed the content of default.sqf to the following (I've kept default-char.sqf as it was):

["PASS",false,"1",[],[[],[]],["",[],[]],[0,0,0],"Survivor2_DZ",0.96]

3.)

To define a custom loadout/start gear I've used the settings the normal Epoch server provides for that. The code is in the server_playerLogin.sqf already, so why not use that.

Open your init.sqf file from your mission pbo and enter the following lines somewhere in the variables section.

// loadout
DefaultMagazines = ["ItemBandage","ItemSodaCoke","FoodCanBakedBeans"]; 
DefaultWeapons = ["ItemCompass","ItemRadio","ItemToolbox","ItemMachete"]; 
DefaultBackpack = "DZ_TerminalPack_EP1"; 
DefaultBackpackWeapon = "";

Change the values to your liking. This is the custom loadout the player will get if he dies and respawns newly.

Repack the mission pbo and upload it to the server.

 

This should be everything needed. Restart the server to load and execute the modified pbo files.

 

I needed quite a bit of time to figure out how it's possible to achieve this and I still have some problems to understand e.g. why 2 default sqf files in the cache/players dir are needed and in which order what is called. To be honest...I do not really understand why cache files are needed at all. So there is always a better way, I guess, but this works for me.

 

How I've tested this:

I stopped the server by killing the process and deleted the directories in the cache/players dir where the player information is stored (the folders, NOT the files default.sqf and default-char.sqf).

I've also emptied the tables Character_Data, Player_DATA and Player_LOGIN in the database to avoid issues from existing data.

 

Tests:

1.) Logged in, got the gender selection screen...start gear was there. I consumed a coke and logged out to desktop. Logged in again and the inventory was as expected.

2.) I found some Zeds to kill me, went back to the lobby and logged out completely again. I logged in again, after the lobby the gender selection appeared. Inventory was the defined custom loadout as expected. I drank a coke again, packed some stuff into the backpack and logged out again.

3.) Relogged, everything regarding inv still ok. Was looking for some zombies to kill me. This time I went back to the lobby and entered the mission again from there (without logging out completely). This also worked.

 

I did this for both man and woman.

 

Issues:

1.) I am using a mechanism which takes me automatically back to the lobby after dying (without pressing ESC and pressing Abort in the main menu). I am not 100% sure but if I remember correctly something with the inventory went wrong here. I need to check this again.

--> Works

 

2.) I did everything with a 'fresh install'. As I said...deleted player cache files and player/character DB entries. If someone is using the server from scratch this works very well.

 

I am not sure if everything works correctly if changing the files as mentioned above and already having entries in the Character_DATA table ad cache files. I don't have a second server whith the old setup.

Maybe someone can send me a screenshot (or in text) how an entry in Character_DATA in the original version on GitHub looks like if a player dies and the player logged out afterwards.

 

With the changes above this now looks like this:

 

Character_DATA1.jpg

 

I use one of the empty fields ("[]") to check if the player is new or not. I do not exactly know which one that is (in server_playerLogin.sqf it's "_isNew =         count (_primary select 3) < 1;").

 

If a player dies and logs out you can see a new line in the Character_DATA in the database with Alive=1 (The old line with the dead Character has then been changed to Alive=0).

I am not 100% sure if existing character data causes issues but I think so. I've created a trigger which changes the values for a new Character_DATA line if Alive=1 to change the other values so that it's looking like in my screenshot above.

The trigger could be used until all the players died once. I think after that everything should be ok and the trigger can be deleted again.

 

I use phpMyAdmin and to create the trigger, login, select your database, click on table Character_DATA, then go to the sql tab and enter the code of the trigger and press ok.

DELIMITER ;
DROP TRIGGER IF EXISTS char_gender_fix;
DELIMITER $$
CREATE TRIGGER char_gender_fix
BEFORE INSERT ON Character_DATA
FOR EACH ROW BEGIN
DECLARE oldCharacterID INT;
DECLARE oldHumanity INT;
IF (NEW.Alive = 1) THEN
	
	SELECT CharacterID, Humanity INTO oldCharacterID, oldHumanity
	FROM `Character_DATA` 
	WHERE PlayerUID = NEW.PlayerUID
	AND Alive = '0'
	ORDER BY CharacterID Desc
	LIMIT 1;
	SET NEW.Inventory = '[[],[]]';
  	SET NEW.Backpack = '["",[],[]]';
  	SET NEW.Worldspace = '[]';
  	SET NEW.Medical = '[]';
  	SET NEW.KillsZ = 0;
  	SET NEW.HeadshotsZ = 0;
  	SET NEW.DistanceFoot = 0;
  	SET NEW.Duration = 0;
  	SET NEW.CurrentState = '[]';
  	SET NEW.KillsH = 0;
  	SET NEW.Model = '"Survivor2_DZ"';
  	SET NEW.KillsB = 0;
	IF (oldCharacterID IS NOT NULL) THEN
          SET NEW.Humanity = oldHumanity;
        ELSE
          SET NEW.Humanity = 2500;
        END IF;
END IF;
END$$
DELIMITER ;

Every time a new line is inserted here now with Alive=1 the above code will be triggered and changes the values before the insert takes place.

To check if the trigger has been created execute the sql statement.

SHOW TRIGGERS

To test the trigger you can execute the following sql statement:

INSERT INTO `Character_DATA` (`CharacterID`, `Alive`) VALUES (xxx,1);

...where xxx is a characterID you need to enter which is a number higher than the ones you already have there. You will see that the other values in the new line will be filled as shown above by the trigger.

 

In phpMyAdmin you can also find the trigger (which is bound to a table) here:

 

phpmyadmin_trigger1.jpg

 

It's needed that someone tests this on a test server with existing Character and Cache data.

 

Please give me some feedback if that works for you!

Feel free to ask any questions and I will try to help here.

 

Regards,

jahan.

 

P.S.: if you just want to get the selection screen you can change the condition in the file player_monitor.fsm in dayz_code.pbo / system (make it custom and add it to your mission);

class New_Character
        {
          priority = 5.000000;
          to="Gender_Selection";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_isNew && _isInfected == 0"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };

to:

class New_Character
        {
          priority = 5.000000;
          to="Gender_Selection";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isNew && _isInfected == 0"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };

("!" before _isNew ...it's bad to see). But you will get the gender selection screen now everytime you login, if you are dead or not which is not like it is intended.

Link to comment
Share on other sites

I noticed you missed out something

//Do Connection Attempt
_doLoop = 0;
while {_doLoop < 5} do {
    _key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
    diag_log (_key);
_key = format["\cache\players\%1\%2.sqf", MyPlayerCounter, _playerID];
diag_log ("LOAD PLAYER: "+_key);
_res = preprocessFile _key;
diag_log ("PLAYER CACHE: "+_res);
////////// settime for player
onPlayerConnected "[_id, _name] execVM ""\z\addons\dayz_server\custom\settime.sqf""";
onPlayerConnected "[_id, _name] execVM ""\z\addons\dayz_server\custom\settime.sqf

is not there by default, might want to remove that line for other people :)

Link to comment
Share on other sites

No, The player_login is completely different for windows, have you tried resetting your server.pbo and that might fix it

 

How do I do that ?

 

If you mean reset it back to default, I have custom stuff in there that I cannot lose.

 

its nothing that would have stopped the gender screen from showing up.

 

I did have the gender screen show up again but then died a few times and it hasnt shown up again.

Is there ahything that needs to trigger the gender screen to show up ?

Link to comment
Share on other sites

Yeah, Get a clean server.pbo from the website, and transfer over your buildings ect, you might have edited a file wrong, not too sure. also I'm not sure of the main trigger, I think its just if your not alive in the hive then it will show it 

Link to comment
Share on other sites

P.S.: if you just want to get the selection screen you can change the condition in the file player_monitor.fsm in dayz_code.pbo / system (make it custom and add it to your mission);

class New_Character
        {
          priority = 5.000000;
          to="Gender_Selection";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_isNew && _isInfected == 0"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };

to:

class New_Character
        {
          priority = 5.000000;
          to="Gender_Selection";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isNew && _isInfected == 0"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };

("!" before _isNew ...it's bad to see). But you will get the gender selection screen now everytime you login, if you are dead or not which is not like it is intended.

 

 

Its worth a shot trying what he did above, but I'm not too sure of the problems it will cause for windows, just make sure you backup

Link to comment
Share on other sites

I think for the windows version there should be other posts. But that should have been solved as far as i know. If iam right there is an solution by axecop in the other forums here. Maybe you try that.
But i think that happens due to your custom stuff. Add the 2 diag_log lines as i have them at the end of the server_playerLogin.sqf to check the values for _isNew and _isInfected. Isnew needs to be true and isInfected 0 to get the gender selection. If you have this values if you die and respawn you might have an timing issue as axecop described it.
or set _isNew = true; and _isInfected = 0; additionally to the place where the diag_logs from above are placed. So you would always get the gender screen (just for testing). If it does not show up or too short look to axecops post as mentioned.


@deanreid: yes you are right (EDITed the link in the OP). This from an earlier post which fixes for me that all players have more or less exactly the same time when they join the server. So its not still night for some and already day for others.
nobody ever answered to that ;) so maybe i am the only who had this pribem or who cares ;)
so i thought i let it in here. Just comment it out. I add a remark in the post when i'm home. Thanks.

Again:
The op can only be seen as a workaround until devd adapts how players/characters are written to the db and cache files.
I also tried to create a workaround to be able to play as a zombie.
problem is that the information which i can get from the medical string in xxxxx-char.sqf in the player cache directory is needed already in server_playerLogin.sqf but will be read in server_playerSetup.sqf where it's already too late.
A workaround here would be too much to change and confusing i guess. Maybe i find an easier way which is worth to be posted.
I dont know yet for what the second value (false) is used in the xxxxx.sqf player cache file. Maybe thats used for that.

Link to comment
Share on other sites

Ah ok, thanks.
Did not know that you have any ,))

Could you please try that one, before I update it above? I've checked the syntax and tested this once. Should work now to take the humanity over to the new Character.

DELIMITER ;
DROP TRIGGER IF EXISTS char_gender_fix;
DELIMITER $$
CREATE TRIGGER char_gender_fix
BEFORE INSERT ON Character_DATA
FOR EACH ROW BEGIN
DECLARE oldCharacterID INT;
DECLARE oldHumanity INT;
IF (NEW.Alive = 1) THEN
	
	SELECT CharacterID, Humanity INTO oldCharacterID, oldHumanity
	FROM `Character_DATA` 
	WHERE PlayerUID = NEW.PlayerUID
	AND Alive = '0'
	ORDER BY CharacterID Desc
	LIMIT 1;
	SET NEW.Inventory = '[[],[]]';
  	SET NEW.Backpack = '["",[],[]]';
  	SET NEW.Worldspace = '[]';
  	SET NEW.Medical = '[]';
  	SET NEW.KillsZ = 0;
  	SET NEW.HeadshotsZ = 0;
  	SET NEW.DistanceFoot = 0;
  	SET NEW.Duration = 0;
  	SET NEW.CurrentState = '[]';
  	SET NEW.KillsH = 0;
  	SET NEW.Model = '"Survivor2_DZ"';
  	SET NEW.KillsB = 0;
	IF (oldCharacterID IS NOT NULL) THEN
          SET NEW.Humanity = oldHumanity;
        ELSE
          SET NEW.Humanity = 2500;
        END IF;
END IF;
END$$
DELIMITER ;

This checkes if there is an old entry in Character_DATA for the same PlayerUID with Alive=0 and takes the last one from that (if more are available). If this line exists it takes the Humanity from there...if not it sets it to 2500.

Seems that I need to repeat some SQL here. It's really a pain to get the syntax right ;)

(Notice: You can only have 1 trigger for a specific type (here BEFORE INSERT).. If you already have another trigger of the same type you need to integrate one into the other. AFTER INSERT you can still have additionally.)

 

 

EDIT: replaced in the OP

Link to comment
Share on other sites

Hm, I think it should be available in a Linux version which should be able to handle all the things which are possible in the Windows version (my optinion ;) ). If someone wants to disable this he could go to the right file (player_monitor.fsm) and change the condition so that it is never true and the screen does not appear anymore

Don't tell me that disabling this was just a click or something. It took me ages to figure out how to do it. ;)  I think it's not the best way how I did this...but at least it's working.

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...