Hrm, not if we keep that in Decodelevelparms() function. Actually its a poor place to check for the server type. It only will run when the client connects for the first time, so if you have a ded server running with no players joined yet, "dedicated" will still be zero.
After some more experimenting, I wound up putting it in StartFrame ()
Code: Select all
if (framecount == 10)
{
local entity ded;
ded = findfloat (ded, colormap, 1);
if (ded.netaddress == "local")
cvar_set ("dedicated", "0");
else
cvar_set ("dedicated", "1");
}
I was messing with it in WorldSpawn() , but it seems the environment for the player slots is not yet set up yet there, so it did not work. Further tests revealed that after about (10) frames, the slots were put up, so I guess this is about the safest place to do it.
Yea, other Kernel or Hunk envoronments may vary.
NOTE: As opposed to findfloat(), on other engines where its not available, usually Nextent(world) winds up being the first player slot after everything else is set up, unless you are interupting the process I think by spawning a dynamic entity before all that. I believe they refer to map items as "Quaked" items or Quaked ents in some older stuff I once read about QC. I guess the Quaked stuff spawns after the player solts are put up....in some framecount number decided by the speed of the hardware being used I guess. So even though I am making my code here in a Win 64 bit environment, its still I guess possible the framecount number I picked could be too low if the system I upload it to live runs a tad slower, or like you say, if the Linux Kernel / Hunk stuff is doing something differently.
Anyhow, this is more or less pretty simple done in QC, so the need for an engine cvar oir extension may not be needed.
Oh , and I was looking for a good place to register the new cvar. Seems I had to go to StartFrame once again :
Code: Select all
if (!framecount)
registercvar ("dedicated", "0");
r00k wrote:woudn't
if (self.netaddress == "local")
be enough?
I have seen issues with manipulating strings on the hunk to differ from windows and linux, so I could see how this would be
useful.