laylayzi 0 Posted February 4, 2015 Hi! There is my problem. I want to add a new parameter into the char table but I don't know how to work with it. For example: i add a new column "count" into the char table. (integer default: 0) and i want every i type a command (ex: @count) or talk with NPC, it can show me the current value of "count" then +1 so: the first time i use @count (or talk with NPC) it will show me: 0 the secondtime i use @count it will show me: 1 ... Thats it. Thank for your time! Quote Share this post Link to post Share on other sites
0 Garr 117 Posted February 4, 2015 Why not use char-based variables? Those will be easier to set ingame, and they can be found in SQL as well via charID/name of variable. Quote Share this post Link to post Share on other sites
0 laylayzi 0 Posted February 4, 2015 (edited) what i am trying to do is put a flag for my charactor. orthers variable have their using purpose (maybe, as i can see at the columname) that i cant modifier. Im a newbie in scripting so maybe there is an other way to set a variable bind to character but i dont know. Thank for your time! Edited February 4, 2015 by laylayzi Quote Share this post Link to post Share on other sites
0 malufett 247 Posted February 4, 2015 @ doc/script_commands.txt Variables are divided into and uniquely identified by the combination of:prefix - determines the scope and extent (or lifetime) of the variablename - an identifier consisting of '_' and alphanumeric characterspostfix - determines the type of the variable: integer or stringScope can be:global - global to all serverslocal - local to the serveraccount - attached to the account of the character identified by RIDcharacter - attached to the character identified by RIDnpc - attached to the NPCscope - attached to the scope of the instanceExtent can be:permanent - They still exist when the server resets.temporary - They cease to exist when the server resets.Prefix: scope and extentnothing - A permanent variable attached to the character, the default variable type."@" - A temporary variable attached to the character. They disappear when the character logs out."$" - A global permanent variable. They are stored in database table `mapreg`."$@" - A global temporary variable. They are important for scripts which are called with no RID attached, that is, not triggered by a specific character object."." - A NPC variable. They exist in the NPC and disappear when the server restarts or the NPC is reloaded. Can be accessed from inside the NPC or by calling 'getvariableofnpc'. Function objects can also have .variables which are accessible from inside the function, however 'getvariableofnpc' does NOT work on function objects.".@" - A scope variable. They are unique to the character, script and scope. Each script execution has its own scope that ends when the script ends. Calling a function with callsub/callfunc starts a new scope, returning from the function ends it. When a scope ends, its variables are converted to values ('return .@var;' returns a value, not a reference)."'" - An instance variable. These are used with the instancing system, and are unique to each instance."#" - A permanent local account variable."##" - A permanent global account variable stored by the login server. The only difference you will note from normal # variables is when you have multiple char-servers connected to the same login-server. The # variables are unique to each char-server, while the ## variables are shared by all these char-servers.Postfix: integer or stringnothing - integer variable, can store positive and negative numbers, but only whole numbers (so don't expect to do any fractional math).'$' - string variable, can store text.Examples: name - permanent character integer variable name$ - permanent character string variable@name - temporary character integer variable@name$ - temporary character string variable$name - permanent global integer variable$name$ - permanent global string variable$@name - temporary global integer variable$@name$ - temporary global string variable.name - NPC integer variable.name$ - NPC string variable.@name - scope integer variable.@name$ - scope string variable'name - instance integer variable'name$ - instance string variable#name - permanent local account integer variable#name$ - permanent local account string variable##name - permanent global account integer variable##name$ - permanent global account string variable Quote Share this post Link to post Share on other sites
0 laylayzi 0 Posted February 5, 2015 @ doc/script_commands.txt Thank a lot for your information! From that i have a question, where can i assign charactor permanent variable? I want it to be assigned when my character first created. Thank for your time! Quote Share this post Link to post Share on other sites
0 laylayzi 0 Posted February 5, 2015 (edited) !!! Edited February 5, 2015 by laylayzi Quote Share this post Link to post Share on other sites
0 Garr 117 Posted February 5, 2015 - script PcLogin -1,{OnPCLoginEvent: if (!<variablename>) <variablename> = <variablevalue>; end;} Where <variablename> is name of the variable, in the format of just name, without any prefixes or suffixes, and <variablevalue> is desired value, since it's a flag 1 should go here, mainly. Run this script at the start of server via npc/scripts_custom.conf Quote Share this post Link to post Share on other sites
0 laylayzi 0 Posted February 6, 2015 I got it. Thank you so much. Quote Share this post Link to post Share on other sites
Hi! There is my problem.
I want to add a new parameter into the char table but I don't know how to work with it.
For example:
i add a new column "count" into the char table. (integer default: 0)
and i want every i type a command (ex: @count) or talk with NPC, it can show me the current value of "count" then +1
so:
the first time i use @count (or talk with NPC) it will show me: 0
the secondtime i use @count it will show me: 1
...
Thats it.
Thank for your time!
Share this post
Link to post
Share on other sites