Jed Posted April 13, 2009 Author Share Posted April 13, 2009 ok, i've been asking this for quite a while now, and i have tried the script myself.what this script does is allows players to attack certain classes, and the others it cannot attack. for example:Classes 0,1, 2, and 6 can attack classes 3, 4, 5, and 7, and vice versa.if classes 0, 1, 2, and 6 try to attack one of the allied classes, it should tell you something like "You cannot attack an ally!", but when the allies attack the enemy classes, it should work. the one major important thing is that i dont want the players to become PKers when they kill each other. i have tried soing this myself, but it doesnt work. here is what i tried:If GetPlayerClass = 0 ThenIf GetPlayerTarget = Class 0 ThenCall BattleMsg(Index, "You cannot attack an allied member!" , BRIGHTRED)if you can help or make the script, thanx, and if you dont have the time or you dont want to make the script, at least help me. thanks. Link to comment Share on other sites More sharing options...
Admiral Refuge Posted April 13, 2009 Share Posted April 13, 2009 You're calling the functions wrong.GetPlayerClass needs to be GetPlayerClass(index) and GetPlayerTarget needs to be GetPlayerTarget(index).Also, you forgot both End If at the end, and "Class 0" should just be "0".EDIT:So this should be correct (syntax-wise):If GetPlayerClass(index) = 0 Then If GetPlayerTarget(index) = 0 Then Call BattleMsg(Index, "You cannot attack an allied member!" , BRIGHTRED) End IfEnd IfThough, you could also just have:If GetPlayerClass(index) = 0 AND GetPlayerTarget(index) = 0 Then Call BattleMsg(Index, "You cannot attack an allied member!" , BRIGHTRED)End IfJust letting you know, unless you have an "Exit Sub" after the call msg, it will still attack the player, it will just say "You cannot attack an allied member!". Link to comment Share on other sites More sharing options...
Jed Posted April 13, 2009 Author Share Posted April 13, 2009 where would this need to go in the attack sub? like where to put it? before the actual attacking? Link to comment Share on other sites More sharing options...
Admiral Refuge Posted April 13, 2009 Share Posted April 13, 2009 @Ezmek:> where would this need to go in the attack sub? like where to put it? before the actual attacking?Assuming the logic is correct, put it at the the beginning of your attack sub; just make sure you didn't forget the exit sub command as well. Link to comment Share on other sites More sharing options...
Jed Posted April 14, 2009 Author Share Posted April 14, 2009 ok, thanx admiral. Link to comment Share on other sites More sharing options...
Akselj Posted April 17, 2009 Share Posted April 17, 2009 The best way, though, is to use If GetPlayerClass(Index) = GetPlayerClass(GetPlayerTarget(Index)) Link to comment Share on other sites More sharing options...
Jed Posted April 18, 2009 Author Share Posted April 18, 2009 ok, this gets confusing, i will need someone to make the entire sub for what i explained, and please PM it to me, because this will get very confusing after a while. Link to comment Share on other sites More sharing options...
Admiral Refuge Posted April 18, 2009 Share Posted April 18, 2009 Write an entire sub, for 4 lines of code???Just put this before anything else in your attack sub:```If GetPlayerClass(Index) = GetPlayerClass(GetPlayerTarget(Index)) Then Call BattleMsg(Index, "You cannot attack an allied member!" , 12) Exit SubEnd If``` Link to comment Share on other sites More sharing options...
Jed Posted April 18, 2009 Author Share Posted April 18, 2009 no, i want 4 classes to be able to attack 4 other classes and not the first 4 classes they are a part of. Link to comment Share on other sites More sharing options...
Admiral Refuge Posted April 18, 2009 Share Posted April 18, 2009 @Ezmek:> no, i want 4 classes to be able to attack 4 other classes and not the first 4 classes they are a part of.In that case, it would be a function, not a sub, wouldn't it?Okay…. I haven't tested this, so let me know if it works (other scritpers, take a look at it to please)Paste this at the bottom of your main.txt:```Function CanAttack(index, target)Dim MyClassDim TheirClassMyClass = GetPlayerClass(index)TheirClass = GetPlayerClass(target)If MyClass = 0 Or MyClass = 1 Or MyClass = 2 Or MyClass = 6 Then 'Their 0, 1, 2, or 6. If TheirClass = 3 Or Theirclass = 4 Or TheirClass = 5 Or TheirClass = 7 Then Return True 'They can attack. Else Return False 'They cannot attack. End IfElse 'Their 3, 4, 5, or 7. If TheirClass = 0 Or Theirclass = 1 Or TheirClass = 2 Or TheirClass = 6 Then Return True ' They can attack. Else Return False ' They cannot attack. End IfEnd IfEnd Function```Now, put this before anything else in your attack sub:```Dim targettarget = GetPlayerTarget(Index)If CanAttack(index, target) <> True Then Call BattleMsg(Index, "You cannot attack an allied member!" , 12) Exit SubEnd If``` Link to comment Share on other sites More sharing options...
Jed Posted April 18, 2009 Author Share Posted April 18, 2009 it doesnt work. when i attack someone or an NPC, all it does is make the attack sound then nothing happens. Link to comment Share on other sites More sharing options...
Bobosk Posted April 18, 2009 Share Posted April 18, 2009 try replacing <> true with = true Link to comment Share on other sites More sharing options...
Jed Posted April 19, 2009 Author Share Posted April 19, 2009 no because we dont want allies attacking each other. if you make that true then it would allow that, and we dont want that.maybe we could try = False instead of <> True 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