Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Send params to putnpc2? (https://forums.graalonline.com/forums/showthread.php?t=71846)

JkWhoSaysNi 01-31-2007 09:48 PM

Send params to putnpc2?
 
I'm creating a projectile using putnpc2 but I want to send some data to it. It cant read from player.attr.

Is there any way to send some parameters to an NPC created using putnpc2 with a joined class?

Thanks :)

Andy0687 01-31-2007 09:54 PM

I doubt its the most efficient, but you could always pass them to a DB NPC and use

this.variable = FindNPC("NPC").variable;

or set them to a temporary server variable?

JkWhoSaysNi 01-31-2007 09:59 PM

but how do i identify the npc when using findnpc?

There could be more than one instance of the projectile class.

Chompy 01-31-2007 10:02 PM

when the npc was created, make it save the npc id it was :o ( (npccount - 1) I think?), then use the npc id :]

Andy0687 01-31-2007 10:09 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1271762)
but how do i identify the npc when using findnpc?

There could be more than one instance of the projectile class.

Well this is what i mean for example

PHP Code:

function onActionServerside() {
 
FindNPC("Params").power clientr.power;
}
//#CLIENTSIDE
function onWeaponFired() {
 
triggerserver("gui"this.name"power");
 
putnpc2...


Then in the class you have something like

PHP Code:

function onCreated() {
 
this.power FindNPC("Params").power;


Hope thats what you were asking anyways and im not making it needlessly complex.

Riot 01-31-2007 10:12 PM

You mean..

HTML Code:

with (putnpc2(x, y, "join someclass;"))
{
  this.something = somevar;
  this.somefunc();
}

or
HTML Code:

temp.npc putnpc2(x, y, "join someclass;");
  temp.npc.something = somevar;
  temp.npc.somefunc();


hotrian 01-31-2007 10:13 PM

NPC Code:

thiso.param = "rawrs";
with (npcs[npcs.size()-1]) {
this.string = thiso.param;
}


or so

hotrian 01-31-2007 10:13 PM

Quote:

Originally Posted by Riot (Post 1271773)
You mean..

HTML Code:

with (putnpc2(x, y, "join someclass;"))
{
  this.something = somevar;
  this.somefunc();
}

or
HTML Code:

temp.npc putnpc2(x, y, "join someclass;");
  temp.npc.something = somevar;
  temp.npc.somefunc();


with (putnpc2) works?
"join(\"someclass\");"

Skyld 01-31-2007 10:15 PM

Quote:

Originally Posted by hotrian (Post 1271776)
"join(\"someclass\");"

It should be "this.join(\"someclass\");", but what is the point in overcomplicating it when "join someclass;" is clearer in the case of putnpc2()?

Riot 01-31-2007 10:16 PM

Quote:

Originally Posted by hotrian (Post 1271776)
with (putnpc2) works?
"join(\"someclass\");"

putnpc2 returns the object of the NPC. And I prefer to just use the old join as it looks better than "join(\"someclass\");".

hotrian 01-31-2007 10:16 PM

Quote:

Originally Posted by Skyld (Post 1271780)
It should be "this.join(\"someclass\");", but what is the point in overcomplicating it when "join someclass;" is clearer in the case of putnpc2()?

why this., doesnt it already assume? Or is it instead joining the script to the script that called it or so?

@Riot
Yea? I didn't know you could pull the object of a putnpc2

Skyld 01-31-2007 10:17 PM

Quote:

Originally Posted by hotrian (Post 1271782)
why this., doesnt it already assume? Or is it instead joining the script to the script that called it or so?

Because you should specify the object you're working with for clarity, and I guess easier later editing.

hotrian 01-31-2007 10:17 PM

Quote:

Originally Posted by Skyld (Post 1271783)
Because you should specify the object you're working with for clarity, and I guess easier later editing.

But doesn't it already know..? Its always worked for me without it XD

Skyld 01-31-2007 10:18 PM

Quote:

Originally Posted by hotrian (Post 1271784)
But doesn't it already know..? Its always worked for me without it XD

It will work, yes, but like I said, you should be clear on what you're working with, for at least clarity and consistency.

JkWhoSaysNi 01-31-2007 10:26 PM

ok, I found a better way.


looks messy, but works and should be more efficient than findnpc()

PHP Code:

putnpc2(player.x,player.y,"join(\"test_projectile2\"); this.value=" this.value ";"); 

edit: I didn't see Skyld's posts.


All times are GMT +2. The time now is 04:56 PM.

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