Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Insert()? (https://forums.graalonline.com/forums/showthread.php?t=74137)

killerogue 05-22-2007 11:51 PM

Insert()?
 
A question, when using insert does it shift everything over one entry? Or does it simply replace the value you've inserted into.

As I was using it this function is supposed to first insert a new string into the 0 entry of the client.messages array then delete the last entry if the last entry is over five. Isn't adding any new messages after I reach the 5 limit nor deleting them.

Any ideas?

PHP Code:

function onCreated()
{
  
setshape(13232);
}

//#CLIENTSIDE
function onCreated()
{
  
setshape(13232);
}
public function 
addPlayerNotification(message) {
  echo(
temp.message);
  
  
this.client.messages.insert(0temp.message);
  
this.checkNotifications();
}

public function 
checkNotifications() {
  if (
this.client.messages.size() > 5)
  {
    
this.deleteNotification();
  }
}

public function 
deleteNotification() {
  
this.client.messages.delete(6);
}

public function 
updateNotifications() {



Inverness 05-23-2007 12:14 AM

Quote:

Originally Posted by Wiki
obj.replace(index,obj2)
obj.insert(index,obj2)

...
Indexes start at zero.
PHP Code:

public function addPlayerNotification(msg) {
  
client.messages.insert(0msg);
  if (
client.messages.size() > 5) {
    
client.messages.delete(5);
  }




All times are GMT +2. The time now is 07:08 PM.

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