Public Kill Tracker

It’s good to share. this is the first npc i made in a long time. all it does is keep track of the top 5 most kills on the server. sloppy coding is my style, but it works. anyone can use this if they feel like it.

if (created) {
  timereverywhere;
  setshape 1,32,32;
  message Kill Rankings;
}

if (playerenters) {setplayerprop #c,showkills; set playerchats; unset playerchats;}

if (playertouchsme) {
  //setplayerprop #c,showkills;
  say2 Here is the top five most kills: #b
  1st #I(server.kName,0) has #I(server.kCount,0) kills #b
  2nd #I(server.kName,1) has #I(server.kCount,1) kills #b
  3rd #I(server.kName,2) has #I(server.kCount,2) kills #b
  4th #I(server.kName,3) has #I(server.kCount,3) kills #b
  5th #I(server.kName,4) has #I(server.kCount,4) kills #b;
}
if (playerchats) {
  if (startswith(kills:,#c)) {
    setplayerprop #c,I tried to cheat, but nope.;
  }
  this.count = 5;
  this.onList = 0;
  sleep .5;
  if (startswith(kills:,#c))
    {
    for (k=0;k<5;k++) {
      if (strequals(#I(server.kName,k),#a)) {
        this.onIndex = k;
        this.onList = 1;
        deletestring server.kCount,this.onIndex;
        deletestring server.kName,this.onIndex;
        this.count--;
      }
    }
    for (i=0;i<this.count;i++) {
      if (strtofloat(#e(7,-1,#c)) > strtofloat(#I(server.kCount,i))) {
        insertstring server.kCount,i,#e(7,-1,#c);
        insertstring server.kName,i,#a;
        if (this.onList == 0) {
          deletestring server.kCount,5;
          deletestring server.kName,5;
        }
        break;

      }
    }
    setplayerprop #c,;
  }
}

What’s the point of setting playerchats and then unsetting it?

im still trying to figure out how things work. so i bet there are things in there that arent needed.

I put it there because I dont think the playerchats flag gets set if you use the setplayerprop command.

i put this in a level and it doesnt keep track at all… x.x

Really good point oO…

only stores info for 1st place
sorry for necroposting

works for me. i think i had to create the server strings.

you mean flags?
server.kCount2=7
server.kCount=12
server.kName2=test
server.kName=Clavo

and only clavo appears in ranking

No, it’s a couple of lists

server.kName=Name1,Name2,Name3,…
server.kCount=500,400,300,…

yeah you have to initialize all the values in the array. i had an npc do this in the level i was using to test. i should have uploaded the level instead of just text.

i see, is there a way that the values fill in automatically?

well they will update automatically after they have been initialized.

D: If Beholder hasn’t said it once, he has said it a million times.

“Learn the differences between variables strings and flags”

well its confusing since the editor stores all client. and server. strings under the flag button.

Strings store text/numbers, and Variables store just numbers. As far as I know.

Flags are just data stored on your player that are able to be “set” and “un-set”.

strings are an array of characters. flags will be true or false, 1 or 0, or, as you said, set or unset.

As far as I know, Variables cannot be arrays

setstring string,{array,array};

Beholder is going to come in and say something surely?

well duh. variables in their very nature are nothing like arrays.

setarray var,7;

var = {1,3,5,2,6,4,2};

var[4]=10;

Take your pick.