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

Party Only Chat


coziboy
 Share

Recommended Posts

Okay this is my first tutorial or whatever you can say because this is just a little change from some code :P

*tested on eclipse the final frontier

*difficult: Very Easy
(deathkeeper said :lol: )

**Client Side**

open **modEnumeration** and add this

```

CSayParty

```
below

```

CSayMsg

```
then find in **modClientTCP**

```

Public Sub SayMsg(ByVal text As String)
Dim buffer As clsBuffer

' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo ErrorHandler

Set buffer = New clsBuffer
buffer.WriteLong CSayMsg
buffer.WriteString text
SendData buffer.ToArray()
Set buffer = Nothing

' Error handler
Exit Sub
ErrorHandler:
HandleError "SayMsg", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub

```
below that add this

```

Public Sub PartyMsg(ByVal text As String)
Dim buffer As clsBuffer

' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo ErrorHandler

Set buffer = New clsBuffer
buffer.WriteLong CSayParty
buffer.WriteString text
SendData buffer.ToArray()
Set buffer = Nothing

' Error handler
Exit Sub
ErrorHandler:
HandleError "PartyMsg", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub

```
then open **modInput** and search for

```

' Say message
If Len(chatText) > 0 Then
Call SayMsg(MyText)
End If

```
below that add this

```

'Party Message
If Left$(chatText, 1) = "~" Then
chatText = Mid$(chatText, 2, Len(chatText) - 1)

If Len(chatText) > 0 Then
Call PartyMsg(chatText)
End If

MyText = vbNullString
UpdateShowChatText
Exit Sub
End If

```
**Server Side**

open **modEnumerations**

then below

```

CSayMsg

```
add this

```

CSayParty

```
open **modHandleData**

below

```

HandleDataSub(CSayMsg) = GetAddress(AddressOf HandleSayMsg)

```
add this

```

HandleDataSub(CSayParty) = GetAddress(AddressOf HandlePartyMsg)

```
still at **modHandleData**, search for this sub

```

Private Sub HandleSayMsg

```
below that sub add this sub

```

Public Sub HandlePartyMsg(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Msg As String, s As String
Dim partynum As Long, i As Long
Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteBytes Data()
Msg = buffer.ReadString

' Prevent hacking
For i = 1 To Len(Msg)

If AscW(Mid$(Msg, i, 1)) < 32 Or AscW(Mid$(Msg, i, 1)) > 126 Then
Exit Sub
End If

Next

If Not TempPlayer(index).inParty > 0 Then
PlayerMsg index, "You need to be in a party to talk in Party Chat!", BrightRed
Exit Sub
End If

s = "[Party]" & GetPlayerName(index) & ": " & Msg
partynum = TempPlayer(index).inParty
PartyMsg partynum, "[Party] " & GetPlayerName(index) & " : " & Msg, Blue
Call TextAdd(Msg)
Call AddLog(s, PLAYER_LOG)
Set buffer = Nothing
End Sub

```
**_Done…_**
Link to comment
Share on other sites

There is a tutorial for this. But since this a first timer, keep up the good work!

And also, just a suggestion: To make your code look a bit more neater, you could group together variable declaration. 

eg:

```
dim var1 as string, var2 as string
dim num1 as long, num2 as byte

```
etc
Link to comment
Share on other sites

> ```
>
> Dim Msg As String
> Dim s As String
> Dim partynum As Long
> Dim i As Long
>
> ```
> can also make bit shorter like
>
>  
>
> ```
>
> Dim Msg, s As String
> Dim partynum, i As Long
>
> ```
> Thanks for tutorial ;)

You cannot and should not do that.

All variables in VB should be declared with a type. It is not a necessity by a coding efficiency. It also prevents logical errors from taking place. In Domino's "example" his Msg and partynum variables are not string, longs but rather variants. 

It should be

```
dim msg as string, s as string
dim partnum as long, i as long

```
Link to comment
Share on other sites

> Saw one of these earlier on, but it's nice to see you come up with a useful tutorial! Keep up the good work ^_^

> There is a tutorial for this. But since this a first timer, keep up the good work!
>
> And also, just a suggestion: To make your code look a bit more neater, you could group together variable declaration. 
>
> eg:
>
> ```
> dim var1 as string, var2 as string
> dim num1 as long, num2 as byte
>
> ```
> etc

my mistake, sorry.. :(

> ```
>
> Dim Msg As String
> Dim s As String
> Dim partynum As Long
> Dim i As Long
>
> ```
> can also make bit shorter like
>
>  
>
> ```
>
> Dim Msg, s As String
> Dim partynum, i As Long
>
> ```
> Thanks for tutorial ;)

i think that will cause an error, if i'm sure that is vb.net script :huh:

but thanks for everyone who tell me to simply this code :wub:
Link to comment
Share on other sites

> ~~Umm isnt there already a party chat, with "/p" ?? o.O~~
>
> lol, i though eo had party chat xD But if not then this is helpful. :)

just like what i said, tested on eclipse the final frontier :lol:

in this engine there is no party chat with /p command ;)

CMIIW :P
Link to comment
Share on other sites

  • 8 months later...
  • 7 months later...

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...