Adding/Removing TAGs - Printable Version +- SphereCommunity (https://forum.spherecommunity.net) +-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d) +--- Forum: Script Help (/Forum-Script-Help) +--- Thread: Adding/Removing TAGs (/Thread-Adding-Removing-TAGs) |
Adding/Removing TAGs - Osirirs - 08-25-2015 02:16 AM Hey guys I need to have a better understanding of TAGs Ive been banging my head with that almost all week >.< I always try everything I think of before asking haha. Im trying to tag Stat and Skill points to my level system, everything goes fine to gain the stat points but where I get stuck is removing it...I got 2 stat points and then I could add the stats I want, the points would drop down to 0 and then go back to 2, So of course I could add stats infinitely. I dont have my script with me but Here's what I wrote: [Function f_levelup] TAG. STATP=<tag.statp>+{2 3} //not sure if its supposed to be <tag0.statp> //and then on my level menu [DIALOG d_levelm button] ON=1 IF <EVAL <tag.statp>> SRC. STR +=1 TAG.STATP=<tag.statp> -=1 ELSEIF <EVAL <tag.statp>> dialog d_levelm ELSE SYSMESSAGE you dont have any more Stat Points Return 1 ENDIF ENDIF Sorry if it looks a bit messy, wrote that on my phone o.o RE: Adding/Removing TAGs - azmanomer - 08-25-2015 02:38 AM tag0.blabla -----> means if there is no value for blabla return 0 TAG.STATP=<tag.statp> -=1 this one really wrong correct one is tag0.statp -= 1 also for if <eval <tag.statp>> eval is not neccessary just use if <tag0.statp> but i couldnt understand what are u trying to do while checking 2 times tag.statp but i correct all of them with my understanding. [DIALOG d_levelm button] ON=1 IF <src.tag0.statp> SRC.STR +=1 src.TAG0.STATP -= 1 src.dialog d_levelm ELSE src.SYSMESSAGE you dont have any more Stat Points Return 1 ENDIF also if you are calling this dialog with command you dont have to use 'src' but if you are calling it from item or npc u should use src. RE: Adding/Removing TAGs - Osirirs - 08-25-2015 09:22 AM Rock n rooooooollll ! Everything works great now, thanks buddy ! Plus its a great thing to know for my upcoming script RE: Adding/Removing TAGs - pointhz - 08-25-2015 12:01 PM TAG's are like memory items, except they are not items. They are character based (Unless you use account.tag) and you can set them to a value or a string and then call them using those same values or strings. In your case, you can't be sure if a player has enough "numbers" in the TAG.statp, so you use TAG0.statp. If the player has no tag.statp, it will return 0, else it will return 1. If you used TAG.statp instead, it would return an error. Althought it may work, what azmanomer said isn't totally correct, because if "IF <src.tag0.statp>" returns 1, it means you have that tag, so you only need to use SRC.TAG.STATP -=1 and not SRC.TAG0.STATP -=1 after it. See what I mean? As soon as you check that a player has a tag, you don't need to use tag0 anymore. It is only used so it doesn't return an error in case it doesn't exist. If your tag.statp was a string and not a number, you couldn't use the IF (<SRC.TAG0.STATP>). You would have to use something like IF STRMATCH("<TAG.STATP>","") Why? Lets see some examples: Lets say you want to check if a player doesn't have a tag=string: IF STRMATCH("<SRC.TAG.FACTION>","") SRC.SYSMESSAGE Player has no faction. ELSE SRC.SYSMESSAGE Player has faction. ENDIF If you don't have any TAG.FACTION, then you will read the sysmessage "Player has no faction". If you used "IF STRMATCH("<SRC.TAG0.FACTION>","")" instead, you would read "Player has faction." Why? Because 0 isnt "" (empty). Using IF STRMATCH("<SRC.TAG.FACTION>","") is the same as using IF STRMATCH("<SRC.TAG0.FACTION>","0"). As I said, if you don't have the TAG.FACTION, this last function will return 0, which is = 0, so it's like if it returned 1. Think I explained myself correctly xD RE: Adding/Removing TAGs - Osirirs - 08-28-2015 07:39 AM Hmmm indeed that makes a lot of sense, im not yet very familiar with strings tho but what you meant is I shouldnt use tag0 in my IF statement now that it exist ? Only when the tag is not yet created ? Couldnt I just creat an event that creates the tag in which the default value is 0 (no points) and then every stat point is added or removed ? |