View Full Version : odd problem i think

03-19-2008, 09:38 AM
when i update my "Control-NPC" it says this

The script of NPC Control-NPC has been updated by Graal707396

inside the Control-NPC is this

function onActionPlayerOnline()
for (temp.i: ({"tileset", "chat profiles"}))

player.setlevel2("onlinestartlocal.graal", 29.5, 29.5);

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

function onCreated()
temp.a = {{"ac", 4}, {"at", 7}, {"al", 1}};
temp.e = {};
temp.c = null;

for (temp.i: a)
e[c].sortvalue = i[1];
e.sortbyvalue("sortvalue", "float", true);

why does it keep echoing it??

03-19-2008, 10:41 AM
onCreated() is triggered when you update a weapon or npc script. Is that what you mean?

03-19-2008, 03:08 PM
I think she's saying that's in another script than the NPC-Server itself.

03-19-2008, 03:10 PM
I think she's saying that's in another script than the NPC-Server itself.

yes it is

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:.

03-19-2008, 04:57 PM
nothing, only function that is in there is the onActionPlayerOnline

03-19-2008, 05:09 PM
Chompy fixed it by resetting it!!!!! ^^^^^^

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.

03-19-2008, 08:33 PM
ok ty!! ^^^^

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. :)

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)

03-19-2008, 09:42 PM
i am/were using a prefix

03-19-2008, 10:09 PM
Duh, sorry, my eyes decided to skip the three lines with the initializing of the variables. -_-

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.