Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   /reset npc NAME (https://forums.graalonline.com/forums/showthread.php?t=134260734)

MrOmega 10-06-2010 08:16 PM

/reset npc NAME
 
It would be nice if you could reset DbNPC's via script

with a NPC.reset();

or if you could do

sendToRc( "/reset npc" @ NPC);

cbkbud 10-06-2010 08:25 PM

Why?

MrOmega 10-06-2010 08:44 PM

I have certain scripting needs...

cbkbud 10-06-2010 08:58 PM

Quote:

Originally Posted by MrOmega (Post 1604531)
I have certain scripting needs...

Explain. You're probably doing it wrong if you require this.

MrOmega 10-06-2010 09:05 PM

I'm using an NPC as a main plot point for my server. It goes to another room and some vars change. Both client and server sides. My current work around is a lot parts of the script setting all the vars back to what they were when I created the NPC, (warpto() and all that) it just be a lot easier if I could just reset the NPC via script. This is more so for convenience.

Deas_Voice 10-06-2010 09:37 PM

when you're doing a levelnpc in a DBNPC for easier testing, you often have to reset it because of clientside scripting to make the function "onCreated" to be called, therefor, i agree with this idea.

cbkbud 10-06-2010 09:53 PM

Quote:

Originally Posted by MrOmega (Post 1604537)
I'm using an NPC as a main plot point for my server. It goes to another room and some vars change. Both client and server sides. My current work around is a lot parts of the script setting all the vars back to what they were when I created the NPC, (warpto() and all that) it just be a lot easier if I could just reset the NPC via script. This is more so for convenience.

You should just set variables in an init function.

MrOmega 10-06-2010 11:50 PM

Yeah but the convenience of .reset() seems more practical.

12171217 10-07-2010 12:46 AM

You can store all your variables in a new object..

Like this.state = new TStaticVar();

Then declare all the variables as such:

this.state.health = 10;

Then when you need to clear all the variables, you can do:

this.state = null;

and then simply initialize it again.

Skyld 10-07-2010 01:29 AM

Quote:

Originally Posted by MrOmega (Post 1604584)
Yeah but the convenience of .reset() seems more practical.

And also entirely destructive :monocle: Just save your important variables in an easy-to-destroy TStaticVar, or find a way to do what you are doing without constantly having to reset it.

MrOmega 10-07-2010 03:07 AM

Quote:

Originally Posted by Skyld (Post 1604628)
And also entirely destructive :monocle: Just save your important variables in an easy-to-destroy TStaticVar, or find a way to do what you are doing without constantly having to reset it.

That's what I'm currently doing. I'd just like a command to do it via script.

fowlplay4 10-07-2010 03:29 AM

Quote:

Originally Posted by MrOmega (Post 1604672)
That's what I'm currently doing. I'd just like a command to do it via script.

make a utlity class, and join it to the npc, now all the npcs you want to have the reset function will have it.

MrOmega 10-07-2010 03:58 AM

Quote:

Originally Posted by fowlplay4 (Post 1604680)
make a utlity class, and join it to the npc, now all the npcs you want to have the reset function will have it.

How would thaty reseting a NPC like when reseting via RC?

Cubical 10-07-2010 04:05 AM

onRCChat()
in the Control-NPC then you can do /npc reset whatever

MrOmega 10-07-2010 05:51 AM

O_o I have to try this tomorrow, never heard of it.

Cubical 10-07-2010 06:22 AM

Quote:

Originally Posted by MrOmega (Post 1604707)
O_o I have to try this tomorrow, never heard of it.

It only works in the Control-NPC
PHP Code:

function onRCChat(cmd){
  switch(
cmd){
    case 
"reset":
      
sendtorc("/reset" SPC params[1]);
      break;
    default:
      
sendtorc("Commands")
      
sendtorc("/npc reset account - resets player ");
      break;
  }



MrOmega 10-07-2010 03:12 PM

I need the NPC itself to reset itself, not it to reset a player.

fowlplay4 10-07-2010 03:38 PM

Quote:

Originally Posted by MrOmega (Post 1604762)
I need the NPC itself to reset itself, not it to reset a player.

It's example usage of the event/function, not copy-pasta for your specific situation.

MrOmega 11-02-2010 06:41 PM

bump

Skyld 11-02-2010 08:41 PM

I still do not believe this is necessary. Like it was said earlier in the thread, if you are needing to reset an NPC routinely then you are doing something wrong.

Deas_Voice 11-02-2010 09:07 PM

Quote:

Originally Posted by Skyld (Post 1609787)
I still do not believe this is necessary. Like it was said earlier in the thread, if you are needing to reset an NPC routinely then you are doing something wrong.

what about clientside scripting? you have to reset the DBNPC for it to call "onCreated" on clientside :\

MrOmega 11-02-2010 10:53 PM

Quote:

Originally Posted by Skyld (Post 1609787)
I still do not believe this is necessary. Like it was said earlier in the thread, if you are needing to reset an NPC routinely then you are doing something wrong.

Not that I am doing something wrong but this would be very convient and you must reset an NPC for clientside onCreated() to be called 'again'
Dang it, Deas beat me to it!

fowlplay4 11-02-2010 11:25 PM

You can silently update a level (server-side) using:

fileupdate("level.nw");

Perhaps that would satisfy your wants.

Deas_Voice 11-03-2010 12:27 AM

Quote:

Originally Posted by fowlplay4 (Post 1609826)
You can silently update a level (server-side) using:

fileupdate("level.nw");

Perhaps that would satisfy your wants.

that doesn't even work like "update level" :oo:

fowlplay4 11-03-2010 12:48 AM

Quote:

Originally Posted by Deas_Voice (Post 1609833)
that doesn't even work like "update level" :oo:

Work's like uploading a level, probably need a path/to/level.nw

Deas_Voice 11-03-2010 05:40 PM

Quote:

Originally Posted by fowlplay4 (Post 1609840)
Work's like uploading a level, probably need a path/to/level.nw

Quote:

Originally Posted by Script help for 'fileupdate'
fileupdate(str) - returns boolean - requests the download or reloading of a file
Clientside:
fileupdate(str) - returns boolean

uh, clientside?
so how are your little idea supposed to work to prevent having to do "reset" on the dbnpc to call clientsided "onCreated"? i've confused myself :cool:

fowlplay4 11-03-2010 07:36 PM

The only way you're going be able to "reset" an npc is with sendtorc("/npc reset dbname") on the server-side, if you update the level, you'll update the client-side scripts as well.

I personally believe you should probably be doing something differently if you have to reset the NPC to get it working properly.

Deas_Voice 11-03-2010 08:53 PM

Quote:

Originally Posted by fowlplay4 (Post 1609968)
I personally believe you should probably be doing something differently if you have to reset the NPC to get it working properly.

such as using it as a testnpc for a levelnpc? x)
i often use it when i do levelnpc instead of having to alter the level before ive made the script.. and then i put it in a class when im done.. is that different enuf for you? ;)

fowlplay4 11-03-2010 09:43 PM

Quote:

Originally Posted by Deas_Voice (Post 1609988)
such as using it as a testnpc for a levelnpc? x)
i often use it when i do levelnpc instead of having to alter the level before ive made the script.. and then i put it in a class when im done.. is that different enuf for you? ;)

I just put it in a class script to begin with and create, update and destroy instances of it as I please.


All times are GMT +2. The time now is 12:06 PM.

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