Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   PutNPC2 Questions (https://forums.graalonline.com/forums/showthread.php?t=134258106)

Jman9912 02-21-2010 02:48 AM

PutNPC2 Questions
 
First off, let me explain what i'm doing.

I'm making an npc which drops something when selected.

I've got a class which should read which image to show from a variable in the original weapon.

PHP Code:

with (putnpc2(x,y"join hat;")) {
  
this.hatImage "1";
  }
  } 

Is the method i'm trying to use. But whatn I read this.hatimage in the hat class, it is empty. PutNPC is executed serverside.

I've also tried it like this:
PHP Code:

   temp.npc putnpc2(player.xplayer.y"join(\"hat\");");

    
with(temp.npc) {
    
temp.hatImage "3";




Switch 02-21-2010 02:55 AM

Try this
PHP Code:

temp.npc putnpc2(player.xplayer.y"");
temp.npc.join("hat");
temp.npc.hatImage "3"


cbk1994 02-21-2010 05:05 AM

Quote:

Originally Posted by Switch (Post 1557549)
Try this
PHP Code:

temp.npc putnpc2(player.xplayer.y"");
temp.npc.join("hat");
temp.npc.hatImage "3"


Set the variables first.

PHP Code:

temp.npc putnpc2(player.xplayer.ynull);
npc.hatImage 3;
npc.join("hat"); 


Switch 02-21-2010 06:29 AM

Quote:

Originally Posted by cbk1994 (Post 1557563)
Set the variables first.

PHP Code:

temp.npc putnpc2(player.xplayer.ynull);
npc.hatImage 3;
npc.join("hat"); 


It never seems to matter when I do it.

DustyPorViva 02-21-2010 07:27 AM

Quote:

Originally Posted by Switch (Post 1557576)
It never seems to matter when I do it.

Should be habit regardless. You want to establish variables before it's joined, because when a class is joined it triggers onCreated() in the class. If there is any script in the onCreated() that relies on those variables, logically you'd want them defined first.

Jman9912 02-21-2010 11:21 AM

Stil doesn't seem to be working. I'm doing

PHP Code:

echo("This.hatImage = " this.hatImage); 


xAndrewx 02-21-2010 11:25 AM

Can you show us the full code what you're using? thank you

Jman9912 02-22-2010 02:25 AM

Is what I have right now in the weapon npc.
PHP Code:

function onActionserverside(){
  if (
params[0] == "place") {
//    temp.npc = putnpc2(player.x, player.y, "join(\"hat\");");

//    with(temp.npc) {
//    temp.hatImage = "3";

//    }  
temp.npc putnpc2(player.xplayer.yNull);
npc.hatImage "3";
npc.join("hat");  

  }


Is what I have right now in the class npc.

PHP Code:

function onCreated() {
  
setshape(13232);
  echo(
this.hatimage);




cbk1994 02-22-2010 02:29 AM

Quote:

Originally Posted by Jman9912 (Post 1557752)
Is what I have right now in the weapon npc.
PHP Code:

function onActionserverside(){
  if (
params[0] == "place") {
//    temp.npc = putnpc2(player.x, player.y, "join(\"hat\");");

//    with(temp.npc) {
//    temp.hatImage = "3";

//    }  
temp.npc putnpc2(player.xplayer.yNull);
npc.hatImage "3";
npc.join("hat");  

  }


Is what I have right now in the class npc.

PHP Code:

function onCreated() {
  
setshape(13232);
  echo(
this.hatimage);




You're using "this.hatImage" when placing it and "this.hatimage" in the class. Capitalization counts! :)

Jman9912 02-22-2010 02:37 AM

That's not the main echo i was using, but I fixed it and still no good.

Jman9912 02-22-2010 02:39 AM

Sorry for the double post.

Are this. variables the same serverside and clientside? Or do they lose scope. I do have it echoing the correct thing on serverside, but the clientside still isn't working. Do I need a trigger client in the class?

cbk1994 02-22-2010 02:42 AM

Quote:

Originally Posted by Jman9912 (Post 1557756)
Sorry for the double post.

Are this. variables the same serverside and clientside? Or do they lose scope. I do have it echoing the correct thing on serverside, but the clientside still isn't working. Do I need a trigger client in the class?

They're different clientside so yes you will need to trigger, or use attributes.

Jman9912 02-22-2010 02:45 AM

Alright, Thanks. I think I just got it working.


All times are GMT +2. The time now is 12:46 AM.

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