Author Topic: What is dedicated-compatible?  (Read 2251 times)

How can i avoid having my mod become not compatible with dedicated servers? (losing functionality, crashing the server, etc.)
and if possible, what functions are and aren't compatible with dedicated servers?

Most functions, other than client-sided ones, should be compatible.

Is it possible to post your code?

All server sided functions.
Just start up a dedicated server and see what breaks.

Just test your mod on a dedicated server during development and before releasing it.

The big thing to look out for is .gui files.  Trying to load those from a server.cs will crash a dedicated server.

It's usually the other way around.

Dedicated servers are their own little world. You boot them up, then close them down.

Client-run servers can be shut down, restarted, they can join other servers, etc. If you don't do proper object cleanup on the mission end things can go very wrong.

my code involves getting a list from a .txt, and unless there's a way to completly delete variables, i may need to stick with that. the reason im asking is because the last mod i made that used a .txt list management system crashed the dedicated server the moment it started.

my code involves getting a list from a .txt, and unless there's a way to completly delete variables, i may need to stick with that. the reason im asking is because the last mod i made that used a .txt list management system crashed the dedicated server the moment it started.
Chances are you were trying to call some function that was only available client-side.

What are you trying to accomplish?  im sure theres a server-side friendly way to do it.

i was trying to accomplish a flexible list system, using a .txt, and my average scripting skills.
it worked on a non-dedicated server, but it completly ruined the dedicated server. (crashed it, not corrupted it.)
here was the code for that, it was made along with a gui, so ignore any: (its not going to be released, and its broken. dont copy it.)

function servercmdreserve(%client, %id, %type, %g)
{
   if(!%client.isAdmin)
   return;
   if(%id $= "")
   return;
   for(%c=0;%c<strLen(%id);%c++)
   {
      %char[%c]=sn(getSubStr(%id,%c,1));
      if(%char[%c] !$= "NONE")
      {
         %char[%c] = %char[%c];
         %id[%a++] = %char[%c];
      }
   }
   %id = %id[%a - %a + 1] @ %id[%a - %a + 2] @ %id[%a - %a + 3] @ %id[%a - %a + 4] @ %id[%a - %a + 5];
   if(%type $= "")
   {
      %type = 1;
   }
   %val = %id TAB %type;
   %line = ln(%id, %type);
   if(%type == 2 && ln(%id) == 0)
   {
      return;
   }
   if(%type == 2 && ln(%id) >= 1)
   {
      $Res::ResC--;
      ReservedIDs.setSelectedRow(1);
   }
   if(%type == 1 && ln(%id) == 0)
   {
      $Res::ResC++;
   }
   if(%type == 1 && ln(%id) >= 1)
   {
      if(ln2(%id) == 1)
      {
         return;
      }
   }
   if(%line == 0)
   $Res::Line[$Res::LineCount++] = %val;
   else
   $Res::Line[%line] = %val;
   %file = new FileObject();
   %file.openForWrite("config/server/res/res.txt");
   %file.writeline("--RESERVATION LIST--");
   for(%i=1;%i<=$Res::LineCount;%i++)
   {
      if(getField($Res::Line[%i], 1) $= 1)
      {
         %file.writeLine($Res::Line[%i]);
      }
   }
   %file.close();
   %file.delete();
   if(%g $= "")
   {
      %g = 2;
   }
   if(%g == 1)
   {
      canvas.popdialog(ReserveGUI);
      canvas.pushdialog(ReserveGUI);
   }
}

there's a way to completly delete variables
$var = "";
If you do this to a variable contained in a scriptObject, you'll see that the var no longer appear when you dump it.

the canvas.pop/pushdialog would probably be the cause

$var = "";
Or the DeleteVariables function

its this:
Code: [Select]
   if(%g == 1)
   {
      canvas.popdialog(ReserveGUI);
      canvas.pushdialog(ReserveGUI);
   }
Canvas doesnt exist on a dedicated server.  So when the script compiler tries to parse that, it chokes.

Canvas is a scriptObject or something similar. That shouldn't cause a crash. If it isn't there, the server would say Unable to find object '', attempting to call function blah blah blah

take the Canvas code out of your script and see.

take the Canvas code out of your script and see.
Code: [Select]
<input> (0): Unable to find object: 'Canvas' attempting to call function 'pushDialog'
BackTrace:


<input> (0): Unable to find object: 'Canvas' attempting to call function 'popDialog'
BackTrace:

You haven't provided the full code. Executing a .gui file on a dedicated server causes a crash.

so my .txt system will work, the only thing that was crashing it was the gui system i implemented. is this correct? if so, i could use my .txt system.

$var = "";
If you do this to a variable contained in a scriptObject, you'll see that the var no longer appear when you dump it.
post an example please?

Or the DeleteVariables function
so DeleteVariables("$varname"); will delete the specified variable?
« Last Edit: April 27, 2011, 01:52:53 PM by Ipquarx »