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 07-02-2007, 05:50 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
putnpc2 problem

PHP Code:
public function dropItem(id)
{
  
temp."object_item";

  
with(findplayer("Chompy")) {
    
with(putnpc2(3030"this.join(\"" "\" );")) {
      ...
    }
  }

I'm doing this from a weapon npc..
Any reason why this won't work?

Or do I have to change the npcs array (with(npcs[npcs.size() - 1]))?

Or is there any other methods?
__________________
Reply With Quote
  #2  
Old 07-02-2007, 06:12 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
It would be nice to know what doesn't work.

I'm personally not a fan about double-with's... Nor am I a fan of 'temp.n' mysteriously becoming 'n'.

It could be on a gmap, and showing at the top-left corner... As for the npcs array trick, that was before putnpc2 returned an object.

How I usually do it is:

PHP Code:
public function dropItemid )
  {
  
temp."object_item";

  
temp.obj putnpc23030"" );
  
temp.obj.jointemp.);
  
// ...
  

Reply With Quote
  #3  
Old 07-02-2007, 06:43 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 Novo View Post
It would be nice to know what doesn't work.

I'm personally not a fan about double-with's... Nor am I a fan of 'temp.n' mysteriously becoming 'n'.

It could be on a gmap, and showing at the top-left corner... As for the npcs array trick, that was before putnpc2 returned an object.

How I usually do it is:

PHP Code:
public function dropItemid )
  {
  
temp."object_item";

  
temp.obj putnpc23030"" );
  
temp.obj.jointemp.);
  
// ...
  

Oh yeah, the error was it would just return an error in rc..

And, with your example I could do
PHP Code:
public function dropItem(id)
{
  
temp.obj putnpc2(3030"");
  
temp.obj.join("class name");
  
temp.obj.id id;

and then I would be able to do this.id in the class and return the id gived to the function dropItem?

Edit: Doesn't work in a WNPC
__________________
Reply With Quote
  #4  
Old 07-02-2007, 08:48 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Chompy View Post
Oh yeah, the error was it would just return an error in rc..

And, with your example I could do
PHP Code:
public function dropItem(id)
{
  
temp.obj putnpc2(3030"");
  
temp.obj.join("class name");
  
temp.obj.id id;

and then I would be able to do this.id in the class and return the id gived to the function dropItem?

Edit: Doesn't work in a WNPC
id is a reserved variable. You can't overwrite it. ( Or is that npcid? or name? I'm not sure anymore. )
Reply With Quote
  #5  
Old 07-02-2007, 09:38 PM
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
id is a static variable in TServerPlayer and TServerNPC.
name is static in TGraalVar (everything).
__________________
Reply With Quote
  #6  
Old 07-02-2007, 11:11 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
But, I still have the problem..
Inver told me to do level.putnpc2()

When using that no errors occured in rc, but it wouldn't put the class in the level

Problem solved:

two methods works: (Thanks Inver for the level.putnpc2())

PHP Code:
temp.obj findplayer(this.acct).level.putnpc2(3030"");
temp.obj.join("classname");
temp.obj.var = "foo"
or

PHP Code:
with(findplayer(this.acct)) {
  
temp.obj this.level.putnpc2(3030"");
  
temp.obj.join("classname");
  
temp.obj.var = "foo";

__________________
Reply With Quote
  #7  
Old 07-02-2007, 11:38 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 Chompy View Post
When using that no errors occured in rc, but it wouldn't put the class in the level
You can't "put a class in a level" (well, I guess you could do level.join(class) but that isn't what we are talking about). When you use join() you are only telling the script to append what is in the class to the current script. Of course it will overwrite function definitions and stuff but in essence, that is all that it is doing.

Classes are not objects.
__________________
Do it with a DON!
Reply With Quote
  #8  
Old 07-02-2007, 11:54 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 zokemon View Post
You can't "put a class in a level" (well, I guess you could do level.join(class) but that isn't what we are talking about). When you use join() you are only telling the script to append what is in the class to the current script. Of course it will overwrite function definitions and stuff but in essence, that is all that it is doing.

Classes are not objects.
Hmm, you're right, I think I meant something more the lines of
"It didn't put the npc that had the class joined to itself at the given coords"

but it's fixed now :o
__________________
Reply With Quote
  #9  
Old 07-02-2007, 11:59 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 Chompy View Post
Hmm, you're right, I think I meant something more the lines of
"It didn't put the npc that had the class joined to itself at the given coords"

but it's fixed now :o
Alright
__________________
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 01:12 PM.


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