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 08-13-2007, 11:00 PM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
Question 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!";

__________________
**FLIP OUT**
Reply With Quote
  #2  
Old 08-13-2007, 11:06 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
this.destroy()?
Reply With Quote
  #3  
Old 08-13-2007, 11:30 PM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
Quote:
Originally Posted by DustyPorViva View Post
this.destroy()?
whats the "this." for? it destroys it with destroy();
__________________
**FLIP OUT**
Reply With Quote
  #4  
Old 08-13-2007, 11:40 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
try thiso. to access the object,
__________________
Deep into the Darkness peering...
Reply With Quote
  #5  
Old 08-13-2007, 11:45 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Angel_Light View Post
try thiso. to access the object,
what object? o.o
__________________
Reply With Quote
  #6  
Old 08-13-2007, 11:59 PM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
umm, i need a script like
function onPlayerEnters(){
destroy():
sleep(.1);
onCreated();
}

but that wont work x.x
__________________
**FLIP OUT**
Reply With Quote
  #7  
Old 08-14-2007, 12:01 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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).
Reply With Quote
  #8  
Old 08-14-2007, 12:08 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
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).
__________________
Do it with a DON!
Reply With Quote
  #9  
Old 08-14-2007, 12:31 AM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
Quote:
Originally Posted by zokemon View Post
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");
__________________
**FLIP OUT**
Reply With Quote
  #10  
Old 08-14-2007, 01:14 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by theHAWKER View Post
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"
__________________
Reply With Quote
  #11  
Old 08-14-2007, 02:57 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Chompy View Post
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.
__________________
Do it with a DON!
Reply With Quote
  #12  
Old 08-14-2007, 03:05 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Angel_Light View Post
try thiso. to access the object,
Stop telling people to do that, its not the right way, thats only used inside a with block.
__________________
Reply With Quote
  #13  
Old 08-14-2007, 04:01 AM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
Question

Quote:
Originally Posted by zokemon View Post
function doWhatever() {
what would that be under? created? playerenters? timeout?
__________________
**FLIP OUT**
Reply With Quote
  #14  
Old 08-14-2007, 04:11 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
theHAWKER, perhaps you should stop for a second, take a deep breath and ask yourself the question:

Am I in over my head?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #15  
Old 08-14-2007, 05:16 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by theHAWKER View Post
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.
__________________
Do it with a DON!
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 03:59 PM.


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