Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-04-2010, 12:21 AM
ZeroG ZeroG is offline
Developer
Join Date: Oct 2010
Posts: 12
ZeroG is on a distinguished road
"/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.
Reply With Quote
  #2  
Old 11-04-2010, 12:37 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
PHP Code:
function onPlayerTouchsMe() {
  for (
temp.nlevel.npcs) {
    if (
temp.n.name.starts("localnpc")) {
      
temp.n.destroy();
    }
  }

__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 11-04-2010, 12:44 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
would
PHP Code:
sendToRC("/clearnpcs level.nw"); 
also work? I've never tried.
__________________
Reply With Quote
  #4  
Old 11-04-2010, 12:45 AM
ZeroG ZeroG is offline
Developer
Join Date: Oct 2010
Posts: 12
ZeroG is on a distinguished road
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.
Reply With Quote
  #5  
Old 11-04-2010, 12:47 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by ZeroG View Post
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.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #6  
Old 11-04-2010, 12:48 AM
ZeroG ZeroG is offline
Developer
Join Date: Oct 2010
Posts: 12
ZeroG is on a distinguished road
And salesman, I tried that too, it didn't work:

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

Reply With Quote
  #7  
Old 11-04-2010, 12:52 AM
ZeroG ZeroG is offline
Developer
Join Date: Oct 2010
Posts: 12
ZeroG is on a distinguished road
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.
Reply With Quote
  #8  
Old 11-04-2010, 12:52 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
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?
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #9  
Old 11-04-2010, 12:54 AM
ZeroG ZeroG is offline
Developer
Join Date: Oct 2010
Posts: 12
ZeroG is on a distinguished road
Yes. Thanks
Reply With Quote
  #10  
Old 11-04-2010, 12:54 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
My pleasure.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #11  
Old 11-04-2010, 01:00 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
would this work?
PHP Code:
  sendtonc("/clearnpcs" SPC player.level); 
Reply With Quote
  #12  
Old 11-04-2010, 01:32 AM
ZeroG ZeroG is offline
Developer
Join Date: Oct 2010
Posts: 12
ZeroG is on a distinguished road
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.
Reply With Quote
  #13  
Old 11-04-2010, 01:42 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #14  
Old 11-04-2010, 01:45 AM
ZeroG ZeroG is offline
Developer
Join Date: Oct 2010
Posts: 12
ZeroG is on a distinguished road
Yes, it doesn't work
Reply With Quote
  #15  
Old 11-04-2010, 02:36 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
I have never used sendtonc for anything other than echoing, i just thought it could possibly work.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:28 PM.


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