Squiddle Posted July 20, 2009 Author Share Posted July 20, 2009 Hi everyone! Well, I'm working on the Skills for Kitten Online, and I'm getting an error. Well, actually, it isn't an RTE. It's just a script breaking after use :S.Now, this is in my Sub MenuScripts:```Sub MenuScripts(Index, Clicked_Index, Menu_Type) Dim MenuTitle Dim FieldMessage Dim AlchemyLevel Dim NewAlchemyLevel Dim EXPReward MenuTitle = getplayermenuclicktitle(Index) FieldMessage = getplayermenuclickmsg(Index) AlchemyLevel = GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyLevel") NewAlchemyLevel = GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyLevel") + 1 Select Case Menu_Type Case 1 If Clicked_Index = 0 Then EXPReward = GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP") + 10 If CanTake(Index, 16, 1) Then If CanTake(Index, 15, 1) Then If GetFreeSlots(Index) > 0 Then Call TakeItem(Index, 15, 1) Call TakeItem(Index, 16, 1) Call GiveCurrency(Index, 17, 1) Call PlayerMsg(index, "You made 1 Energy Potion!", YELLOW) Call BattleMsg(index, "You gained 10 Alchemy Experience Points!", WHITE, 0) Call PutVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP", (EXPReward)) If GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP") >= GetVar("Scripts\AlchemyEXP.ini", "EXP", "Level" & AlchemyLevel) Then Call PutVar("Scripts\Charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyLevel", (NewAlchemyLevel)) Call PutVar("Scripts\Charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP", 0) Call BattleMsg(index, "You have gained a level in Alchemy!", YELLOW, 0) Call PlayerMsg(index, "You are now level " & NewAlchemyLevel & " in the Alchemy Skill!", YELLOW) Call SpellAnim(6, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index)) End If Else Call PlayerMsg(index, "You need 1 free inventory slot to preform this action.", YELLOW) End If Else Call PlayerMsg(index, "You need Mew Berries to preform this action!", YELLOW) End If Else Call PlayerMsg(index, "You need a Jar of Honey to preform this action!", YELLOW) End If End If```And yes, you can use that if abosolutely neccissaryNow, in that script it reads off of an AlchemyEXP.ini, located in the Scripts folder. Here is what's in that Ini:```[EXP]Level1=25Level2=50Level3=75Level4=100Level5=150Level6=200Level7=250Level8=300Level9=350Level10=400```Now, at first all of that works all happpy whiskers and smiling puppies, but all of a sudden it breaks :(. At about level 3-4, you start leveling up every time you activate that script, regardless of how much EXP you actually have :(.Now if anyone can help me with this, please do :). Link to comment Share on other sites More sharing options...
Bobosk Posted July 21, 2009 Share Posted July 21, 2009 just a few random things i like to mention ^^```EXPReward = GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP") + 10```should be…```EXPReward = Int(GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP")) + 10```For some odd partially guessable reason, you have parenthesis' around your EXPReward variable here…``` Call PutVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP", (EXPReward))```again here…```If GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP") >= GetVar("Scripts\AlchemyEXP.ini", "EXP", "Level" & AlchemyLevel) Then```you should have int() around getvars when comparing numbers…again parenthesis'..```Call PutVar("Scripts\Charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyLevel", (NewAlchemyLevel))```i could say more, but where would the fun be in that? hahaha! Link to comment Share on other sites More sharing options...
Squiddle Posted July 21, 2009 Author Share Posted July 21, 2009 Hmmm, I don't quite know what the Int() does :(. You say you should wrap it around GetVar whenever the GetVar is involved with another variable or number? Link to comment Share on other sites More sharing options...
Bobosk Posted July 21, 2009 Share Posted July 21, 2009 Int() converts a string, to an integer… so "1" is 1 when it reads it... because when you try to add strings... it just links them togethor... ex: "3" + "2" = "32"and i say you should wrap it around getvars whenever it involves numbers.. Link to comment Share on other sites More sharing options...
Squiddle Posted July 21, 2009 Author Share Posted July 21, 2009 Okay. But when I remove the Parenthesis', I get RTEs :(. Type Mismatch: "PutVar". Here's my Sub now:```Sub MenuScripts(Index, Clicked_Index, Menu_Type) Dim MenuTitle Dim FieldMessage MenuTitle = getplayermenuclicktitle(Index) FieldMessage = getplayermenuclickmsg(Index) AlchemyLevel = GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyLevel") NewAlchemyLevel = int(GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyLevel")) + 1 Select Case Menu_Type Case 1 If Clicked_Index = 0 Then EXPReward = int(GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP")) + 10 If CanTake(Index, 16, 1) Then If CanTake(Index, 15, 1) Then If GetFreeSlots(Index) > 0 Then Call TakeItem(Index, 15, 1) Call TakeItem(Index, 16, 1) Call GiveCurrency(Index, 17, 1) Call PlayerMsg(index, "You made 1 Energy Potion!", YELLOW) Call BattleMsg(index, "You gained 10 Alchemy Experience Points!", WHITE, 0) Call PutVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP", EXPReward) If int(GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP")) >= GetVar("Scripts\AlchemyEXP.ini", "EXP", "Level" & AlchemyLevel) Then Call PutVar("Scripts\Charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyLevel", NewAlchemyLevel) Call PutVar("Scripts\Charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP", 0) Call BattleMsg(index, "You have gained a level in Alchemy!", YELLOW, 0) Call PlayerMsg(index, "You are now level " & NewAlchemyLevel & " in the Alchemy Skill!", YELLOW) Call SpellAnim(6, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index)) End If Else Call PlayerMsg(index, "You need 1 free inventory slot to preform this action.", YELLOW) End If Else Call PlayerMsg(index, "You need Mew Berries to preform this action!", YELLOW) End If Else Call PlayerMsg(index, "You need a Jar of Honey to preform this action!", YELLOW) End If End If``` Link to comment Share on other sites More sharing options...
Bobosk Posted July 21, 2009 Share Posted July 21, 2009 ```Sub MenuScripts(Index, Clicked_Index, Menu_Type) Dim MenuTitle Dim FieldMessage MenuTitle = getplayermenuclicktitle(Index) FieldMessage = getplayermenuclickmsg(Index) AlchemyLevel = GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyLevel") NewAlchemyLevel = int(GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyLevel")) + 1 Select Case Menu_Type Case 1 If Clicked_Index = 0 Then EXPReward = int(GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP")) + 10 If CanTake(Index, 16, 1) Then If CanTake(Index, 15, 1) Then If GetFreeSlots(Index) > 0 Then Call TakeItem(Index, 15, 1) Call TakeItem(Index, 16, 1) Call GiveCurrency(Index, 17, 1) Call PlayerMsg(index, "You made 1 Energy Potion!", YELLOW) Call BattleMsg(index, "You gained 10 Alchemy Experience Points!", WHITE, 0) Call PutVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP", EXPReward & "") If int(GetVar("Scripts\charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP")) >= Int(GetVar("Scripts\AlchemyEXP.ini", "EXP", "Level" & AlchemyLevel)) Then Call PutVar("Scripts\Charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyLevel", NewAlchemyLevel & "") Call PutVar("Scripts\Charextras\" & GetPlayerName(Index) & ".ini", "SKILLS", "AlchemyEXP", 0) Call BattleMsg(index, "You have gained a level in Alchemy!", YELLOW, 0) Call PlayerMsg(index, "You are now level " & NewAlchemyLevel & " in the Alchemy Skill!", YELLOW) Call SpellAnim(6, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index)) End If Else Call PlayerMsg(index, "You need 1 free inventory slot to preform this action.", YELLOW) End If Else Call PlayerMsg(index, "You need Mew Berries to preform this action!", YELLOW) End If Else Call PlayerMsg(index, "You need a Jar of Honey to preform this action!", YELLOW) End If End If```try that.. Link to comment Share on other sites More sharing options...
Squiddle Posted July 21, 2009 Author Share Posted July 21, 2009 Thanks, it works perfectly now :). Link to comment Share on other sites More sharing options...
Bobosk Posted July 22, 2009 Share Posted July 22, 2009 Err… on a side note squiddle, don't try to use Int() with decimals.. Link to comment Share on other sites More sharing options...
Admiral Refuge Posted July 22, 2009 Share Posted July 22, 2009 @Bobosk:> Err… on a side note squiddle, don't try to use Int() with decimals..Yea, use CDbl() for that. Link to comment Share on other sites More sharing options...
Mr. Bob Firefarter Posted July 22, 2009 Share Posted July 22, 2009 Int stands for integer which is a WHOLE number.…It can also be for negative whole numbers......Not sure if you'd call it _whole_ though. Link to comment Share on other sites More sharing options...
Admiral Refuge Posted July 22, 2009 Share Posted July 22, 2009 @DNA:> Int stands for integer which is a WHOLE number.> > …It can also be for negative whole numbers...> ...Not sure if you'd call it _whole_ though.The Int() function returns the integer part of the number; if it's a decimal, it will convert it into a whole number.If you want a number with a decimal, I suggest CDbl(), which is like Int(), but returns a double (which allows a decimal). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now