Jump to content
Sign in to follow this  
Mr.jizz

mp scripting trouble (load screen freeze)

Recommended Posts

so my mission keeps freezing on load screen (with sound), (dedi server) and im about 90% sure (well i assume, as im kinda novice) its to do with my scripts/ how they are executed here is my init.sqf....
 
 

cash = 100;
killcount = 0;

if (isDedicated) then {
	execVM "randommissionArray.sqf";
};

if (hasInterface) then {
	execVM "whitelist.sqf";
	execVM "killcounter.sqf";
	execVM "respawnloadout.sqf";
	execVM "HUD_display.sqf";
};

enableSaving [FALSE,FALSE];
waitUntil {time > 0};

execVM "statSave\saveFuncs.sqf";
waitUntil {!isNil "saveFuncsLoaded"};

if(isServer) then
{
	_serverHasID = profileNameSpace getVariable ["ss_ServerID",nil];
	if(isNil "_serverHasID") then
	{
		_serverID = str(round((random(100000)) + random 10000));
		profileNameSpace setVariable ["SS_ServerID",_serverID];
	};
	serverID = profileNameSpace getVariable "ss_ServerID";
	publicVariable "serverID";
};

waitUntil {!isNil "serverID"};

if (!isDedicated) then {
	execVM "statSave\loadAccount.sqf";
	execVM "statSave\saveLoop.sqf";
};

 so could some one maybe point out my flaws here?, as i know there has to be some?....if you need more info i can post my mission file for you to have a look at....

Share this post


Link to post
Share on other sites

post your mission in some kinda drop box or file share...

the init is a problem, to start I believe

 

this should be at top of init  enableSaving [FALSE,FALSE];

and  waitUntil {time > 0}; isn't doing anything to code above..

 

this also looks wrong but id need to see what you have to know what you should do ..

  1. if (hasInterface) then {
  2. execVM "whitelist.sqf";
  3. execVM "killcounter.sqf";
  4. execVM "respawnloadout.sqf";
  5. execVM "HUD_display.sqf";
  6. };
  7. also I hope these numbers arnt part of your script .. (they wont work)!!!!!

that's it for now

Share this post


Link to post
Share on other sites

Here is a tutorial which explains how to debug your code

https://forums.bistudio.com/topic/166233-zeu-debugging-tutorial-foundation-template/

Debugging is probably the most important element you need to master if you want to evolve your code and get a better understanding of how things work.

 

Here are a few pointers for now.

 

1) To try and figure out which if any script is causing the issue (Bearing in mind we cant see the content of the scrpts you are trying to run, but nonetheless

Edit your code and comment out all the execvm's leaving the very first one uncommented, so that it executes

Example

cash = 100;
killcount = 0;
 
if (isDedicated) then {
execVM "randommissionArray.sqf";
};
 
if (hasInterface) then {
//execVM "whitelist.sqf";
//execVM "killcounter.sqf";
//execVM "respawnloadout.sqf";
//execVM "HUD_display.sqf";
};
 
enableSaving [FALSE,FALSE];
waitUntil {time > 0};
 
//execVM "statSave\saveFuncs.sqf";
//waitUntil {!isNil "saveFuncsLoaded"};
 
if(isServer) then
{
_serverHasID = profileNameSpace getVariable ["ss_ServerID",nil];
if(isNil "_serverHasID") then
{
_serverID = str(round((random(100000)) + random 10000));
profileNameSpace setVariable ["SS_ServerID",_serverID];
};
serverID = profileNameSpace getVariable "ss_ServerID";
publicVariable "serverID";
};
 
//waitUntil {!isNil "serverID"};
 
if (!isDedicated) then {
//execVM "statSave\loadAccount.sqf";
//execVM "statSave\saveLoop.sqf";
};
 

2) If the code runs okay and the server doesnt freeze, then uncomment the second script, which in this case will only be run on the client anyway so unless its a client hosted server, it shouldnt effect the server loading

example

cash = 100;
killcount = 0;
 
if (isDedicated) then {
execVM "randommissionArray.sqf";
};
 
if (hasInterface) then {
execVM "whitelist.sqf";
//execVM "killcounter.sqf";
//execVM "respawnloadout.sqf";
//execVM "HUD_display.sqf";
};
 
enableSaving [FALSE,FALSE];
waitUntil {time > 0};
 
//execVM "statSave\saveFuncs.sqf";
//waitUntil {!isNil "saveFuncsLoaded"};
 
if(isServer) then
{
_serverHasID = profileNameSpace getVariable ["ss_ServerID",nil];
if(isNil "_serverHasID") then
{
_serverID = str(round((random(100000)) + random 10000));
profileNameSpace setVariable ["SS_ServerID",_serverID];
};
serverID = profileNameSpace getVariable "ss_ServerID";
publicVariable "serverID";
};
 
//waitUntil {!isNil "serverID"};
 
if (!isDedicated) then {
//execVM "statSave\loadAccount.sqf";
//execVM "statSave\saveLoop.sqf";
};

 

3) Continue doing this until either you find which script is causing the issue or they are all running.

 

 

Next time you build some code, don't build too much at a time and test each step

 

---------------------------------------------------------------------------------------------------

 

4) Next thing, I notice you dont use any "Tags" for your global variables, example being

  • cash = 100;
  • killcount = 0;

Ideally you should be using some tag, for example my tag is Txu_

So all my global variables start with Txu_

 

Examples being

 

  • Txu_cash = 100;
  • Txu_killcount = 0;

The reason for this, suppose you have copied somebody elses script or are running an addon created by someone who has also not used a tag, or the server is running an addon that an inexperienced coder has created

They may very well have a variable called Killcount or Cash, which means that when you change your value, it effects their code and when they change their value it effects your code. This is very bad practise and you should avoid it.

 

5) There is nothing wrong with execVM "SomeScript.sqf" as stated above, so dont worry about that, you only need the "[] execVM if you need to pass values to the script, which I doubt you need.

 

 

Your code is a little disoganised though, think of the "node" you are running the code for and the flow of that code

At the moment you have to wait until each of your execvm's has finished before the next one starts

So your flow of code is something like

Run a bit of server code

Run a bit of client code

Run some more server code

 

There are different methods to tidy things up, but for now, think about spawning your server code in 1 thread and your client code in another

 

for example

if(IsServer)then
{
    [] spawn
    {
        all your server code here
    };
};
 
if(HasInterface)then
{
   [] spawn
   {
          all your client code here
   };
};

Spawning code in this way, allows all your server code to be run together inline with one n nother and at the same time parallel to it, all your client code can also be run, meaning the server isnt waiting for the client code to finish before it can do the next bit of the server code

So it runs more like this

Run server code in column "A" while I run client code in column "B"

(Unless of course the server code is relying on the client code to do something before it can continue, or vice versa)

 

If the waituntil conditions are messed up and they both share the same environment, eg the client is the server, then a badly defined waituntil command for client code could halt the server, so try where possible to seperate them

 

 

Hope that helps

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for getting back, as i say im pretty novice with all this as this is my first big attempt at running a dedicated server (only ever used small scripts sp etc) so sorry if my up take is a little slow at points, but i much appreciate your help as its a major part of my progression/learning.

- Once i get home from work i will upload my file via dropbox.
- i do not use these numbers in my code, i use notepad++ (easy to find lines).
-i only picked up about using tag's later on, so i will start to change everything (my lack of knowledge).
-i think i did jump in to quick and in a way cant completely cover my tracks, but i have singled out 'execvm scripts' to find the issues, but with my lack of knowledge im never 100% how to fix some issues i just bash at it until it works, but sometimes this causes other things to not work,
--iv been at this for a few weeks now, trying to fix my issues.
--i initially debugged all my scripts so they actually worked.
--sometimes with my "fix's" i have got everything to work properly, just to log off server, come back to 1hour + later and get stuck on load screen.

So believe me when i say iv tried what i can of my knowledge to get this working, it could be something really simple that iv just over looked or just haven't knew or understood?...

I believe i could test these scripts on my dedi without any mods activated, but the server runs fine with these mods and i have got it working with scripts until re-join, so from what i know, as iv said im guessing its something stupidly wrong with my scripts or at least how im executing them (ie client/server etc)

Again mega thanks for getting back, i will upload my file a bit later :)

Share this post


Link to post
Share on other sites

post your mission in some kinda drop box or file share...

the init is a problem, to start I believe

 

this should be at top of init  enableSaving [FALSE,FALSE];

and  waitUntil {time > 0}; isn't doing anything to code above..

 

this also looks wrong but id need to see what you have to know what you should do ..

  1. if (hasInterface) then {
  2. execVM "whitelist.sqf";
  3. execVM "killcounter.sqf";
  4. execVM "respawnloadout.sqf";
  5. execVM "HUD_display.sqf";
  6. };
  7. also I hope these numbers arnt part of your script .. (they wont work)!!!!!

that's it for now

 

here you go, my mission file:

https://www.dropbox.com/sh/bfbw21z93bicrgx/AACo8mT2tnIf0dqVdn0H8pu7a?dl=0

 

 

 

update, so i took some of your advice and moved this around...

 

this should be at top of init  enableSaving [FALSE,FALSE];

and  waitUntil {time > 0}; isn't doing anything to code above..

 

now it actually loaded me into the game, gonna test some stuff first and try and log back in later and ill report back to you, but iv a feeling i may need to tidy some parts up in my init.sqf etc, so would still be great for you to have a look at my mission folder  :)

Edited by Mr.jizz

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
Sign in to follow this  

×