Author Topic: Leveling System  (Read 8095 times)

This is incredibly spammy.

function levelHudLoop()
{
   %count = clientGroup.getCount();
   
   for(%i = 0; %i < %count; %i++)
   {
      %client = clientGroup.getObject(%i);
      
      %client.bottomPrint("<just:center>\c6Level:" SPC %client.level SPC " EXP:" SPC %client.xp @ "/" @ %client.level + 1 SPC "Kills:" SPC %client.kills @ "<br>\c3Top player:" SPC $highestLevelName SPC "(" @ $highestLevelID @ ")" SPC "Level" SPC $highestLevel, 1, 1);
   }
   
   schedule(500, 0, levelHudLoop);
}


This code runs every half-second, and applies the bottomPrint HUD to everyone at the server, at once. Instead of clogging up processing power by doing this, a much more sane and resourceful solution is to just refresh the HUD every time something actually prompts it to change. I wouldn't recommend this, and there are better ways to do it.

This is incredibly spammy.

function levelHudLoop()
{
   %count = clientGroup.getCount();
   
   for(%i = 0; %i < %count; %i++)
   {
      %client = clientGroup.getObject(%i);
      
      %client.bottomPrint("<just:center>\c6Level:" SPC %client.level SPC " EXP:" SPC %client.xp @ "/" @ %client.level + 1 SPC "Kills:" SPC %client.kills @ "<br>\c3Top player:" SPC $highestLevelName SPC "(" @ $highestLevelID @ ")" SPC "Level" SPC $highestLevel, 1, 1);
   }
   
   schedule(500, 0, levelHudLoop);
}


This code runs every half-second, and applies the bottomPrint HUD to everyone at the server, at once. Instead of clogging up processing power by doing this, a much more sane and resourceful solution is to just refresh the HUD every time something actually prompts it to change. I wouldn't recommend this, and there are better ways to do it.

Thanks for the feedback ill get to fixing that shortly as well as adding events.

This is incredibly spammy
Except, you know, when someone triggers a bottomprint event and then can't see the hud until it's updated again.

This makes neglible impact on performance. 500ms is a huge delay in the grand scheme of computing.

Except, you know, when someone triggers a bottomprint event and then can't see the hud until it's updated again.

This makes neglible impact on performance. 500ms is a huge delay in the grand scheme of computing.

Also true.

it also overrides any bottom print messages though so you might want to set the delay to 10 seconds or so so its less likely to override messages too quickly

use an if statement to check if it's changed
also, use 2 variables: exp, and previous exp
if(%exp > %prevexp) {

}

you get it
i've never thought of using that in a bottomprint loop, but now i will, thanks johnny
also, another thing:

try not to use for() statements. if the variable ever makes the statement in the for loop false, it will not work anymore. use for() statements for stuff like making a list of all players in-game.
instead, use %client.exploop = schedule(40,0,exploop());
use that INSIDE of the function named exploop, at the end of it.
do whatever you want to loop in function
you can toggle this off by doing cancel(%client.exploop);
very cool stuff, i use this instead of for loops because imo it's more efficient
« Last Edit: July 06, 2015, 09:12:02 AM by -Setro- »

Oh but Summet Excuse me, how do you reset the stats and level?