View Single Post
  #5  
Old 08-28-2006, 03:40 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
Where should destroy go?

Heres what I have:

PHP Code:
//#CLIENTSIDE

function onWeaponFired() {
arr = new TStaticVar(); 
arr.join("assocarray");
arr.make({"a","b","c"},{"one","two","three"});


echo(
arr.put("d","four"));
arr.put("seven","nine");
echo(
"Has:" arr.has("notakey"));
echo(
arr.keys());
arr.put("eight","ten");
echo(
"remove: " arr.remove("b"));
echo(
arr.keys());

//for(arr.start();arr.off();arr.forth()){
//player.chat = player.chat @ arr.item_for_iteration;
//}

arr.start();
while(!(
arr.off())) {
  
player.chat player.chat " " arr.item_for_iteration();
  
arr.forth();
}
arr.destroy();

I update the assocarry class and this weapon npc never shows the changes. For example, remove isn't working so i changed..

PHP Code:
public function remove(key) {
  if (
has(key)) {
    
this.values.delete(this.keys.index(key));
    
this.keys.delete(this.keys.index(key));
    return 
0;
  }
  else return 
1;

to

PHP Code:
public function remove(key) {
    
this.keys.delete(this.keys.index("b")); //in the example b exists as a key so this should work
    
this.values.delete(this.keys.index(key));
    
this.keys.delete(this.keys.index(key));
    return 
"test..."//return a string instead of a number

However, arr.remove("anything"); is still returning 0 instead of "test...".

I added arr.destroy(); to my NPC but it still never updates.

Is it because both the weapon NPC and the class npc have //#CLIENTSIDE ?


UPDATE: If I copy and paste the entire remove function and call it remove2, then call arr.remove2() it will execute as expected. remove() still executes as if it were never changed since the first time I called it even though the code is identical to remove2().

Any ideas? This is a bit strange and highly annoying because I don't know whether the script is working or not because I cant tell whether it's using the latest version of the function.

Last edited by JkWhoSaysNi; 08-28-2006 at 06:07 PM..
Reply With Quote