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,;
}
}
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.