How temporary a $@ variable is?

eKoh

New member
Messages
75
Points
0
Hello, I am working with a script and I am using a $@ variable but I don't know for how long it lasts.

I wanted to use a $ variable, but this can cause some bugs if somehow the server crashes and the variable cannot be turned back to 0 before the player leaves.

 
It lasts while map server works. Once server crash or restart it's gone.

 
It lasts while map server works. Once server crash or restart it's gone.
Thank you a lot man, seems that $@ is the perfect variable for me. Btw, how do you know this? By source code or experience or?

By the way, I have another question, is this variable attached to the player or?

Because I try to access to this variable from Script 2 but I created this variable from Script 1. But it seems to not load it.

 
Last edited by a moderator:
Experience mostly, I've started using it before I got my hands on source, so had to figure out myself at first.

Just to clear things up for the rest of temp variables:

@variable - lasts until character disconnects

.@variable - lasts until current instance of script ends (script hits an *end or *close)

$@variable - lasts while map-server lasts

$@ variables are server-wide. If you set them in one script they are accessible from any script. Check that both variables are written in same case and you've written the name right.

 
Last edited by a moderator:
I am checking that.

Btw, is it possible to change a Script Variable ( .var ) from another script?

Btw, the $@var is stored in the RAM?

 
*getvariableofnpc(<variable>,"<npc name>")Returns a reference to a NPC variable (. prefix) from the target NPC.This can only be used to get . variables.
So, to actually set it you'll go

set getvariableofnpc(<variable>,"<npc name>"),<newvalue>;
I'm not really sure if it'll work with direct assignment as I didn't try it.

Also, .var is not a script variable, it's an NPC variable. It's stored within NPC data, and is shared between duplicates of this NPC only. It's NOT shared within one script file.

And yes, it's stored in RAM.

 
*getvariableofnpc(<variable>,"<npc name>")Returns a reference to a NPC variable (. prefix) from the target NPC.This can only be used to get . variables.
So, to actually set it you'll go

set getvariableofnpc(<variable>,"<npc name>"),<newvalue>;
I'm not really sure if it'll work with direct assignment as I didn't try it.

Also, .var is not a script variable, it's an NPC variable. It's stored within NPC data, and is shared between duplicates of this NPC only. It's NOT shared within one script file.

And yes, it's stored in RAM.
Hmm, i think it will return the actual value but not the .var, btw I did something that works, I just need to put atcommand <"command">, it works for the settings I have, but I would need to make 1 single command to make it work for every change:

Code:
	OnInit:	bindatcmd "reloadpvp",strnpcinfo(3)+"::OnReloadPvp";		OnReloadPvp:			.pvppoints = 10; // A pvp setting            end;
 
Back
Top