VitinhooxD Posted June 28, 2009 Author Share Posted June 28, 2009 Hi everybody!I new with SadScript and could someone help me with my first script?I have trouble with a part of my rank system script.Here it goes a part of himSub OnNPCDeath(Index, Map, NPCNum, NPCIndex)Call BattleMsg(Index, "You killed a " & getnpcname(NPCNum) & ".", BRIGHTRED, 0) Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", + 1)End Sub' Executes when a player is killed by another.' Note: Death occurs as normal externally to this script.Sub OnPVPDeath(Attacker, Victim)Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), BRIGHTRED) Call PutVar("Accounts\" & GetPlayerName(Attacker) & ".ini" ,"RANKSYSTEM" ,"points", - 1)End SubIt doesn't works the part that add a point or subtracr a point when the player kills a npc / a player.COuld someone help me? thanks Link to comment Share on other sites More sharing options...
Admiral Refuge Posted June 28, 2009 Share Posted June 28, 2009 This won't work:```Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", + 1)```Because you're trying to put the text "+1" into that ini, and sadscript will get confused; if anything, you will always have either the number "1" or the number "-1" in there; it doesn't know what you're trying to do.Try this:```Sub OnNPCDeath(Index, Map, NPCNum, NPCIndex) Dim Points Points = GetVar("Accounts\" & GetPlayerName(Attacker) & ".ini" ,"RANKSYSTEM" ,"points") If Points = "" Then Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", "1") Else Points = Int(Points) + 1 Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", Points) End If Call BattleMsg(Index, "You killed a " & GetNpcName(NPCNum) & ".", BRIGHTRED, 0)End Sub' Executes when a player is killed by another.' Note: Death occurs as normal externally to this script.Sub OnPVPDeath(Attacker, Victim) Dim Points Points = GetVar("Accounts\" & GetPlayerName(Attacker) & ".ini" ,"RANKSYSTEM" ,"points") If Points = "" Then Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", "-1") Else Points = Int(Points) - 1 Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", Points) End If Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), BRIGHTRED)End Sub``` Link to comment Share on other sites More sharing options...
VitinhooxD Posted June 28, 2009 Author Share Posted June 28, 2009 Thanks for postinh but it doesn't work =( Link to comment Share on other sites More sharing options...
Admiral Refuge Posted June 28, 2009 Share Posted June 28, 2009 Yea, I made afew logical errors; try this:```Sub OnNPCDeath(Index, Map, NPCNum, NPCIndex) Dim Points Points = GetVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points") If Points = "" Then Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", "1") Else Points = Int(Points) + 1 Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", Points) End If Call BattleMsg(Index, "You killed a " & GetNpcName(NPCNum) & ".", BRIGHTRED, 0)End Sub' Executes when a player is killed by another.' Note: Death occurs as normal externally to this script.Sub OnPVPDeath(Attacker, Victim) Dim Points Points = GetVar("Accounts\" & GetPlayerName(Attacker) & ".ini" ,"RANKSYSTEM" ,"points") If Points = "" Then Call PutVar("Accounts\" & GetPlayerName(Attacker) & ".ini" ,"RANKSYSTEM" ,"points", "-1") Else Points = Int(Points) - 1 Call PutVar("Accounts\" & GetPlayerName(Attacker) & ".ini" ,"RANKSYSTEM" ,"points", Points) End If Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), BRIGHTRED)End Sub``` Link to comment Share on other sites More sharing options...
VitinhooxD Posted June 28, 2009 Author Share Posted June 28, 2009 Still doesn't working , but i found the error .Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", Points)The variable Points need to be called by & i think, but when i test with the "&" it still doesn't work =( Link to comment Share on other sites More sharing options...
Admiral Refuge Posted June 28, 2009 Share Posted June 28, 2009 @VitinhooxD:> Still doesn't working , but i found the error .> > Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", Points)> > The variable Points need to be called by & i think, but when i test with the "&" it still doesn't work =(The ampersand is only used when combining multiple variables or strings (e.g. this would work: "Hi " & " there!").But, you did remind me, that it needs to be a sting in there, so try this, for those:Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" ,"RANKSYSTEM" ,"points", "" & Points)Also, is scripting turned on? Link to comment Share on other sites More sharing options...
VitinhooxD Posted June 28, 2009 Author Share Posted June 28, 2009 Yep now it works! Thanks for helping!PS:When i post this script i will give some credits to you =D 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