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 05-19-2007, 04:09 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Why doesn't this work now?

2 days ago (the last time i used this script) it worked great. Now it's not, even though it hasn't been changed.

I've created an IRC style chat system which uses my associative array class to store the channels and users.

PHP Code:
public function create_channel(channelnametopicowner) {
  if (!
this.channels.has(channelname)) {
    
channel = new TStaticVar();
    
channel.join("chat_channel");
    
channel.create(topicownerchannelname);
    echo(
"a:"@channel.channelname);
    
this.channels.put(channelname,channel);
    echo(
"b:"@this.channels.item(channelname).channelname);
  }

This worked great before. the first echo (a) works fine, and echos the channel name as it should, but after it's been put into the associative array channel is no longer accessible (b). This was not the case 2 days ago when it worked as expected.

I don't know what's wrong, the associative array class hasn't been changed and it's used in other scripts which are still working fine. The only difference is, this is the only place it's being used to store objects.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #2  
Old 05-21-2007, 03:55 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
I figured it out.

For an array to store objects it must be a TStaticVar;

PHP Code:
channel = new TStaticVar();
channel.join("chat_channel");
channel.create(topicownerchannelname);

//Doesnt work: 
test.add(channel);
echo(
test[0].channelname); 


//works:
test2 = new TStaticVar();
test2.add(channel);
echo(
test2[0].channelname); 
Strange that it used to work though.
__________________

Coming soon (Hopefully:P)
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 12:16 PM.


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