HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] GUID -> noderef = 0 [resolved]  (Read 1402 times)

RogerD

  • World Owners
  • ****
  • Posts: 10
    • View Profile
[Resolved] GUID -> noderef = 0 [resolved]
« on: Jul 08, 12, 02:27:42 PM »

I'm passing a GUID from my server to my client.  The GUID gets through okay, as shown by a println, but when I assign it to a noderef, the noderef is 0.

I know the GUID is valid, because I can look at the object with /HEINFO or modify it via /mnac (and it works correctly).  But when I try to use it from within Heroscript, it just becomes unusable.  Here's the code:

Code: [Select]
remote function AddClassToNode(cname as String, cid as ID)
  println("client:  addclasstonode "+cname + ", "+strutils:idtos(cid))
  n as NodeRef = cid
  println("Noderef is "+n)
  $GLOM._GLOMClass(cname, cid)
.

When I run this, I get this output:

15:20:33: System:SCRIPT[AranClientTools]:client:  addclasstonode QuestGiver, 9223372056541021811
15:20:33: System:SCRIPT[AranClientTools]:Noderef is 9223372056541021811
15:20:33: System:SCRIPT[QuestGiverClassMethods]:I am initializing your quests
15:20:33: System:SCRIPT[AranClientTools]:client:  addclasstonode QuestGiver, 9223372056541021764
15:20:33: System:SCRIPT[AranClientTools]:Noderef is 0
15:20:33: !ERROR!HeroScript::HeroMachine::ScriptError:Requested glom on an invalid node(0)

For the first GUID, it works fine, but it fails for the second GUID.  I'm certain the GUID is valid, since it works in other places, like /mnac, for example:

15:23:49: /mnac 9223372056541021764 QuestGiver
15:23:49: System:CLI command /mnac 9223372056541021764 QuestGiver.
15:23:49: System:MNAC OK 9223372056541021764 : "Node ID: 9223372056541021764 Modified."

Anyone have an idea why certain GUIDs would not be valid within Heroscript?  This particular node is one I created via /henpc - it's a generic female character I've created as a test.
« Last Edit: Nov 01, 12, 02:42:18 PM by HE-Cooper »
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: GUID -> noderef = 0
« Reply #1 on: Jul 08, 12, 07:04:53 PM »

At what point is AddClassToNode called, like is it when a player first enters the game, or first enters an area, or something like that?  Could be a timing thing that the node is not realized, yet, on the client when that was called, but is later on when you use the mnac.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

RogerD

  • World Owners
  • ****
  • Posts: 10
    • View Profile
Re: GUID -> noderef = 0
« Reply #2 on: Jul 08, 12, 09:07:59 PM »

At what point is AddClassToNode called, like is it when a player first enters the game, or first enters an area, or something like that?  Could be a timing thing that the node is not realized, yet, on the client when that was called, but is later on when you use the mnac.

You're right, that's the problem.  If I register a server command to call my method manually after the area is loaded, it works fine.  Thanks!

Right now I'm calling my method from He_PostClientReady.  It seems like the regular models are loaded in, but PCs and NPCs are not created yet at that time.  Do you know when they're all loaded into the client?

EDIT:  I think I've answered my own question.  It seems that objects of type character don't get created on the client until the game decides that you're in range of them.  At that time, $CHARACTERSYSTEM calls a method HE_OnCharacterCreate (which you can put on a class and glom on to $CHARACTERSYSTEM).  I have enough information to solve my problem now.
« Last Edit: Jul 08, 12, 09:37:49 PM by RogerD »
Logged