Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   odd problem i think (https://forums.graalonline.com/forums/showthread.php?t=79084)

[email protected] 03-19-2008 09:38 AM

odd problem i think
 
when i update my "Control-NPC" it says this

Quote:

The script of NPC Control-NPC has been updated by Graal707396
al,ac,at
inside the Control-NPC is this

PHP Code:

function onActionPlayerOnline()
  {    
    for (
temp.i: ({"tileset""chat profiles"}))
      
player.addweapon(i);
    
    
player.setlevel2("onlinestartlocal.graal"29.529.5);
  } 

why does it do that?? it is doing my sorting weapon script everytime i update it, here is my sorting npc weapon

PHP Code:

function onCreated() 
  {
    
temp.= {{"ac"4}, {"at"7}, {"al"1}};
    
temp.= {};
    
temp.null;
    
    for (
temp.ia
      {
        
e.add(i[0]);
        
e[c].sortvalue i[1];
        
c++;
      }
    
e.sortbyvalue("sortvalue""float"true);
    echo(
e);
  } 

why does it keep echoing it??

Inverness 03-19-2008 10:41 AM

onCreated() is triggered when you update a weapon or npc script. Is that what you mean?

coreys 03-19-2008 03:08 PM

I think she's saying that's in another script than the NPC-Server itself.

[email protected] 03-19-2008 03:10 PM

Quote:

Originally Posted by coreys (Post 1380778)
I think she's saying that's in another script than the NPC-Server itself.

yes it is

zokemon 03-19-2008 04:46 PM

What's in the onCreated() and/or onInitialized() for the NPC-Server?

Also, eww at lower case weapon names :frown:.

[email protected] 03-19-2008 04:57 PM

nothing, only function that is in there is the onActionPlayerOnline

[email protected] 03-19-2008 05:09 PM

Chompy fixed it by resetting it!!!!! ^^^^^^

Inverness 03-19-2008 08:11 PM

I would suggest naming your weapons differently, like: Tileset and ChatProfiles.

That way you can do WeaponName.myFunction() and such in script.

[email protected] 03-19-2008 08:33 PM

ok ty!! ^^^^

xXziroXx 03-19-2008 09:37 PM

Since you weren't using a prefix for your variables, they were saved locally in the level and was able to be read by other NPCs in that level on serverside. I suggest you learn how Graal's vast amount of variable types work. :)

Quote:

Originally Posted by Graal Wiki
object.var accesses the variables of the object. The object can be retrieved by using the case-sensitive name of the object or a variable pointing to the object.
this.var variables that belong to the current script object, on the server-side they are saved to file when the object is a database npc
thiso.var refer to the this. variables of the executing npc ('o' stands for original) when you use the with () command: with (findnpc("npc2")) thiso.temp = this.temp; will copy 'this.temp' from npc2 to the current npc
temp.var variables that belong to the current function. They can be used anywhere in the function even when referencing another object. Function parameters are declared as temp variables if they do not have a prefix. Temp variables will be destroyed at the end of the function.
player.var variables of the current player object, when the event was invoked by a player (e.g. playertouchsme), or you do with (findplayer(accountname))
playero.var variables of the original player object, in generally the player who has invoked the event (e.g. playertouchsme)
client.var short for player.client.var, variables that can be changed on server-side and client-side
clientr.var short for player.clientr.var, variables that can only be changed on server-side but can be read on client-side
server.var variables that only exists on server-side and can be accessed by all npcs
serverr.var variables that can only be changed on server-side and is server wide, but can also be read by all clients, so it can be used for storing the state of global activities that need client-side actions like displaying weather; like server. vars they can also be changed with remotecontrol.exe by administrators that have the right to change server. variables
level.var variables of the current level, which is the level the executing npc stands in (on server-side) or the player is in (on client-side)


[email protected] 03-19-2008 09:42 PM

i am/were using a prefix

xXziroXx 03-19-2008 10:09 PM

Duh, sorry, my eyes decided to skip the three lines with the initializing of the variables. -_-

Inverness 03-19-2008 10:29 PM

The thing I like about temp variables is that once you initialize them you don't need the temp. anymore which is something I hate seeing repeated in a function, so I prefer to initialize all the temp variables at the start of the function unless its a small thing.


All times are GMT +2. The time now is 10:51 PM.

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