Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Problem With Destroy() (https://forums.graalonline.com/forums/showthread.php?t=85872)

Struggler 05-28-2009 09:29 PM

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();



Stryke 05-28-2009 10:02 PM

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();



Struggler 05-28-2009 10:15 PM

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");  



salesman 05-28-2009 10:21 PM

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

Tigairius 05-28-2009 10:28 PM

Quote:

Originally Posted by salesman (Post 1495007)
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

cbk1994 05-28-2009 11:06 PM

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();



Gambet 05-29-2009 12:17 AM

Quote:

Originally Posted by cbk1994 (Post 1495015)
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.

Pelikano 05-29-2009 12:07 PM

Using hide() is not very good, since it still exists, making it just use CPU it shouldn't.

zokemon 05-29-2009 12:29 PM

Quote:

Originally Posted by Pelikano (Post 1495189)
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)

Pelikano 05-29-2009 03:03 PM

Quote:

Originally Posted by zokemon (Post 1495202)
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 :D

cbk1994 05-29-2009 09:57 PM

Quote:

Originally Posted by Gambet (Post 1495040)
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.

Chompy 05-29-2009 10:09 PM

Quote:

Originally Posted by cbk1994 (Post 1495327)
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.

Pelikano 05-30-2009 10:35 AM

Quote:

Originally Posted by cbk1994 (Post 1495327)
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. ;)


All times are GMT +2. The time now is 09:17 AM.

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