Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Why doesn't this work now? (https://forums.graalonline.com/forums/showthread.php?t=74063)

JkWhoSaysNi 05-19-2007 04:09 PM

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.

JkWhoSaysNi 05-21-2007 03:55 PM

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.


All times are GMT +2. The time now is 03:40 PM.

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