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 05-28-2009, 09:29 PM
Struggler Struggler is offline
Zone Repulser =D
Struggler's Avatar
Join Date: May 2006
Posts: 54
Struggler is an unknown quantity at this point
Problem With Destroy()

I'm havin troubles getting this script to delete itself after the player touchs it.. Can someone tell me whats worng with it?
PHP Code:
function onCreated(){
  
setshape13232);
  
setimg"beer.png");
}
function 
onActionServerside(){
  if(
params[0] == "destroy"){
    
destroy();
  }
}
//#CLIENTSIDE
function onPlayerTouchsme(){
  
setimg"beer.png");
  
setshape13232);
  
player.hearts += 5;
  
player.bombs += 5;
  
player.darts += 5;
  
triggerserver("gui",this.name,"destroy");
  
destroy();

Reply With Quote
  #2  
Old 05-28-2009, 10:02 PM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
triggerserver(..) only works on weapons.

Use this:
PHP Code:
triggeraction(this..5this..5"Trigger"); 
And to receive:
PHP Code:
function onCreated() {
  
setshape(13232);
}

function 
onActionTrigger() {
  
this.destroy();

Reply With Quote
  #3  
Old 05-28-2009, 10:15 PM
Struggler Struggler is offline
Zone Repulser =D
Struggler's Avatar
Join Date: May 2006
Posts: 54
Struggler is an unknown quantity at this point
okay, now i gots this, still doesnt work:
PHP Code:
function onCreated(){
  
setimg"beer.png");
  
setshape(13232);
}
function 
onActionTrigger() { 
  
destroy(); 
}
//#CLIENTSIDE
function onPlayerTouchsme(){
  
setimg"beer.png");
  
setshape13232);
  
player.hearts += 5;
  
player.bombs += 5;
  
player.darts += 5;
  
triggeraction(this..5this..5"Trigger");  

Reply With Quote
  #4  
Old 05-28-2009, 10:21 PM
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
Try adding a null parameter to the trigger

triggeraction(this.x + .5, this.y + .5, "Trigger", null);

I'm not sure why, but it seems to work
Reply With Quote
  #5  
Old 05-28-2009, 10:28 PM
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 salesman View Post
Try adding a null parameter to the trigger

triggeraction(this.x + .5, this.y + .5, "Trigger", null);

I'm not sure why, but it seems to work
Yes, triggeraction expects 4 params, in the new version it's only 3
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #6  
Old 05-28-2009, 11:06 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I assume this is in a level NPC? In that case, you should just use

PHP Code:
function onCreated(){
  
setshape13232);
  
setimg"beer.png");
}
//#CLIENTSIDE
function onPlayerTouchsme(){
  
setimg"beer.png");
  
setshape13232);
  
player.hearts += 5;
  
player.bombs += 5;
  
player.darts += 5;
  
hide();

__________________
Reply With Quote
  #7  
Old 05-29-2009, 12:17 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by cbk1994 View Post
I assume this is in a level NPC? In that case, you should just use

PHP Code:
function onCreated(){
  
setshape13232);
  
setimg"beer.png");
}
//#CLIENTSIDE
function onPlayerTouchsme(){
  
setimg"beer.png");
  
setshape13232);
  
player.hearts += 5;
  
player.bombs += 5;
  
player.darts += 5;
  
hide();


That would just hide the NPC but the NPC itself would still be there. If you use destroy, the NPC itself is destroyed.

It all depends on how he wants to use it, but hide is not the same as destroy.
Reply With Quote
  #8  
Old 05-29-2009, 12:07 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Using hide() is not very good, since it still exists, making it just use CPU it shouldn't.
Reply With Quote
  #9  
Old 05-29-2009, 12:29 PM
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 Pelikano View Post
Using hide() is not very good, since it still exists, making it just use CPU it shouldn't.
Well, memory actually. CPU would only be used if the script was actually doing something (it might use some minimal CPU but I mean MINIMAL)
__________________
Do it with a DON!
Reply With Quote
  #10  
Old 05-29-2009, 03:03 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by zokemon View Post
Well, memory actually. CPU would only be used if the script was actually doing something (it might use some minimal CPU but I mean MINIMAL)
whatever, it just uses something it shouldn't
Reply With Quote
  #11  
Old 05-29-2009, 09:57 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Gambet View Post
That would just hide the NPC but the NPC itself would still be there. If you use destroy, the NPC itself is destroyed.

It all depends on how he wants to use it, but hide is not the same as destroy.
Destroying would just make it come back when they reentered the level if it's done clientside, like I think he was trying to.
__________________
Reply With Quote
  #12  
Old 05-29-2009, 10:09 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 cbk1994 View Post
Destroying would just make it come back when they reentered the level if it's done clientside, like I think he was trying to.
He's using a class.
__________________
Reply With Quote
  #13  
Old 05-30-2009, 10:35 AM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by cbk1994 View Post
Destroying would just make it come back when they reentered the level if it's done clientside, like I think he was trying to.
Also if you tried to read his post, atleast tried, you'd see that he's doing it serverside.
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 06:58 AM.


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