Author Topic: eXtreme 2.7: player-threads  (Read 197 times)

Offline {NADF}Geronimo

  • Rank: Private
  • *
  • Posts: 65
eXtreme 2.7: player-threads
« on: July 16, 2011, 12:30:04 pm »
Hi Pat!

The following player-threads are always "created". Could we optimize this part a bit?

   
// start toolbox procedures
self thread extreme\_ex_toolbox::main();
// monitor for knife
self thread extreme\_ex_knife::main();
// monitor for flamethrower
self thread extreme\_ex_flamethrower::main();
// display round number at spawn for roundbased gametypes
self thread roundDisplay();



For example:
Toolbox:
Code: [Select]

//********************************************************************************
//{NADF} Toolbox Fix
//********************************************************************************
//Created by: {NADF}Geronimo
//Date: 19.06.2011
//Version: 1.0
//Website: http://nadfserver.org
//Clan: {NADF} - North Atlantic Defence Force
//Comment: NADF FIX to reduce player threads!
//********************************************************************************
if (level.ex_nadf_toolbox) self thread extreme\_ex_toolbox::main();
//********************************************************************************
Add a level-variable to turn on/off that feature. In that way, the player-names for the toolbox can always be added in the file.
Also it helps to reduce a bit of spawning-player-threads.
Code: [Select]

level endon("ex_gameover");
self endon("disconnect");

authplayers = [];

// Enable the tools for the following players (include color codes)
authplayers[authplayers.size] = "playername";

// Enable the tools you need (preferably only enable one at a time)
tool_thirdperson = true;
tool_showpos = false;

// No need to change anything below this line
tool_authorized = false;
//********************************************************************************
This code is always used...


KNIFE:
If it's not correct, could you please post the correct way? ;)
Code: [Select]
//********************************************************************************
//{NADF} Knife Fix
//********************************************************************************
//Created by: {NADF}Geronimo
//Date: 19.06.2011
//Version: 1.0
//Website: http://nadfserver.org
//Clan: {NADF} - North Atlantic Defence Force
//Comment: NADF FIX to reduce player threads!
//********************************************************************************
if (level.ex_wepo_sidearm > 1 && getCvarInt("scr_allow_knife") != 0) self thread extreme\_ex_knife::main();
//********************************************************************************


Flamethrower
Similary to the knife, we never use them, but the player-thread is started.
Code: [Select]
//********************************************************************************
//{NADF} Flamethrower Fix
//********************************************************************************
//Created by: {NADF}Geronimo
//Date: 19.06.2011
//Version: 1.0
//Website: http://nadfserver.org
//Clan: {NADF} - North Atlantic Defence Force
//Comment: NADF FIX to reduce player threads!
//********************************************************************************
if(getCvarInt("scr_allow_flamethrower") != 0 || getCvarInt("scr_allow_flammenwerfer") != 0) self thread extreme\_ex_flamethrower::main();
//********************************************************************************
I think, the thread is died anyway, if flamethrower is not used, but better would be, never to create the player-thread.


RoundDisplay
This thread is died, when no round-display is needed. But it is created too. I prefer not to creat a thread, which is the most of the time not needed.
Bad solution i added:


Code: [Select]
//********************************************************************************
//{NADF} Round number Fix
//********************************************************************************
//Created by: {NADF}Geronimo
//Date: 19.06.2011
//Version: 1.0
//Website: http://nadfserver.org
//Clan: {NADF} - North Atlantic Defence Force
//Comment: NADF FIX to reduce player threads!
//********************************************************************************
if(!isDefined(game["roundnumber"]) || !game["roundnumber"] || game["roundnumber"] == self.pers["roundshown"] || isDefined(self.ex_roundnumber))
{
//Do nothing, Wtf is the "opposite" of that one, to save the "else"???? :(
}
else
{
self thread roundDisplay();
}
//********************************************************************************

Ok, that's all for now ;)
Your thoughts please  :oops:

Regards,
Geronimo

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: eXtreme 2.7: player-threads
« Reply #1 on: July 16, 2011, 01:11:53 pm »
The threads will die within milliseconds if you are not authorized (toolbox),the weapon is not available (flamethrower), or the feature is not available (round display). I rather have it that way, then implementing a "bad solution" for something that doesn't need fixing.

The event controller in 2.7 saves hundreds of player and level threads. I don't mind spending a few threads here and there.