Jump to content

client/server emoting


Recommended Posts

ok well i'm completely stumped right now. i've been working that that clien/server chat program i found on these forums kind of beefing it up to be a nice little chat program for my friends and i. so far everything has been goin well untill the emote part...

for those who may not know... to Emote means to give expression. so in the chat usually when u talk it's like:

Particle > hey sup

Pookie > nothin...

but i want an emote feature so i can do stuff like:

Particle is bored>

heres some experiemental code that i tried but did not work(the comments are the different ways i tried but failed):

CLIENT PART

$me = GUICtrlCreateButton("Emote", 155, 40, 50, 20)
GUICtrlSetOnEvent($me, "_Emote")
Func _Emote()
    If not GUICtrlRead($input) Then Return 0
;TCPSend($sock, GUICtrlRead($input), Chr(1), "emote", Chr(2), "")
;TCPSend($sock, Chr(1), "emote", Chr(2), "")
;TCPSend($sock, Chr(1), "", Chr(2), "emote")
;TCPSend($sock, StringReplace(StringReplace(GUICtrlRead($input), Chr(1), "emote"), Chr(2), ""))
;TCPSend($sock, StringReplace(StringReplace(GUICtrlRead($input), Chr(1), ""), Chr(2), "emote"))
    GUICtrlSetData($input, "")
    Return 1
EndFunc

SERVER PART

Func _CheckConn()
   Local $recv = ""
   For $i = 0 to 16
      If $list[$i][0] Then
         $recv = TCPRecv($list[$i][0], 2048)
         If @error Then
        ; disconnect client
            TCPCloseSocket($list[$i][0])
            _SendAll(Chr(1) & "deluser" & Chr(2) & $list[$i][1])
            $list[$i][0] = 0
            $list[$i][1] = ""
         Else
            If $recv Then
              ; parse the command(s)
               $recv = StringSplit($recv, Chr(1))
               For $j = 1 to $recv[0]
                  $temp = StringSplit($recv[$j], Chr(2))
                  Switch $temp[1]
                     Case "bye"
                        TCPCloseSocket($list[$i][0])
                        _SendAll(Chr(1) & "deluser" & Chr(2) & $list[$i][1])
                        $list[$i][0] = 0
                        $list[$i][1] = ""
                     Case "kick"
                        _Kick($temp[2])
                     Case "PM"
                        _PM($temp[2], $temp[3], $list[$i][1])
                     Case "emote"
                        _Emote($temp[2])
                     Case Else
                        If $recv[$j] Then _SendAll($recv[$j], $list[$i][1])
                  EndSwitch
               Next
            EndIf
         EndIf
      EndIf
   Next
EndFunc

Func _Emote($str, $from = "", $except = 0 )
  ; send a message to all users
   For $i = 0 to 16
      If $list[$i][0] and $list[$i][0] <> $except Then
         If $from and StringLeft($str, 1) <> Chr(1) Then
            TCPSend($list[$i][0], $from & $str & " > ")
         Else
            TCPSend($list[$i][0], $str)
         EndIf
      EndIf
   Next
EndFunc

I know my code for emoting is probably completely wrong, but i'm trying my best and i want to learn more...please help?

Link to comment
Share on other sites

Well, maybe you can make a menu named "Emotions" and there will be "Happy", "Sad", etc and when user clicks on one of them a code sends. Then the client part (hopefully) recognizes the code and writes "Odie is Happy", "Garfield is in love" etc.

I can do signature me.

Link to comment
Share on other sites

i want to give the users ability to make their own emotes, have u ever played on battle.net? you would know what i mean.

No...I played Club Penguin...hmm... but I know what you mean

This is a little complicated because of fact that the emote registered on one client is not registered on another client

but if you send for example "registerEmote='waddles around'" and then "callRegisterEmote" to another client he would register "waddles around" and on "callRegisterEmote" it would say "i542 waddles around"... :)

i542

I can do signature me.

Link to comment
Share on other sites

Bumping will only get you flamed.

I think i542 had the right idea. When your client sends a "/me farts loudly" into the client, replace /me with a specialized character ... say CHR(199)...

the server reads CHR(199) as an emote and strips the ">" prompt from in front of the user's name and then echoes the stripped text back to the entire chat network.

Simple.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

;EMOTE OMG
Func _Emote($str, $from = "", $except = 0 )
 ; send an emote to all users
   For $i = 0 to 16
      If $list[$i][0] and $list[$i][0] <> $except Then
         If $from and StringLeft($str, 1) <> Chr(1) Then
             $from2 = StringTrimRight($from,2)
            TCPSend($list[$i][0], $from2 & " " & $str & " >" & @LF)
         Else
            TCPSend($list[$i][0], $str)
         EndIf
      EndIf
   Next
EndFunc;==>Emote

Func _SendAll( $str, $from = "", $except = 0 )
 ; send a message to all users
   For $i = 0 to 16
      If $list[$i][0] and $list[$i][0] <> $except Then
         If $from and StringLeft($str, 1) <> Chr(1) Then
            TCPSend($list[$i][0], $from & " " & $str & @LF)
         Else
            TCPSend($list[$i][0], $str)
         EndIf
      EndIf
   Next
EndFunc

blha, i didnt test it. hold on.

Edited by BackStabbed

tolle indicium

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...