Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Helping with arrays in showtext (https://forums.graalonline.com/forums/showthread.php?t=134264089)

Astram 08-04-2011 03:54 AM

Helping with arrays in showtext
 
Well, I can't get this showtext to update to the array I want, the array should include multiple nicknames but it only shows one in the level.
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
this.set NULL;
}
function 
onUpdateText()
  {
  
showtext(1this.x+0.5this.y-0.05"Arabic""b"this.text);
  
changeimgzoom(11);
  
changeimgcolors(11111);
  
drawunderplayer;
  }
function 
onPlayerEnters()
  {
  
onTimeOut();
  }
function 
onTimeOut()
  {
  if (
this.set != NULL)
    {
    
this.text this.set;
    }
  else
    {
    
this.text "Lineup: ";
    }
  
onUpdateText();
  
setTimer(.5);
  }
function 
onPlayerChats()
  {
  if (
player.guild == "Events Team")
    {
    if (
player.chat == ":lineup")
      {
      for (
temp.0temp.playerscounttemp.++)
        {
        
this.lineup NULL;
        
this.lineup.add(players[(@temp.p)].nick);
        
player.chat this.lineup;
        
this.set "Lineup: "@this.lineup;
      }
    }
  }



fowlplay4 08-04-2011 04:22 AM

You're setting the array to NULL then adding a player to it.

cbk1994 08-04-2011 04:24 AM

Also, this

PHP Code:

this.lineup NULL

for (
temp.0temp.playerscounttemp.++) 

  
this.lineup.add(players[(@temp.p)].nick); 
  
player.chat this.lineup
  
this.set "Lineup: "@this.lineup


would be better written as

PHP Code:

this.lineup NULL

for (
temp.pl players

  
this.lineup.add(temp.pl.nick);
}

player.chat this.lineup
this.set "Lineup: "@this.lineup


Astram 08-04-2011 04:25 AM

Quote:

Originally Posted by fowlplay4 (Post 1661577)
You're setting the array to NULL then adding a player to it.

I removed onCreated nothing different

cbk1994 08-04-2011 04:27 AM

Quote:

Originally Posted by Astram (Post 1661579)
I removed onCreated nothing different

The issue is in the loop, not in onCreated.

PHP Code:

for (temp.0temp.playerscounttemp.++) 
        { 
        
this.lineup NULL
        
this.lineup.add(players[(@temp.p)].nick); 
        
player.chat this.lineup
        
this.set "Lineup: "@this.lineup
      } 

You're setting this.lineup to null then adding the player to it. The null assignment should be before the loop.


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

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