Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   destroy(); (https://forums.graalonline.com/forums/showthread.php?t=76265)

theHAWKER 08-13-2007 11:00 PM

destroy();
 
Ive made a target system, but the targets keep responing, making the targets not disapear and reapear x.x

i need it to destroy every time a player enters and then recreate one.

this is my script:
PHP Code:

//NPC Made By *theHAWKER
function onPlayerChats(){
if (
clientr.staff true){
if (
player.chat "destroy"){
destroy();
}
}
}
function 
onCreated(){
  
setshape(1,32,48);
  
setimg("gl_target.png");
  
this.chat "Shoot Me!";
  
setTimer(.1);
}
function 
onActionAdd(){
  
with(findplayer(params[0])){
    
player.rupees += int(random(0,20));
  }
}
function 
onTimeout(){
hide();
sleep(random(1,3));
show();
sleep(random(1,3));
  
setTimer(.3);
}
//#CLIENTSIDE
function onWasShot(){
  
this.chat "Hit!";
  
triggerserver("gui","-System","addrupees",player.account,int(random(0,20)));
  
sleep(.5);
  
this.chat "Shoot Me!";



DustyPorViva 08-13-2007 11:06 PM

this.destroy()?

theHAWKER 08-13-2007 11:30 PM

Quote:

Originally Posted by DustyPorViva (Post 1339769)
this.destroy()?

whats the "this." for? it destroys it with destroy();

Angel_Light 08-13-2007 11:40 PM

try thiso. to access the object,

Chompy 08-13-2007 11:45 PM

Quote:

Originally Posted by Angel_Light (Post 1339774)
try thiso. to access the object,

what object? o.o

theHAWKER 08-13-2007 11:59 PM

umm, i need a script like
function onPlayerEnters(){
destroy():
sleep(.1);
onCreated();
}

but that wont work x.x

DustyPorViva 08-14-2007 12:01 AM

O.o that won't work. You can't call a function in a script that isn't there.
Instead of destroying it, set some kind of check to see if it is active or not(inactive on creation, active when told to be).

zokemon 08-14-2007 12:08 AM

Just do something like:
NPC Code:
function doWhatever() {
hide();
sleep(0.1);
temp.n = putnpc2(x,y,"");
n.join("whatever");
destroy();
}



When you call destroy, it IMMEDIATELY stops the script (like return).

theHAWKER 08-14-2007 12:31 AM

Quote:

Originally Posted by zokemon (Post 1339789)
Just do something like:
NPC Code:
function doWhatever() {
hide();
sleep(0.1);
temp.n = putnpc2(x,y,"");
n.join("whatever");
destroy();
}



When you call destroy, it IMMEDIATELY stops the script (like return).

whats this part do?

temp.n = putnpc2(x,y,"");

n.join("whatever");

Chompy 08-14-2007 01:14 AM

Quote:

Originally Posted by theHAWKER (Post 1339800)
whats this part do?

temp.n = putnpc2(x,y,"");

n.join("whatever");

it puts and npc at x and y, and makes n scope to the object that was dropped to x,y

n.join() - n scopes to the dropped npc, so it makes the dropped npc at x,y join a the class "whatever"

zokemon 08-14-2007 02:57 AM

Quote:

Originally Posted by Chompy (Post 1339808)
it puts and npc at x and y, and makes n scope to the object that was dropped to x,y

n.join() - n scopes to the dropped npc, so it makes the dropped npc at x,y join a the class "whatever"

Exactly.

Inverness 08-14-2007 03:05 AM

Quote:

Originally Posted by Angel_Light (Post 1339774)
try thiso. to access the object,

Stop telling people to do that, its not the right way, thats only used inside a with block.

theHAWKER 08-14-2007 04:01 AM

Quote:

Originally Posted by zokemon (Post 1339789)
function doWhatever() {

what would that be under? created? playerenters? timeout?

xXziroXx 08-14-2007 04:11 AM

theHAWKER, perhaps you should stop for a second, take a deep breath and ask yourself the question:

Am I in over my head?

zokemon 08-14-2007 05:16 AM

Quote:

Originally Posted by theHAWKER (Post 1339850)
what would that be under? created? playerenters? timeout?

doWhatever() was a function I made up on the spot. It's not "in" anything because function definitions can't be nested inside each other. You can call it whatever (onCreated, onPlayerEnters, onImaCheeseBurger), I just was giving you an example.


All times are GMT +2. The time now is 01:23 PM.

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