Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Class Attack Script


Jed
 Share

Recommended Posts

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 Then
If GetPlayerTarget = Class 0 Then
Call 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

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 If
End If

Though, 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 If

Just 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

@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 MyClass
Dim TheirClass
MyClass = 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 If
Else '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 If
End If
End Function
```
Now, put this before anything else in your attack sub:
```
Dim target
target = GetPlayerTarget(Index)
If CanAttack(index, target) <> True Then
  Call BattleMsg(Index, "You cannot attack an allied member!" , 12)
  Exit Sub
End If
```
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...