here is a little script .. ill comment it .. i made it in like 5 minutes cuz i was bored .. and I think it can teach something to some1 learning how to script
NPC Code:
// NPC made by LiquidIce
this.beginindex=200; //begin showimg index
//this is so it only shows local (local showimg starts at 200)
if (playerenters&&!isweapon) {
toweapons Scouter;
timeout=.05;
}
if (weaponfired) {
this.enabled=(this.enabled+1)%2;
//uses mod.. it will go back to 0 if this.enabled=>2
if (this.enabled=1) {
this.oldshow=this.beginindex;
//here we set the oldshow (which is a value that keeps track)
//of the highest showimg done .. useful when we are hiding
//all the showimgs.. we set to the beginindex so the for loop
//doesnt run .. (cuz no showimg has been done yet)
}
timeout=.05;
}
if (isweapon&&(timeout||playerenters)) {
hide(); //calls function to hide all the shown images
if (keydown(4)&&strequals(#w,Scouter)) {
//checks to see if D is being pressed and the current weapon
//is our scouter
check(); //does the check function
}
timeout=.05;
}
function hide() {
//hide function
for (this.a=this.beginindex;this.a<this.oldshow;this.a ++) {
//this forloop uses the this.oldshow to know when to stop
hideimg this.a;
//hides the img .. based on the loop
}
}
function check() {
for (this.a=1;this.a<playerscount;this.a++) {
//runs a loop starting at 1 (since 0 is you) .. and stops when
//this.a reaches playerscount
if (players[this.a].id>-1) {
//if its not a npc character..
showimg this.a+this.beginindex,@#v(players[this.a].hearts),players[this.a].x+.75,players[this.a].y-1;
//does a text showimg .. it uses the players array and this.a
// to check the players health,x, and y value..
}
}
this.oldshow=this.beginindex+playerscount;
//saves the highest value of the showimg .. for the hiding
}
there.. ^_^
yeah its from dbz o.o but so what ;D