Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-28-2006, 10:18 PM
AnarchySquare AnarchySquare is offline
Registered User
Join Date: Jun 2006
Posts: 4
AnarchySquare is on a distinguished road
passing vars -> putnpc

I'm trying to pass a varible (account name) through putnpc so that the NPC can have a "master" when it's created. I know a few ghetto ways of doing, like putting a flag in the "master"'s account and having the NPC scan through players in the level to detect that flag, and after using the putnpc doing a triggeraction on the NPC setting the "master"'s account there.

Is there a more effecient way of doing this?
Reply With Quote
  #2  
Old 06-28-2006, 10:43 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
If I understand you correctly, you can do something like...

NPC Code:

function onCreated()
{
putnpc2(x,y,"join(\"classname\");
this.master = player.account;
");
}



Then in a class npc...

NPC Code:

//#CLIENTSIDE
function onPlayerChats()
{
if ( player.chat == "/test" ) {
if ( this.master == player.account ) {
chat = "Hello, Master!";
} else {
chat = "You are not my master!";
}
}
}





It all depends on how you want to do it.
Reply With Quote
  #3  
Old 06-28-2006, 10:50 PM
AnarchySquare AnarchySquare is offline
Registered User
Join Date: Jun 2006
Posts: 4
AnarchySquare is on a distinguished road
That won't work. When the putnpc is placed it has no communication between itself and your account...it's like a blank script...so you can't pass the account.

That's the problem I ran into.
Reply With Quote
  #4  
Old 06-28-2006, 11:18 PM
Giltwist2k1 Giltwist2k1 is offline
Registered User
Giltwist2k1's Avatar
Join Date: Jun 2002
Posts: 13
Giltwist2k1 is on a distinguished road
Send a message via ICQ to Giltwist2k1 Send a message via AIM to Giltwist2k1 Send a message via Yahoo to Giltwist2k1
isn't that what playero.account is for?

Quote:
playero.var variables of the original player object, in generally the player who has invoked the event (e.g. playertouchsme)
Failing that, you could triggeraction it right after you placed it.
Reply With Quote
  #5  
Old 06-28-2006, 11:18 PM
Snakeandy7 Snakeandy7 is offline
"Member ID=2610"
Snakeandy7's Avatar
Join Date: Mar 2003
Posts: 987
Snakeandy7 is on a distinguished road
with(putnpc2(x, y, "join class")){ stuffs in here };

edit to the post below: try it and find out :], it works wonders.
__________________
"Freedom is best I tell thee
of all things to be won
then never live within the bond
of slavery my son".



Last edited by Snakeandy7; 06-28-2006 at 11:49 PM..
Reply With Quote
  #6  
Old 06-28-2006, 11:29 PM
AnarchySquare AnarchySquare is offline
Registered User
Join Date: Jun 2006
Posts: 4
AnarchySquare is on a distinguished road
Quote:
Originally Posted by Snakeandy7
with(putnpc2(x, y, "join class")){ stuffs in here };
Wouldn't work exactly like that, but yeah...I get the concept...smart.

Gilt, That wouldn't work. It's not like playertouchsme...it's a fresh NPC with and it's had no communication with another NPC or player.

[Edit] Actually I don't even think that would work...in order to use with() on an NPC it has to be a) a database NPC or b) you have to have the index of the NPC in combination with npcs[] I do believe...[/Edit]
Reply With Quote
  #7  
Old 06-28-2006, 11:52 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Oh, you silly geese.

PHP Code:
this.pet putnpc2(x,y,"join(\"class\");");
this.pet.owner player.account
Reply With Quote
  #8  
Old 06-28-2006, 11:52 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Oh, and with() can get ANY object.
Any object at all. GUI, NPCs, players, images, ganis, ect.
Reply With Quote
  #9  
Old 06-29-2006, 03:44 AM
AnarchySquare AnarchySquare is offline
Registered User
Join Date: Jun 2006
Posts: 4
AnarchySquare is on a distinguished road
Quote:
Originally Posted by Yen
Oh, and with() can get ANY object.
Any object at all. GUI, NPCs, players, images, ganis, ect.

But if you're using with() don't you need to specify what you're searching for? Like with (players[])?


Thanks for the answer.
Reply With Quote
  #10  
Old 06-29-2006, 05:12 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by AnarchySquare
Wouldn't work exactly like that, but yeah...I get the concept...smart.
It does actually work exactly like that.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #11  
Old 06-29-2006, 03:32 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Quote:
Originally Posted by AnarchySquare
But if you're using with() don't you need to specify what you're searching for? Like with (players[])?


Thanks for the answer.
Well, objects also have names.
You do normally need to do with (players[]), but you could also do something like:
PHP Code:
reference findplayer("Yen");
with (reference) {


You can also just put in the name of a GUI object, and it will automatically refer to that GUI.
Reply With Quote
  #12  
Old 06-29-2006, 04:31 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Yen
Well, objects also have names.
You do normally need to do with (players[]), but you could also do something like:
PHP Code:
reference findplayer("Yen");
with (reference) {


You can also just put in the name of a GUI object, and it will automatically refer to that GUI.
Just for clarification, it doesn't have to be a variable either. If a function returns an object, you can use the function itself.

PHP Code:
with(findPlayer("Yen")) {
  
player.chat "Hi thar";

You can also do:

PHP Code:
this.foo = new TStaticVar();
this.foo.bar "Wee"
this.foo.baz "Woo";

with(this.foo) {
  echo(
bar);
  echo(
this.baz);

would output:
PHP Code:
Wee
Woo 
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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 11:57 AM.


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