Ariel Posted November 1, 2011 Author Share Posted November 1, 2011 Adding News to a label in the frmMain from a file in the server folder.Heya :embarrassed: Im new Here :DAs well new in the packeting thing so i made it as an extra in already made pack, SendEXP Hope that still helps!**First thing first, Make a .txt file named: ingame_news in the Server\Data folder!**Server-Side:Find:```Function GetNews()'read news Dim tmpTxt As String, tmpArray() As String, i As Long ' load news Open App.Path & "\data\ingame_news.txt" For Input As #1 Line Input #1, tmpTxt Close #1 ' split breaks tmpArray() = Split(tmpTxt, "/nl") For i = 0 To UBound(tmpArray) news = frmServer.lblnews.Caption & tmpArray(i) & vbNewLine NextEnd Function```Then search for:```Sub SendEXP(ByVal Index As Long)```After the first "Dim"add```Call GetNews```added after```Buffer.WriteLong GetPlayerNextLevel(Index)```This:```Buffer.WriteString news```Server Side done!Client-Side:Before Editing the Client Make a label in the frmMain called lblNews.Find:```Function IsTryingToMove() As Boolean```Below the function add the function:```Function setNews(ByVal News As String)frmMain.lblNews = NewsEnd Function```Last find the sub```Private Sub HandlePlayerExp```and Add after the "Dim"```Dim News As String```then before "Exit sub" add:``` News = Buffer.ReadString Call setNews(News)``` Link to comment Share on other sites More sharing options...
xppxdd Posted November 16, 2011 Share Posted November 16, 2011 Nicee :)) Link to comment Share on other sites More sharing options...
Yxxe Posted November 16, 2011 Share Posted November 16, 2011 This is really inefficient. Why are you sending the news every time the player gains exp? Surely you should just contact the server when the client loads up and get the text that way, or just upload the txt file for download in an autoupdater. Link to comment Share on other sites More sharing options...
Rob Janes Posted November 16, 2011 Share Posted November 16, 2011 This method 'works' but very inefficently. A+ for effort on learning the packets though.Your method of loading the news file should be done once at the Startup of the Server in Sub Main or whenever someone forces it to reload the News.txt file through a command or button. This way the news is stored in memory on startup and not loading every time an individual player checks their EXP.Next, rather than piggy backing with the SendEXP, create a seperate Enumerator for handling news. You'll want to look in modEnumerations, and add something like SSendNews for example. Create a seperate function that is called when a player joins the game in modPlayer. Use that new function to send the news to that player when they connect, saving you a lot of data transfer from Server>Client whenever they gain EXP ;) It's not hard to learn how to create new packets, you have the basis of it so far, so pick at it a bit more and learn. The biggest things to remember are:1\. Add your Client or Server enumerator at the end of each array in modEnumerations on the client AND the server. General rule of thumb is to put an S infront of a Server packet and C infront of a Client packet.2\. A blank server packet will look something like this```Public Sub ThisIsMyNewServerSub(byval Index as Long)Dim Buffer as clsBufferSet Buffer = New ClsBufferBuffer.WriteLong SMyNewEnumeratorBuffer.WriteString "Hello World!"SendDataTo Index, Buffer.ToArray()Set Buffer = NothingEnd Sub```You'd look in modHandleData and handle the SMyNewEnumerator and tell it what function to call when it finds a packet starting with that variable. ;) Link to comment Share on other sites More sharing options...
Ariel Posted January 14, 2012 Author Share Posted January 14, 2012 Thank you !I will try it :) Link to comment Share on other sites More sharing options...
achap89 Posted January 21, 2012 Share Posted January 21, 2012 Why not use it onload? Wouldn't that be so much more efficient? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now