Implementing a select - spawn system

HarryPearce

New Member
Hello,

I've been meaning to code in a custom, selective spawn system. It would work along the lines of opening the map on new character spawn, with temporary markers depicting the possible spawn locations. A player would then click on one of the available markers, setting the position of his character accordingly. I haven't managed to find anything using the search function, but it is possible I missed a thread on this matter.

I have the logic coded in, but I am having problems with recognizing the newly spawned character. I've tried setting a custom variable in the server_playerSetup.sqf in dayz_server.pbo/compile as such:
Code:
if (_randomSpot) then {
 
    private["_counter","_position","_isNear","_isZero","_mkr","_code","_omsc"];
    if (!isDedicated) then {
        endLoadingScreen;
    };
    _playerObj setVariable["RandomSpawn",true,true]; //my custom variable
    ...

And referring to this variable in a custom script file, executed from init.sqf of the mpmission file, as such:
Code:
waitUntil {!isNil ("dayzLoginRecord")};
 
_randomSpawn = player getVariable "RandomSpawn";
titleText[format["RS:%1",_randomSpawn],"PLAIN"];
 
if ((!isNil ("_randomSpawn")) and (_randomSpawn)) then {
...

However, this only works when the character is new AND the server is freshly restarted. Any other time the variable comes in as <null>.

I have limited understanding of the dayz character creation mechanism, and I am at a loss, trying to understand why the variable is valid only some of the time, as other variables are set in the same scope to the _playerObj object, including medical data, which are working as intended.

I am certain I am missing a crucial logical step somewhere in the dayz player/character creation processing. Can anyone shed some light on this subject? Thanks.
 
Have you tried setting/creating that player variable from the mission pbo instead of the server pbo?
 
Have you tried setting/creating that player variable from the mission pbo instead of the server pbo?
Well, no, I dont know, how to find out, from the mission pbo, if the character is new. In fact, i have no idea where is the client side of the character creation process.
 
First, the variable comes back null because dayzloginrecord is JIP'd. This means
waitUntil {!isNil ("dayzLoginRecord")}; immediately becomes true and _randomSpawn = player getVariable "RandomSpawn"; is ran BEFORE if (_randomSpot) then {


Second, you can probley copy and paste some code/dialogs from Orgins mod since they do the sort of thing you are looking to achieve.

Third, don't use dayzloginrecord lol
 
Third, don't use dayzloginrecord lol

Well, I am glad I am source of such great amusement. Nevertheless, this particular line of code I have copied from a code snippet, dealing with on-spawn camera interaction. As I understood it, loginRecord is a global variable, that gets initialized by server using publicVariable, and thus, the moment it is not nil, the character is already created.

Since this appears to not be the case, I used my custom variable as the wait condition, and it works. Thanks for the advice.
 
There were servers that already had this setup back in Dec. 2012

A screen would popup asking what area you would like to respawn.

If I recall it also displayed the names of the players near the areas.
 
Back
Top