Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   "/clearnpcs" from Script (https://forums.graalonline.com/forums/showthread.php?t=134261001)

ZeroG 11-04-2010 12:21 AM

"/clearnpcs" from Script
 
Is it possible to clear all the npcs in the level with a script in the same way you would with "/clearnpcs *.nw" in RC? For example let's put this script on an npc:

PHP Code:

function onPlayerTouchsMe(){
  
clearnpcs osl.nw;


I'm 100% sure this isn't how you would do it, but it's just to help you understand what I mean.

Tigairius 11-04-2010 12:37 AM

PHP Code:

function onPlayerTouchsMe() {
  for (
temp.nlevel.npcs) {
    if (
temp.n.name.starts("localnpc")) {
      
temp.n.destroy();
    }
  }



salesman 11-04-2010 12:44 AM

would
PHP Code:

sendToRC("/clearnpcs level.nw"); 

also work? I've never tried.

ZeroG 11-04-2010 12:45 AM

This destroys the npcs, I meant like getting rid of them if they are already destoryed. I had an npc create a bunch of class npcs for a while that destored themselves after a few seconds and eventually it stopped creating them. When I typed "/clearnpcs osl.nw," then more class npcs started coming off of the original npc.

Tigairius 11-04-2010 12:47 AM

Quote:

Originally Posted by ZeroG (Post 1610053)
This destroys the npcs, I meant like getting rid of them if they are already destoryed. I had an npc create a bunch of class npcs for a while that destored themselves after a few seconds and eventually it stopped creating them. When I typed "/clearnpcs osl.nw," then more class npcs started coming off of the original npc.

You'll have to show us some code examples if you're going to require more help. Show us the script creating these NPCs.

ZeroG 11-04-2010 12:48 AM

And salesman, I tried that too, it didn't work:

PHP Code:

function onPlayerTouchsMe() {
  
sendToRC("/clearnpcs dodge.nw");



ZeroG 11-04-2010 12:52 AM

Here is the emitter:

PHP Code:

if (created) {
setshape 1,32,32;
}
function 
onPlayerChats(){
  if (
player.chat=="start"){
    if (
player.account=="Graal755284"){
      
settimer(0.1);
    }
  }
}
function 
onTimeout(){
  
sleep 1;
  
putnpc2(this.x,this.y,"join(\"dodge\");");
  
settimer(1);


Here is the class npc that is created:

PHP Code:

//#CLIENTSIDE
function onCreated(){
  
setimg("rock.png");
  
settimer(0.1);
  
dontblock();
}

function 
onTimeout(){
  
temp.dx=0.3;
  
this.x=this.x-temp.dx;
  if (
player.x>this.x-1.5 && player.x<this.x+1.5){
    if (
player.y>this.y-1.5 && player.y<this.y+1){
      
setani dead,;
      
player.chat="I was hit!";
      
player.x=30;
      
player.y=15;
      
destroy();
    }
  }
  if (
this.x<8){
    
destroy();
  }
  
settimer(0.01);


After a while, the rocks stop appearing, and I have to type "/clearnpcs dodge.nw" in the RC for it to continue spawning. I'm wondering if there is a function or something that can clear the npcs automatically.

Tigairius 11-04-2010 12:52 AM

The problem is that you need to destroy your dodge NPC on the serverside. Otherwise it only destroys clientside (which is what it's doing right now). Do you understand?

ZeroG 11-04-2010 12:54 AM

Yes. Thanks:)

Tigairius 11-04-2010 12:54 AM

My pleasure. :)

Cubical 11-04-2010 01:00 AM

would this work?
PHP Code:

  sendtonc("/clearnpcs" SPC player.level); 


ZeroG 11-04-2010 01:32 AM

I tried this:

PHP Code:

function onPlayerTouchsMe() {
sendtonc("/clearnpcs" SPC player.level);


And all it did was write "/clearnpcs dodge.nw" in the RC. Nothing actually happened. So that's a no, cubical.

fowlplay4 11-04-2010 01:42 AM

I've always considered sendtonc is the same thing as echo, and sendtorc the one that can perform the CLI stuff. Try sendtorc instead, pretty sure nothing happens though.

ZeroG 11-04-2010 01:45 AM

Yes, it doesn't work:p

Cubical 11-04-2010 02:36 AM

I have never used sendtonc for anything other than echoing, i just thought it could possibly work.


All times are GMT +2. The time now is 05:11 PM.

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