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 02-21-2010, 02:48 AM
Jman9912 Jman9912 is offline
Registered User
Join Date: Jun 2001
Location: North Carolina
Posts: 114
Jman9912 is on a distinguished road
Send a message via AIM to Jman9912
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";


Reply With Quote
  #2  
Old 02-21-2010, 02:55 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Try this
PHP Code:
temp.npc putnpc2(player.xplayer.y"");
temp.npc.join("hat");
temp.npc.hatImage "3"
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #3  
Old 02-21-2010, 05:05 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Switch View Post
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"); 
__________________
Reply With Quote
  #4  
Old 02-21-2010, 06:29 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbk1994 View Post
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.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #5  
Old 02-21-2010, 07:27 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Switch View Post
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.
Reply With Quote
  #6  
Old 02-21-2010, 11:21 AM
Jman9912 Jman9912 is offline
Registered User
Join Date: Jun 2001
Location: North Carolina
Posts: 114
Jman9912 is on a distinguished road
Send a message via AIM to Jman9912
Stil doesn't seem to be working. I'm doing

PHP Code:
echo("This.hatImage = " this.hatImage); 
Reply With Quote
  #7  
Old 02-21-2010, 11:25 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Can you show us the full code what you're using? thank you
__________________
Reply With Quote
  #8  
Old 02-22-2010, 02:25 AM
Jman9912 Jman9912 is offline
Registered User
Join Date: Jun 2001
Location: North Carolina
Posts: 114
Jman9912 is on a distinguished road
Send a message via AIM to Jman9912
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);


Reply With Quote
  #9  
Old 02-22-2010, 02:29 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Jman9912 View Post
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!
__________________
Reply With Quote
  #10  
Old 02-22-2010, 02:37 AM
Jman9912 Jman9912 is offline
Registered User
Join Date: Jun 2001
Location: North Carolina
Posts: 114
Jman9912 is on a distinguished road
Send a message via AIM to Jman9912
That's not the main echo i was using, but I fixed it and still no good.
Reply With Quote
  #11  
Old 02-22-2010, 02:39 AM
Jman9912 Jman9912 is offline
Registered User
Join Date: Jun 2001
Location: North Carolina
Posts: 114
Jman9912 is on a distinguished road
Send a message via AIM to Jman9912
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?
Reply With Quote
  #12  
Old 02-22-2010, 02:42 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Jman9912 View Post
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.
__________________
Reply With Quote
  #13  
Old 02-22-2010, 02:45 AM
Jman9912 Jman9912 is offline
Registered User
Join Date: Jun 2001
Location: North Carolina
Posts: 114
Jman9912 is on a distinguished road
Send a message via AIM to Jman9912
Alright, Thanks. I think I just got it working.
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 08:50 AM.


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