Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   NPC's (https://forums.graalonline.com/forums/showthread.php?t=134266017)

tstre 03-17-2012 05:41 PM

NPC's
 
I need help!
Ok, so I deleted my whole server, but whenever I click on the NPC's folder, my RC disconnects. I cannot click on the npcs folder to delete them! That's the only things left on the server, and it's NPC's such as "npcs/npclocalnpc". I have to delete them 1 by 1 on client RC. Is there any type of script I can use to delete them fully? Without deleting them manually (1 by 1), Thanks!

cbk1994 03-17-2012 05:47 PM

Not really. You can't modify that folder via scripts serverside, and clientside you'd have to use client-RC stuff which is typically for privileged scripts only, I think.

Did you try using findNPC to find each of the local DB NPCs and then calling destroy() on them?

Alternatively you could give yourself partial folder rights like "rw npcs/localnpca*" and then "localnpcb" etc (doing this intelligently if a lot of them start with the same few characters).

tstre 03-17-2012 05:58 PM

Mind giving me a script real quick?

Crow 03-17-2012 06:11 PM

Quote:

Originally Posted by tstre (Post 1688981)
Mind giving me a script real quick?

Quote:

Originally Posted by cbk1994 (Post 1688978)
You can't modify that folder via scripts serverside

To call destroy() on them, simply do:
PHP Code:

function onCreated()
  
findNPC("InsertNameHere").destroy(); 

If that's what you were asking for. Nothing else to provide anyway though.

tstre 03-17-2012 06:18 PM

Didn't work, I used

function onCreated()
findNPC("npcs/localnpc").destroy();

(In the Control-NPC).

cbk1994 03-17-2012 06:20 PM

Quote:

Originally Posted by tstre (Post 1688981)
Mind giving me a script real quick?

Try this. I can't guarantee it'll work if the levels have been deleted.

PHP Code:

// put this in a DB NPC
// DO NOT RUN THIS ON A SERVER WHERE YOU DON'T WANT TO DELETE ALL NPCS
function onCreated() {
  
temp.folder.loadFolder("npcs/npclocalnpc*"false);
  
  for (
temp.file temp.folder) {
    
temp.fileName removeEscapesFromFileName(temp.file);
    
temp.fileName temp.fileName.substring(3temp.fileName.length() - 7);
    
    
temp.npc findNPC(temp.fileName);
    
temp.npc.destroy();
  }



fowlplay4 03-17-2012 06:23 PM

This should go through a kill everything.

PHP Code:

function onCreated() {
  
maxlooplimit 100000;
  
temp.lvls.loadfolder("levels/*.nw"1);
  for (
temp.lvltemp.lvls) {
    
temp.npcs findlevel(temp.lvl).npcs;
    for (
temp.npctemp.npcs) {
      
temp.npc.destroy();
    }
  }
  echo(
"EVERYTHING HAS BEEN DESTROYED");


Then you'll have to clearnpcs manually for your gmaps. I.e.

/clearnpcs yourworld.gmap

tstre 03-17-2012 06:26 PM

So I should readd the levels first and then try the script?

tstre 03-17-2012 06:30 PM

Oh, thanks guys.
Chris, your's worked, thanks.
(I didnt try yours FP4, but thanks xP)


All times are GMT +2. The time now is 08:44 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.