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

Global attack animation?


Growlith1223
 Share

Recommended Posts

OK! Think it's time for me to give this a shot! On another thread Robin chimed in and, along with his usual type of response :''( , pretty much explained that Origins already does this, it's just missing a few pieces of code. So here goes…

**CLIENT:** In the client we already have a packet being sent by the CheckAttack sub
```
Set Buffer = New clsBuffer
                Buffer.WriteLong CAttack
                SendData Buffer.ToArray()
                Set Buffer = Nothing
```**CLIENT:** This code just needs to have the index information of who is attacking to be sent to the server
```
Set Buffer = New clsBuffer
                Buffer.WriteLong CAttack
                [b]Buffer.WriteLong MyIndex[/b]
                SendData Buffer.ToArray()
                Set Buffer = Nothing
```**SERVER:**Next the HandleAttack sub in the server needs to receive this info (P.S. don't forget to Dim buffer)
```
Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()
    attackingplayer = Buffer.ReadLong
    Set Buffer = Nothing
```
**SERVER:** Then have the server send that info right back to the client (best to have this right after the above)
```
' Send this packet so they can see the person attacking
    Set Buffer = New clsBuffer
    Buffer.WriteLong SAttack
    Buffer.WriteLong attackingplayer
    SendDataToMap GetPlayerMap(index), Buffer.ToArray()
    Set Buffer = Nothing
```
**CLIENT:** and last….guess what? there shouldn't be any last! this code should already be in the client's handleattack sub:
```
Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()
    i = Buffer.ReadLong
    ' Set player to attacking
    Player(i).Attacking = 1
    Player(i).AttackTimer = GetTickCount

```
If you've done all this right (and if I've written these instructions right at 3a.m.) then all players should see your attack frame! (p.s. for animations this should also work)

Well, That's all folks! Be good, and don't thank me(maybe a little) but thank Robin most of all!
Link to comment
Share on other sites

Thanks but not work!
When I attack another player I have: (in the server)
Run-time error '9':
Subscript out of range

> Public Sub WriteBytes(ByRef nByte() As Byte)
> Dim nLength As Long
>        
>     **nLength = (UBound(nByte) - LBound(nByte)) + 1**
>    
>     If WriteHead + nLength - 1 > BufferSize Then Allocate nLength
>    
>     CopyMemory Buffer(WriteHead), nByte(0), nLength
>     WriteHead = WriteHead + nLength
> End Sub
Link to comment
Share on other sites

@Soul:

> Make sure the packets in modEnumerations client-side match with the packets in modEnumerations server-side.

Yeah they are the same. My server & client work good, but when I install Deathfissure's codes I've this bug. :/ Maybe I did something wrong.

I've add in Sub CheckAttack under:
```
Set Buffer = New clsBuffer
                Buffer.WriteLong CAttack

```This:
```
Buffer.WriteLong MyIndex
```
And in Sub HandleAttack (server side) I've add under:
```
    ' Send this packet so they can see the person attacking
    'SendAttack Index
```This
```
Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()
    attackingplayer = Buffer.ReadLong
    Set Buffer = Nothing
```
In sub handleattack (client side) under:
```
    ' Set player to attacking
    Player(i).Attacking = 1
    Player(i).AttackTimer = GetTickCount
```This
```
        Buffer.WriteLong SAttack
    Buffer.WriteLong attackingplayer
    SendDataToMap GetPlayerMap(Index), Buffer.ToArray()
    Set Buffer = Nothing
```
And when I attack another player, I've this bug: (in the server)
Compile error:
Variable not defined

In sub handleattack:

> Set Buffer = New clsBuffer
>     Buffer.WriteBytes Data()
>     **attackingplayer =** Buffer.ReadLong
>     Set Buffer = Nothing

So, I've add
```
Dim attackingplayer As Long
```(didn't work)
Another time
```
Dim attackingplayer As String
```(didn't work)

Always with the same bug:
@Keny:

> Run-time error '9':
> Subscript out of range
>
> > Public Sub WriteBytes(ByRef nByte() As Byte)
> > Dim nLength As Long
> >        
> >     **nLength = (UBound(nByte) - LBound(nByte)) + 1**
> >  
> >     If WriteHead + nLength - 1 > BufferSize Then Allocate nLength
> >  
> >     CopyMemory Buffer(WriteHead), nByte(0), nLength
> >     WriteHead = WriteHead + nLength
> > End Sub

Thank you for your help. ^^'
Link to comment
Share on other sites

Hi Keny! looks like you put a piece of code on the wrong program, this code:
```
Buffer.WriteLong SAttack
    Buffer.WriteLong attackingplayer
    SendDataToMap GetPlayerMap(Index), Buffer.ToArray()
    Set Buffer = Nothing
```isn't supposed to go in the client. That code goes in the server handleattack sub right after the other chunk of code, (the one that has the attackingplayer = buffer.readlong).
Then the client should already have i=buffer.readlong in the handleattack sub.
sorry if my wording in the tut was a little confusing, I'll edit it a bit. :)
Link to comment
Share on other sites

  • 5 months later...
Hey guys, sorry for the post in an old topic, but I've got a problem.

When I try to compile, I get the error:

**"Compile Error:**

**Type Mistach:array or user-defined type expected."**

in

```

Set Buffer = New clsBuffer

Buffer.WriteLong SAttack

Buffer.WriteLong attackingplayer

SendDataToMap GetPlayerMap(index), Buffer.ToArray()

Set Buffer = Nothing

```

Ain't I suppose to specify Buffer.ToArray() putting "index" in ()?
Link to comment
Share on other sites

> Hey guys, sorry for the post in an old topic, but I've got a problem.
>
> When I try to compile, I get the error:
>
> **"Compile Error:**
>
> **Type Mistach:array or user-defined type expected."**
>
> in
>
> ```
>
> Set Buffer = New clsBuffer
>
> Buffer.WriteLong SAttack
>
> Buffer.WriteLong attackingplayer
>
> SendDataToMap GetPlayerMap(index), Buffer.ToArray()
>
> Set Buffer = Nothing
>
> ```
>
> Ain't I suppose to specify Buffer.ToArray() putting "index" in ()?

No. In wich line does the error show up?

Also sending MyIndex to the server in the checkattck sub its extra uneeded work since attackingplayer will always be equal to index
Link to comment
Share on other sites

> No. In wich line does the error show up?
>
> Also sending MyIndex to the server in the checkattck sub its extra uneeded work since attackingplayer will always be equal to index

Hi there, thanks for the reply and sorry for any english mistake, I'm brazilian.

My final code stands as this:

```

'SendAttack index

Dim Buffer

Set Buffer = New clsBuffer

Buffer.WriteBytes Data()

Dim attackingplayer As String

attackingplayer = Buffer.ReadLong

Buffer.WriteLong SAttack

Buffer.WriteLong attackingplayer

SendDataToMap GetPlayerMap(index), Buffer.ToArray()

Set Buffer = Nothin

```

And the error happens in the line

```
SendDataToMap GetPlayerMap(index), [b]Buffer.ToArray()[/b]
```
Link to comment
Share on other sites

i havent got access to vb6 right now so replace your code with mine and tell me if it works

```

Dim Buffer as clsBuffer

Set Buffer = New clsBuffer

Buffer.WriteLong SAttack

Buffer.WriteLong Index

SendDataToMap GetPlayerMap(index), Buffer.ToArray()

Set Buffer = Nothing

```
Link to comment
Share on other sites

> i havent got access to vb6 right now so replace your code with mine and tell me if it works
>
> ```
>
> Dim Buffer as clsBuffer
>
> Set Buffer = New clsBuffer
>
> Buffer.WriteLong SAttack
>
> Buffer.WriteLong Index
>
> SendDataToMap GetPlayerMap(index), Buffer.ToArray()
>
> Set Buffer = Nothing
>
> ```

Aw, yep! Worked as pie. My very thanks to you, bro.

And if anyone need the final code, here it goes:

```

Dim Buffer As clsBuffer

Set Buffer = New clsBuffer

Buffer.WriteBytes Data()

Dim attackingplayer As String

attackingplayer = Buffer.ReadLong

Set Buffer = Nothing

Set Buffer = New clsBuffer

Buffer.WriteLong SAttack

Buffer.WriteLong index

SendDataToMap GetPlayerMap(index), Buffer.ToArray()

Set Buffer = Nothing
```
Link to comment
Share on other sites

> No delete this code its not needed
>
> ```
>
> Set Buffer = New clsBuffer
>
> Buffer.WriteBytes Data()
>
> Dim attackingplayer As String
>
> attackingplayer = Buffer.ReadLong
>
> Set Buffer = Nothing
>
> ```
>
> also delete this line in client checkattack sub
>
> ```
>
> Buffer.WriteLong MyIndex
>
> ```

,

Gzz, sorry for the mistake! This one is working well, thank'ya again! ![:lol:](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/laugh.png)
Link to comment
Share on other sites

> Any can post in this thread the full tutorial? i don't understand where is the complete code and the work fine code… in this post have 20000 codes (?)... help?

I posted it [here](http://www.touchofdeathforums.com/community/index.php?/topic/129156-eoevent-system-3-some-bug-fixes/) a while ago, look the last Quote…
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...