Jump to content
  • 0
eKoh

How temporary a $@ variable is?

Question

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.

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

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.

Edited by eKoh

Share this post


Link to post
Share on other sites
  • 0

 

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?

 

https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt#L438

Share this post


Link to post
Share on other sites
  • 0

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.

Edited by Garr

Share this post


Link to post
Share on other sites
  • 0

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?

Share this post


Link to post
Share on other sites
  • 0
*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.

Share this post


Link to post
Share on other sites
  • 0

 

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

 

 

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.