Jump to content
  • 0

Only run script on new spawns.


MatthewK

Question

i've been trying to get a script in my mission folder to execute only if the player is a new spawn. But nothing is working so far.  It's very frustrating and I'm not sure if its because I'm using Parachute spawning or that Epoch uses different conditions to check if players are new spawn.  I'm using this at the moment, which should work but just doesn't.. :(

waitUntil {!isNil ("PVDZ_plr_LoginRecord")};
if (PVCDZ_plr_Login2 select 2) then
{

//Code for this script: https://gist.github.com/IT07/6210573

};

Any ideas? I've put a link to the script I'm embedding too.

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Where are you trying to put this code? 

 

If you are not having it in the init.sqf, as the installation instructions are giving you, then you will have issues making the script work. 

 

It should be in the Dedicated portion of the missions init.sqf: 

 

if (!isDedicated) then {                               <-----
	//Conduct Credit Style Info                    <-----
	[] execVM "Custom\Server_WelcomeCredits.sqf";  <-----
	//Conduct map operations
	0 fadeSound 0;
	waitUntil {!isNil "dayz_loadScreenMsg"};
	dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
	
	//Run the player monitor
	_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
	_playerMonitor = 	[] execVM "\z\addons\dayz_code\system\player_monitor.sqf";	

};

I dont know if you can put this into a sqf and execute it in the location above... but it could be something to explore? 

Link to comment
Share on other sites

  • 0

Where are you trying to put this code? 

 

If you are not having it in the init.sqf, as the installation instructions are giving you, then you will have issues making the script work. 

 

It should be in the Dedicated portion of the missions init.sqf: 

 

if (!isDedicated) then {                               <-----
	//Conduct Credit Style Info                    <-----
	[] execVM "Custom\Server_WelcomeCredits.sqf";  <-----
	//Conduct map operations
	0 fadeSound 0;
	waitUntil {!isNil "dayz_loadScreenMsg"};
	dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
	
	//Run the player monitor
	_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
	_playerMonitor = 	[] execVM "\z\addons\dayz_code\system\player_monitor.sqf";	

};

I dont know if you can put this into a sqf and execute it in the location above... but it could be something to explore? 

 

I'm doing exactly as the instructions say, but I'm just trying to add code to the script itself, to ONLY run if it detects the player is a new spawn.  So it loads that file above, then all I've done is add the code as in my example.. I hope that makes sense.. I didn't include the entire file as it was just going to waste screen space here :)

Link to comment
Share on other sites

  • 0

i've been trying to get a script in my mission folder to execute only if the player is a new spawn. But nothing is working so far.  It's very frustrating and I'm not sure if its because I'm using Parachute spawning or that Epoch uses different conditions to check if players are new spawn.  I'm using this at the moment, which should work but just doesn't.. :(

waitUntil {!isNil ("PVDZ_plr_LoginRecord")};
if (PVCDZ_plr_Login2 select 2) then
{

//Code for this script: https://gist.github.com/IT07/6210573

};

Any ideas? I've put a link to the script I'm embedding too.

 

this code is correct, you need to show us the script you intend to use as i think the error is there ... also check you client rpt file for clues as to what went wrong

 

quicksaver edit:

code is incorrect ... try this:

waitUntil {!isNil ("PVDZE_plr_LoginRecord")};
if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {

just woke up ... sorry

Link to comment
Share on other sites

  • 0

this code is correct, you need to show us the script you intend to use as i think the error is there ... also check you client rpt file for clues as to what went wrong

 

quicksaver edit:

code is incorrect ... try this:

waitUntil {!isNil ("PVDZE_plr_LoginRecord")};
if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {

just woke up ... sorry

 

Edit: That still doesn't work.. 

Link to comment
Share on other sites

  • 0

waitUntil {!isNil ("PVDZE_plr_LoginRecord")};

if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {

 

Still doesn't work .. I'm giving up!

 

unless you forgot a closing bracket or your script is broken, this will work ... oh and you also need to edit server_playerSetup.sqf, but i assumed you already changed this:

dayzPlayerLogin2 = [_worldspace,_state];

to this:

dayzPlayerLogin2 = [_worldspace,_state,_randomSpot];
Link to comment
Share on other sites

  • 0

 

unless you forgot a closing bracket or your script is broken, this will work ... oh and you also need to edit server_playerSetup.sqf, but i assumed you already changed this:

dayzPlayerLogin2 = [_worldspace,_state];

to this:

dayzPlayerLogin2 = [_worldspace,_state,_randomS

 

The script works fine when i don't add the condition to check if player is new. to prove this I just added a condition that checks the players height (ATL) and if above 200m it triggers the script on startup. As my players all parachute in on respawn, this works just fine for me.  

 

So are you saying (this is just to help me learn something) that the dayzPlayerlogin2 variable is empty, until I add that array to it? I always assumed that dayzPlayerLogin2 was a local variable set at start up.  Maybe i'm missing something.  I certainly don't think you need to edit your playersetup.sqf, that just doesn't make sense to me when I know there is already a function to check whether player is a new spawn... lol.. (pulls hair out)

 

Thanks for your help, appreciate it.

Link to comment
Share on other sites

  • 0

Try the following:

 

//

FILENAME: server_WelcomeCredits.sqf
// =====
// SCRIPT NAME: Server Intro Credits Script by IT07
// SCRIPT VERSION: v1.3.7 BETA
// Credits for original script: Bohemia Interactive http://bistudio.com
 
// ========== SCRIPT CONFIG ============
_onScreenTime = 6; //how long one role should stay on screen. Use value from 0 to 10 where 0 is almost instant transition to next role 
//NOTE: Above value is not in seconds. It is percentage. Default: 6
 
// ==== CUSTOMIZING THE CREDITS ===
// If you want more or less credits on the screen, you have to add/remove roles.
// Watch out though, you need to make sure BOTH role lists match eachother in terms of amount.
// Just take a good look at the _role1 and the rest and you will see what I mean.
 
// == CUSTOMIZING TEXT COLOR ==
// Find line 49 and look for: color='#f2cb0b'
//  #f2cb0b is the HTML color code for the text. As well as #FFFFFF in the row below it.
// Find the color code you want here: http://html-color-codes.info
// =====
 
// ==== SCRIPT START ====
waitUntil {!isNil "dayz_animalCheck"}; //remove this line completely to make it work in ArmA 3. Yes you read that correctly.
waitUntil {!isNil ("PVDZE_plr_LoginRecord")};
if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {
sleep 10; //Wait in seconds before the credits start after player IS ingame
 
_role1 = "Welcome to";
_role1names = ["Your server name"];
_role2 = "Admins";
_role2names = ["ChuckNorris", "Eddie Morphine"];
_role3 = "Server mod";
_role3names = ["DayZ Epoch Chernarus"];
_role4 = "Server antihack<br />by"; //The "by" in this row will be shown one row below "Server antihack". Can be applied to any role
_role4names = ["infiSTAR.de", "Blurgaming"];
_role5 = "Server Mods";
_role5names = ["Dynamic Spawns", "Self-bb", "Custom traders", "More mods"];
_role6 = "Website";
_role6names = ["yourwebsite.com"];
_role7 = "Twitter";
_role7names = ["@yourtwittername"];
_role8 = "Email Support";
_role8names = ["[email protected]"];
_role9 = "Special Thanks";
_role9names = ["DayZ.ST", "Blurgaming.com", "infiSTAR.de", "HFBservers.com", "ArmAholic.com", "OpendayZ.net", "DayZmod.com"];
 
{
sleep 2;
_memberFunction = _x select 0;
_memberNames = _x select 1;
_finalText = format ["<t size='0.40' color='#f2cb0b' align='right'>%1<br /></t>", _memberFunction];
_finalText = _finalText + "<t size='0.70' color='#FFFFFF' align='right'>";
{_finalText = _finalText + format ["%1<br />", _x]} forEach _memberNames;
_finalText = _finalText + "</t>";
_onScreenTime + (((count _memberNames) - 1) * 0.5);
[
_finalText,
[safezoneX + safezoneW - 0.8,0.50], //DEFAULT: 0.5,0.35
[safezoneY + safezoneH - 0.8,0.7], //DEFAULT: 0.8,0.7
_onScreenTime,
0.5
] spawn BIS_fnc_dynamicText;
sleep (_onScreenTime);
} forEach [
//The list below should have exactly the same amount of roles as the list above
[_role1, _role1names],
[_role2, _role2names],
[_role3, _role3names],
[_role4, _role4names],
[_role5, _role5names],
[_role6, _role6names],
[_role7, _role7names],
[_role8, _role8names],
[_role9, _role9names] //make SURE the last one here does NOT have a , at the end
];

};



I'm actually interested in seeing if this works myself, as we run the server intro credits script on our server and I've pondered having it run only when a player is a new spawn.

Link to comment
Share on other sites

  • 0

Would it be the following: 

 

In your missions init.sqf: 

 

Add: 

waitUntil {!isNil ("PVDZE_plr_LoginRecord")}; if (dayzPlayerLogin2 select 2) then { [] execVM "custom\server_WelcomeCredits.sqf"; };

After the: 

if (!isDedicated) then {
	//Conduct map operations
	0 fadeSound 0;
	waitUntil {!isNil "dayz_loadScreenMsg"};
	dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");

	//Run the player monitor
	_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
	_playerMonitor = 	[] execVM "\z\addons\dayz_code\system\player_monitor.sqf";	


	//anti Hack
	[] execVM "\z\addons\dayz_code\system\antihack.sqf";

	//Lights
	//[false,12] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};

Note that I am not sure if the server_WelcomeCredits.sqf can run outside of the "if (!isDedicated) then {", but you should really be doing the check in the mission before you load the credits. 

If thats not possible, using this in the server_WelcomeCredits.sqf is likely better: 

 

// FILENAME: server_WelcomeCredits.sqf
// =====
// SCRIPT NAME: Server Intro Credits Script by IT07
// SCRIPT VERSION: v1.3.7 BETA
// Credits for original script: Bohemia Interactive http://bistudio.com
 
// ========== SCRIPT CONFIG ============
_onScreenTime = 6; //how long one role should stay on screen. Use value from 0 to 10 where 0 is almost instant transition to next role 
//NOTE: Above value is not in seconds. It is percentage. Default: 6
 
// ==== CUSTOMIZING THE CREDITS ===
// If you want more or less credits on the screen, you have to add/remove roles.
// Watch out though, you need to make sure BOTH role lists match eachother in terms of amount.
// Just take a good look at the _role1 and the rest and you will see what I mean.
 
// == CUSTOMIZING TEXT COLOR ==
// Find line 49 and look for: color='#f2cb0b'
//  #f2cb0b is the HTML color code for the text. As well as #FFFFFF in the row below it.
// Find the color code you want here: http://html-color-codes.info
// =====
 
// ==== SCRIPT START ====
waitUntil {!isNil "dayz_animalCheck"}; //remove this line completely to make it work in ArmA 3. Yes you read that correctly.
waitUntil {!isNil ("PVDZE_plr_LoginRecord")}; if (dayzPlayerLogin2 select 2) then {
sleep 10; //Wait in seconds before the credits start after player IS ingame
 
_role1 = "Welcome to";
_role1names = ["Your server name"];
_role2 = "Admins";
_role2names = ["ChuckNorris", "Eddie Morphine"];
_role3 = "Server mod";
_role3names = ["DayZ Epoch Chernarus"];
_role4 = "Server antihack<br />by"; //The "by" in this row will be shown one row below "Server antihack". Can be applied to any role
_role4names = ["infiSTAR.de", "Blurgaming"];
_role5 = "Server Mods";
_role5names = ["Dynamic Spawns", "Self-bb", "Custom traders", "More mods"];
_role6 = "Website";
_role6names = ["yourwebsite.com"];
_role7 = "Twitter";
_role7names = ["@yourtwittername"];
_role8 = "Email Support";
_role8names = ["[email protected]"];
_role9 = "Special Thanks";
_role9names = ["DayZ.ST", "Blurgaming.com", "infiSTAR.de", "HFBservers.com", "ArmAholic.com", "OpendayZ.net", "DayZmod.com"];
 
{
sleep 2;
_memberFunction = _x select 0;
_memberNames = _x select 1;
_finalText = format ["<t size='0.40' color='#f2cb0b' align='right'>%1<br /></t>", _memberFunction];
_finalText = _finalText + "<t size='0.70' color='#FFFFFF' align='right'>";
{_finalText = _finalText + format ["%1<br />", _x]} forEach _memberNames;
_finalText = _finalText + "</t>";
_onScreenTime + (((count _memberNames) - 1) * 0.5);
[
_finalText,
[safezoneX + safezoneW - 0.8,0.50], //DEFAULT: 0.5,0.35
[safezoneY + safezoneH - 0.8,0.7], //DEFAULT: 0.8,0.7
_onScreenTime,
0.5
] spawn BIS_fnc_dynamicText;
sleep (_onScreenTime);
} forEach [
//The list below should have exactly the same amount of roles as the list above
[_role1, _role1names],
[_role2, _role2names],
[_role3, _role3names],
[_role4, _role4names],
[_role5, _role5names],
[_role6, _role6names],
[_role7, _role7names],
[_role8, _role8names],
[_role9, _role9names] //make SURE the last one here does NOT have a , at the end
];
};
};

Link to comment
Share on other sites

  • 0

Finally got some time to implement and test this, use the following as it is working on our server:


// FILENAME: server_WelcomeCredits.sqf

// =====
// SCRIPT NAME: Server Intro Credits Script by IT07
// SCRIPT VERSION: v1.3.7 BETA
// Credits for original script: Bohemia Interactive http://bistudio.com


// ========== SCRIPT CONFIG ============
_onScreenTime = 6; //how long one role should stay on screen. Use value from 0 to 10 where 0 is almost instant transition to next role 
//NOTE: Above value is not in seconds. It is percentage. Default: 6


// ==== CUSTOMIZING THE CREDITS ===
// If you want more or less credits on the screen, you have to add/remove roles.
// Watch out though, you need to make sure BOTH role lists match eachother in terms of amount.
// Just take a good look at the _role1 and the rest and you will see what I mean.


// == CUSTOMIZING TEXT COLOR ==
// Find line 49 and look for: color='#f2cb0b'
//  #f2cb0b is the HTML color code for the text. As well as #FFFFFF in the row below it.
// Find the color code you want here: http://html-color-codes.info
// =====


// ==== SCRIPT START ====
waitUntil {!isNil "dayz_animalCheck"}; //remove this line completely to make it work in ArmA 3. Yes you read that correctly.
if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {
sleep 10; //Wait in seconds before the credits start after player IS ingame


_role1 = "Welcome to";
_role1names = ["Your server name"];
_role2 = "Admins";
_role2names = ["ChuckNorris", "Eddie Morphine"];
_role3 = "Server mod";
_role3names = ["DayZ Epoch Chernarus"];
_role4 = "Server antihack<br />by"; //The "by" in this row will be shown one row below "Server antihack". Can be applied to any role
_role4names = ["infiSTAR.de", "Blurgaming"];
_role5 = "Server Mods";
_role5names = ["Dynamic Spawns", "Self-bb", "Custom traders", "More mods"];
_role6 = "Website";
_role6names = ["yourwebsite.com"];
_role7 = "Twitter";
_role7names = ["@yourtwittername"];
_role8 = "Email Support";
_role8names = ["[email protected]"];
_role9 = "Special Thanks";
_role9names = ["DayZ.ST", "Blurgaming.com", "infiSTAR.de", "HFBservers.com", "ArmAholic.com", "OpendayZ.net", "DayZmod.com"];


{
sleep 2;
_memberFunction = _x select 0;
_memberNames = _x select 1;
_finalText = format ["<t size='0.40' color='#f2cb0b' align='right'>%1<br /></t>", _memberFunction];
_finalText = _finalText + "<t size='0.70' color='#FFFFFF' align='right'>";
{_finalText = _finalText + format ["%1<br />", _x]} forEach _memberNames;
_finalText = _finalText + "</t>";
_onScreenTime + (((count _memberNames) - 1) * 0.5);
[
_finalText,
[safezoneX + safezoneW - 0.8,0.50], //DEFAULT: 0.5,0.35
[safezoneY + safezoneH - 0.8,0.7], //DEFAULT: 0.8,0.7
_onScreenTime,
0.5
] spawn BIS_fnc_dynamicText;
sleep (_onScreenTime);
} forEach [
//The list below should have exactly the same amount of roles as the list above
[_role1, _role1names],
[_role2, _role2names],
[_role3, _role3names],
[_role4, _role4names],
[_role5, _role5names],
[_role6, _role6names],
[_role7, _role7names],
[_role8, _role8names],
[_role9, _role9names] //make SURE the last one here does NOT have a , at the end
];
};



You will obviously need to adjust the displayed information to be what you want but this basic template will result in the credits only rolling for fresh spawns.

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