A Little problem

Hello my friends, i have a little problem on projectiles system, im using resbak engine, i can attack and target my own character with bow,arrows(projectiles weapons only) and i can kill myself, how to fix it?

Thanks alot!

On the client, find the attack code for the bow, then check your target. Add a check if you’re targeting yourself, and exit the sub if you are.

It should look something like this:
If Player(MyIndex).Target = MyIndex Then Exit Sub

I don’t know if that code will work or not, but it should look very similar to that.


(You will need VB6 to edit this, Visual Studios will not work)

Are you sure it is on client side? not server side? i tried this way:

  • If targetType = TARGET_TYPE_PLAYER And Target = index Then
    PlayerMsg index, “You can’t attack yourself.”, BrightRed
    Exit Sub

and this way:

  • If Player(MyIndex).target = MyIndex Then
    PlayerMsg Index, “You can’t attack yourself.”, BrightRed
    Exit Sub

on createprojectile sub at client source, because i don’t have any bow or something code related on client , also don’t worked 😐

Thanks for the fast reply!

It should be server sided and the possible sub would be tryPlayerShootPlayer

It can be client or server side. The thing is, it’s more work for the server to do when you can just have a check in the client. It doesn’t really matter if a player has a client without the fix, it’s their fault, so it doesn’t need to be server side.

Basically, does it affect anyone’s game play if a player has a client they shouldn’t without this fix? And the answer is no, not really.


Find

Public Sub CheckAttack()


Under

If StunDuration > 0 Then Exit Sub ’ stunned, can’t attack


Add This

If myTargetType = TARGET_TYPE_PLAYER Then
If myTarget = MyIndex Then
PlayerMsg Index, “You can’t attack yourself.”, BrightRed
Exit Sub
End If
End If


This change isn’t tested, but I did look for variable names so the code should work. Let me know if it does or doesn’t 🙂

@mohenjo-daro said in A Little problem:

If myTargetType = TARGET_TYPE_PLAYER Then
If myTarget = MyIndex Then
PlayerMsg Index, “You can’t attack yourself.”, BrightRed
Exit Sub
End If
End If

Variable not defined in both methods (index) and (myIndex)

Edit: defined the variables and i still can attack myself

Ok, I tested the following code in AE (based off of Resbak) and it worked.

Go to

Public Sub CheckAttack()

Under

                With TempPlayer(MyIndex)
                    .Attacking = 1
                    .AttackTimer = GetTickCount
                End With

Add

                If myTargetType = TARGET_TYPE_PLAYER Then
                    If myTarget = MyIndex Then
                        Call AddText("You can’t attack yourself.", BrightRed)
                        Exit Sub
                    End If
                End If

MyIndex should be a global, so you shouldn’t need to define it. (Don’t forget to remove the previous code from the other post).

Love you Mohenjo Daro, fixed 🙂
Also thanks for SolidLink for reply too.

See ya guys

No problem, I marked the fix as the answer so anyone in the future can get the fix as well 🙂 Have a good one!

Log in to reply