Print Page | Close Window

Maximum Message Length

Printed From: Mirage Source
Category: Tutorials
Forum Name: Submitted Tutorials
Forum Discription: Tutorial submissions for MSE are posted here, waiting for approval
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=39
Printed Date: 20 December 2006 at 6:02pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Maximum Message Length
Posted By: Sync
Subject: Maximum Message Length
Date Posted: 07 February 2006 at 5:55pm
Originally posted by jokeofweek

[size=15pt]Maximum Message Length Tutorial(untested)
Difficulty:1/5

Okay. All this code is all server side   :lol: and i know its basic..but you never know. It might help ;-).

Oh. Before you start this tut, make sure you have a .ini server side called data.ini and add this to it:
[MSGLEN]
MaxLen=100

Note:Change the 100 to the wanted maximum length ;-)

~Server Side~

modGeneral

Okay, first of all, look for the following :

' Used for logging
Public ServerLog As Boolean


and add this right under it:

' Maximum Message Length Variables
Public MaxMsgLen As Long


Now, find Sub initserver and look for the following:
    Call SetStatus("Loading spells...")
    Call LoadSpells


and add the following under:

If FileExist("data.ini") then
MaxMsgLen= Val(GetVar(App.Path & "\data.ini", "MSGLEN", "MaxLen"))
else
maxmsglen = 100
call putvar(App.Path & "\data.ini","MSGLEN","MAXLEN","100")
end if


good :) your done with that module.

ModServerTCP

Good. Now open up this module and look for this code:
Sub GlobalMsg(ByVal Msg As String, ByVal Color As Byte)
Dim Packet As String

    Packet = "GLOBALMSG" & SEP_CHAR & Msg & SEP_CHAR & Color & SEP_CHAR & END_CHAR
   
    Call SendDataToAll(Packet)
End Sub

Sub AdminMsg(ByVal Msg As String, ByVal Color As Byte)
Dim Packet As String
Dim I As Long

    Packet = "ADMINMSG" & SEP_CHAR & Msg & SEP_CHAR & Color & SEP_CHAR & END_CHAR
    For I = 1 To MAX_PLAYERS
        If IsPlaying(I) And GetPlayerAccess(I) > 0 Then
             Call SendDataTo(I, Packet)
        End If
    Next I
End Sub

Sub PlayerMsg(ByVal Index As Long, ByVal Msg As String, ByVal Color As Byte)
Dim Packet As String

    Packet = "PLAYERMSG" & SEP_CHAR & Msg & SEP_CHAR & Color & SEP_CHAR & END_CHAR
   
    Call SendDataTo(Index, Packet)
End Sub

Sub MapMsg(ByVal MapNum As Long, ByVal Msg As String, ByVal Color As Byte)
Dim Packet As String
Dim Text As String

    Packet = "MAPMSG" & SEP_CHAR & Msg & SEP_CHAR & Color & SEP_CHAR & END_CHAR
   
    Call SendDataToMap(MapNum, Packet)
End Sub

Sub AlertMsg(ByVal Index As Long, ByVal Msg As String)
Dim Packet As String

    Packet = "ALERTMSG" & SEP_CHAR & Msg & SEP_CHAR & END_CHAR
   
    Call SendDataTo(Index, Packet)
    QueueDisconnect(Index) = True
End Sub


and replace it with :

Sub GlobalMsg(ByVal Msg As String, ByVal Color As Byte)
Dim Packet As String
    Msg = Left(MaxMsgLen, msg)
    Packet = "GLOBALMSG" & SEP_CHAR & Msg & SEP_CHAR & Color & SEP_CHAR & END_CHAR
   
    Call SendDataToAll(Packet)
End Sub

Sub AdminMsg(ByVal Msg As String, ByVal Color As Byte)
Dim Packet As String
Dim I As Long
    Msg = Left(MaxMsgLen, msg)
    Packet = "ADMINMSG" & SEP_CHAR & Msg & SEP_CHAR & Color & SEP_CHAR & END_CHAR
    For I = 1 To MAX_PLAYERS
        If IsPlaying(I) And GetPlayerAccess(I) > 0 Then
             Call SendDataTo(I, Packet)
        End If
    Next I
End Sub

Sub PlayerMsg(ByVal Index As Long, ByVal Msg As String, ByVal Color As Byte)
Dim Packet As String
    Msg = Left(MaxMsgLen, msg)
    Packet = "PLAYERMSG" & SEP_CHAR & Msg & SEP_CHAR & Color & SEP_CHAR & END_CHAR
   
    Call SendDataTo(Index, Packet)
End Sub

Sub MapMsg(ByVal MapNum As Long, ByVal Msg As String, ByVal Color As Byte)
Dim Packet As String
Dim Text As String
    Msg = Left(MaxMsgLen, msg)
    Packet = "MAPMSG" & SEP_CHAR & Msg & SEP_CHAR & Color & SEP_CHAR & END_CHAR
   
    Call SendDataToMap(MapNum, Packet)
End Sub

Sub AlertMsg(ByVal Index As Long, ByVal Msg As String)
Dim Packet As String
    Msg = Left(MaxMsgLen, msg)
    Packet = "ALERTMSG" & SEP_CHAR & Msg & SEP_CHAR & END_CHAR
   
    Call SendDataTo(Index, Packet)
    QueueDisconnect(Index) = True
End Sub


And thats all there is to it :-)

If there is a bug, or you have a comment, feel free to tell me :)

[EDIT]Added File Exist checker ;-)



Replies:
Posted By: Sync
Date Posted: 07 February 2006 at 5:56pm
Would of been approved, but I think the Left( function is mucked.



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info