Mirage Source
http://web.miragesource.net/forums/

News System
http://web.miragesource.net/forums/viewtopic.php?f=210&t=401
Page 1 of 2

Author:  DarkX [ Sun Aug 20, 2006 6:03 am ]
Post subject:  News System

Ok after Leighland Posted: Thu Aug 17, 2006 7:35 pm Live/Stats
I started working on a small system that is a text box called txtnews that is suppossed to grab it's info from news.ini but I am unable to get the code to work how it's suppossed to.

1. news =blank
2. admin updates it
3. player logs in
4. news is displayed on main menu

But I can't get the code to work correctly

Ok it's 2:04 am here so I gotta get some sleep later people.

Author:  halla [ Sun Aug 20, 2006 6:13 am ]
Post subject: 

what part are you having trouble with...

adding write news to server...

adding read news to client...

sending from server to client...

?

Author:  Trekz [ Sun Aug 20, 2006 9:32 am ]
Post subject: 

look at how Motd is set up.

Author:  DarkX [ Sun Aug 20, 2006 6:06 pm ]
Post subject: 

You mean like this

Server Side
Code:
    ' :::::::::::::::::::::
    ' :: Set NEWS packet ::
    ' :::::::::::::::::::::
    If LCase(Parse(0)) = "setNews" Then
        ' Prevent hacking
        If GetPlayerAccess(Index) < ADMIN_MAPPER Then
            Call HackingAttempt(Index, "Admin Cloning")
            Exit Sub
        End If
       
        Call PutVar(App.Path & "\data\News.ini", "NEWS", "Msg", Parse(1))
        Call GlobalMsg("News changed to: " & Parse(1), BrightCyan)
        Call AddLog(GetPlayerName(Index) & " changed NEWS to: " & Parse(1), ADMIN_LOG)
        Exit Sub
    End If


Client Side
Code:
Sub SendNEWSChange(ByVal NEWS As String)
Dim packet As String

    packet = "SETNEWS" & SEP_CHAR & NEWS & SEP_CHAR & END_CHAR
    Call SendData(packet)
End Sub

I'm not sure if theres anyother code to it, thats the code I had before but I can't get it to load into the text box on frmMainMenu

Author:  Trekz [ Sun Aug 20, 2006 7:11 pm ]
Post subject: 

aight im still rusty with vb and mirage been away for too long. But you are not trying to load it into a textbox there, u just sending a packet from client to server to save the news. after it saves send another packet back to the client with the news, and when the client recives the packet, just make it display it in the textbox.

Author:  Matt [ Sun Aug 20, 2006 7:19 pm ]
Post subject: 

I don't get it, are you trying to do a news box on the main form, or trying to send a message when a player logs in?

Author:  DarkX [ Sun Aug 20, 2006 11:59 pm ]
Post subject: 

Ok let me clear this up, ok that code up there is the code I was using, which as you all said it sends into the client txtChat, I'm sick of that. So I'm trying to figure out the code to make it appear in a text box on the frmMainMenu, but again I can't figure out the code for sending, receiving, and I'm not even sure if I got the saving part right.

Author:  Matt [ Mon Aug 21, 2006 12:07 am ]
Post subject: 

I can write you a tut, to pull text from a txt file on a website, or to pull it from a txt file client side, which you can update everytime a player logs on, by making them download it automatically from your server or something.

Author:  DarkX [ Mon Aug 21, 2006 1:27 am ]
Post subject: 

Well the idea I was having was to; have it on the server side and edit it through the server or just by writting in it, and then everytime the player logs in they get the new info.

Author:  Matt [ Mon Aug 21, 2006 1:30 am ]
Post subject: 

Well, then you send a packet in sub main, to the server, to tell the server you need that data sent back, then you set it up client side, to recieve that packet, and set it to display that packet in a text box.

It really wouldn't be all that hard.

Author:  DarkX [ Mon Aug 21, 2006 1:33 am ]
Post subject: 

I've tried something like that but I can't get it right.

Author:  Matt [ Mon Aug 21, 2006 2:06 am ]
Post subject: 

I'll try working on it tomarrow, if I get it working, I will post a tut for it.

Author:  DarkX [ Mon Aug 21, 2006 2:31 am ]
Post subject: 

Alright, I'll keep trying some other codes, ohh thanks in advance if you get it working. I also found this code. http://www.splamm.com/elysium/forums/vi ... .php?t=523

Author:  Dark Echo [ Mon Aug 21, 2006 1:59 pm ]
Post subject: 

First thing you need to learn to be able to do this properly is to understand how packets are sent and recieved in Mirage Source.. Once you understand that concept you should be able to do basically anything you need..

I'll quickly run through it now.. I'll use sending hp as an example.. The server gets the players hp and puts it in a packet.. The packet has a simple label.. The packet should look something like this:

"playerhp" & SEP_CHAR & PlayerHp & SEP_CHAR & END_CHAR

Now, as you can see, SEP_CHAR separates the packets individual sections of data. this allows the client to distinguish between what is data and what isnt.. The END_CHAR tells the client when the packet ends.. And well the PlayerHP pretty much speaks for itself.. Now, This is still server side.. By default mirage sends all packets as strings.. So you use the SendData method (oh god im turning all java.. arghh.. i hate the word method) to send the packet from the server to the client..

Now client side.. When a packet is recieved it runs the HandleData method.. (Arghh again with the method) Anyway, the first thing you need to do, is add in a nice little section, and If statement by default, to check to see if your PlayerHP packet has arrived. Now if you remember from the top section, our packet was called playerhp.. So you just go If packet name = playerhp then update label.. Thats basically it..

Once you understand this concept, you will be able to send data to the client from the server and vice versa.. Happy coding.. :wink:

Author:  Matt [ Mon Aug 21, 2006 3:51 pm ]
Post subject: 

Posted the tut for pulling the news from a url. I will work on the other one later.

Author:  DarkX [ Mon Aug 21, 2006 3:52 pm ]
Post subject: 

you mean pulling the news from a website?

Author:  Matt [ Mon Aug 21, 2006 3:54 pm ]
Post subject: 

Yes, pretty much. You upload a text file to your website, and you use the link for it in the client, it will pull all the text from that file, and put it in a text box.

Author:  DarkX [ Mon Aug 21, 2006 3:57 pm ]
Post subject: 

ok, I'll still keep trying out stuff so I can edit on server side and view on client side

Author:  Matt [ Mon Aug 21, 2006 4:01 pm ]
Post subject: 

That's not hard to do, and I will get that one finished later. ^^

Author:  DarkX [ Mon Aug 21, 2006 4:03 pm ]
Post subject: 

ok well if not I'll make some mods to the one you have on there now and see what comes out

Author:  Matt [ Mon Aug 21, 2006 4:11 pm ]
Post subject: 

Well, that method is for only pulling it from a url.

The one I'm working on now, you type out the news on the main server form, and then click send, and it will send, and it will send it to the client, and save it client side in a text file. When the client is ran, it will check the contents of news.txt client side, against the news server side, and if it is different, it will pull the new, news and display it. ^^

Author:  DarkX [ Mon Aug 21, 2006 4:16 pm ]
Post subject: 

Well, I'll probably wind up using your tut anyway, but I'm still going to try and figure out the code.

Author:  Matt [ Mon Aug 21, 2006 4:43 pm ]
Post subject: 

The tut I already posted, will work fine, and will be easier for other staff to edit the news.

The method you want, requires making the client connect on frmMainMenu, so that you CAN send packets (At least, seems so to me, I could be wrong), which is something I don't feel like doing.

Sooner or later, I will get a tut out for this, but imo, the tut I already posted, should do perfectly fine.

Author:  DarkX [ Mon Aug 21, 2006 4:49 pm ]
Post subject: 

Alright well if you feel like writting the other one it's cool. Ok I found a code that's similar to what I want but still can't get the text to blit intothat freaking starting textbox.

here's the code;
client side:
Code:
   
    ' :::::::::::::::::::::::::::::::::
    ' ::     News Recieved packet    ::
    ' :::::::::::::::::::::::::::::::::
    If LCase(Parse(0)) = "news" Then
        Call WriteINI("DATA", "News", Parse(1), (App.Path & "\News.ini"))
        Exit Sub
    End If

ServerSide
Code:
Sub SendNewsTo(ByVal index As Long)
Dim Packet As String

    Packet = "NEWS" & SEP_CHAR & ReadINI("DATA", "ServerNews", App.Path & "\News.ini") & SEP_CHAR & END_CHAR
   
    Call SendDataTo(index, Packet)
End Sub
think that theres anything else that I should do to make it show the words in the text box?

Author:  wanai [ Tue Nov 02, 2021 4:51 am ]
Post subject:  Re: News System

Prem215.6CHAPReprStorGirlCafePietSingDaviFlowJeweWisaWassIndiSidnEdgaAlleWilsTorrXVIINULLMary
XIIIKrzyOxygDerePurcDougBrenEricTracPantSticBosqFortGezaPoulRudyXVIIAuroMatiSwalMaltHannJorg
PatrZoneKaraLeanVoguLighLycrPeteCircFallNikiHeggOmsaIronJameJeffJaneBabyJohnJoanAndaBoriRadi
CollEdgaHeatGillRobeSelaElemWindAlfrELEGOrieSileMariTellMichOverZoneUtsuArtsJaneTraiZoneGrea
ZoneZoneEverZoneZoneZoneAlesdiamZoneIsaoZoneZoneZoneZoneZoneStanCanoZonelsbkAnnaMinuZoneHapp
ZoneFabrGerhNokiCaulSamsNeveAtlaBookMcDoOscaRambGeerBeflRenzDonaMistSTARSonyKenwKareThistrac
IvreValiNDFESemcLegeIrinOutlWindPoweSaleAnimPanaLighSergYarrHereGrinManafantProlMariLikeAbov
AcadXVIIMigjSmokHoheMartJackJackCharGottWaltNapoMMORJudaJeweThisMineMariCarmMichJeffSPECGuid
wwwaStevLawrXXVIPunkBeasBlacCavestaiwwwnLeftHansWhatToveOverIcedfranAnimEnjoBetsDisnNokiNoki
NokiAdobGleeMorgSonyClouCyprMusiBirtConnPaolGracJohntuchkasEnidShin

Page 1 of 2 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/