Reset level script.

i need a npc that when the player says “reset board”, the level goes back to its original state and all npcs go back to where they were first located.

if wondering what for, ive made a chess board in the start area. still working out kinks, but it looks good so far. just need that script so when people are done playing, you can say “reset board” and all the pieces go back to where they came.

thanks in advance. :open_mouth:

Yes I also agree this would be nice. Often the levels need to be reset after a few players have been on them and interacted with the npcs. Maybe even a timer that resets (updates) levels on regular intervals. Just an idea.

Have you considered just setting up each piece so that if the player says “reset board” they each individually go back to their place, or are all deleted and new pieces spawned?

the original pieces go back to where they were, pretty much what ever is easier.

if(playerenters) {
setarray this.level,4096;
for(this.i=0;this.i<4096;this.i++) this.level[this.i]=tiles[this.i%64,int(this.i/64)];
}

if(playerchats && strequals(#c,reset board)) {
for(this.i=0;this.i<4096;this.i++){
tiles[this.i%64,int(this.i/64)] = this.level[this.i];
}
updateboard 0,0,64,64;
}

Unless you use a static array, changes will be “saved” when a play enters the level after modification.

i tried the code you sent beholder, but it makes the tileset go all over the level instead of just putting the npcs back in the rightful spot. i appreciate the attempt though :slight_smile:

Thanks for the fix Nalin.
I wrote that 3 minutes after waking up just before having to get my ass to work. Lol

its all good. the board works well, i remember when i was staff there was an “update level” command, i dunno if it was written into the staff commands or something, but that might just work as good i guess. maybe make it a chess tourney? i dunno. thanks for trying though :smiley:

update level is a preset staff command.

How about…

if (playerenters && !this.in) {
  set this.in;
  setarray this.px,100;
  setarray this.py,100;
  for (i=0;i<npcscount;i++) {
    this.px[i] = npcs[i].x;
    this.py[i] = npcs[i].y;
  }
}
if (playerchats && strequals(#c,move npcs)) {
  for (i=0;i<npcscount;i++) {
    npcs[i].x = this.px[i];
    npcs[i].y = this.py[i];
  }
}

This only moves them to their original position. Nothing more.

How bout a simple idea since you want to give everyone staff rights :smiley:

defaultaccount.txt
LOCALRIGHTS 8
IPRANGE ...

im gonna try it out in a bit and see how it rolls, thanks.

Saves eh? coool. How do they work exactly? I remember hearing that there were 9-10 of them to save extra features of an npc. But each npc has 10 of them, ie. save[0] is only the save[0] of THAT npc? Also, the gserver must send these values to all new players the same as it does the other major npcprops, or it would encounter the same problem as downsiders solution.

Every NPC has their own, 0~9
Changes to them [made locally] are broadcasted to other players.
They hold an integer based variable from 0~220

If multiple people are changing the save[x] at a very quick speed, overlapping/replacing will occur, as would happen with any local vs serverside prop.