Register for your free account! | Forgot your password?

You last visited: Today at 18:21

  • Please register to post and access all features, it's quick, easy and FREE!

 

[Release] Hellmouth Broadcast

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2004
Posts: 26
Received Thanks: 4
[Release] Hellmouth Broadcast

Hello,
Well since ive started getting back into C#.net coding and learning the Hellmouth source i decided to give something back. So here it is just a simple broadcast system that brodcasts a new message every 50 seconds(can easily be changed).

Before we start i just want to say thanks to Pro4Never for releasing his source and making me want to brush up on my c# and wanting to learn again .

Also please give feedback as i want to see improvments that can be made.

OPEN: Extras/Dictionary.cs

FIND:
Code:
public static Dictionary<uint, Client> Waiting = new Dictionary<uint, Client>();
UNDER ADD:
Code:
public static SortedList<int, Broadcast> Broadcasts = new SortedList<int, Broadcast>();
OPEN: Structures/ChatType.cs

FIND:
Code:
Broadcast = 2050,
REPLACE WITH:
Code:
Broadcast = 2500,
OPEN: Program.cs

FIND:
Code:
EffT.Start();
UNDER ADD:
Code:
BroadcastQueue Brd = new BroadcastQueue();
Thread BrdT = new Thread(new ThreadStart(Brd.Run));
BrdT.Start();
OPEN: Tools.cs

FIND:
Code:
public class Effects
ABOVE ADD:
Code:
public class BroadcastQueue
    {
        public void Run()
        {
            while (true)
            {
                if (Dictionary.Clients.Count > 0)
                {
                    if (Dictionary.Broadcasts.Count > 0)
                    {
                       int id = Dictionary.Broadcasts.Keys[0];
                       Packets.ToServer(Packets.Chat(Dictionary.Broadcasts[id].Message, Dictionary.Broadcasts[id].Name, "ALL", Struct.ChatType.Broadcast));
                       Dictionary.Broadcasts.Remove(id);
                       Thread.Sleep(50000);
                    }
                }
            }
        }
    }
CREATE FILE: Objects/Broadcast.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hellmouth
{
    public class Broadcast
    {
        public string Name;
        public string Message;
        public byte Place;
    }
}
OPEN: Packet/PacketHandler.cs

FIND:
Code:
case 2050:
FIND IN:
Code:
case 3:
REPLACE CASE WITH:
Code:
case 3:
{
    if (Client.CP >= 5)
    {
        if (Dictionary.Broadcasts.Count <= 100)
        {
            Client.CP -= 5;
            Broadcast B = new Broadcast();

            B.Name = Client.Name;
            B.Message = Message;
            B.Place = (byte)Dictionary.Broadcasts.Count;

            Dictionary.Broadcasts.Add((Dictionary.Broadcasts.Count), B);
        }
    }                                   
}
break;
END



Yaksha is offline  
Thanks
1 User
Old   #2
 
elite*gold: 0
Join Date: Aug 2007
Posts: 2
Received Thanks: 0
thanks bro


leandrovermelauro is offline  
Old   #3
 
elite*gold: 0
Join Date: Apr 2011
Posts: 73
Received Thanks: 12
You made me lol at C#.net

.NET is a framework and not a language. C# is a programming language and VS C# is just a C# compiler.
Secured is offline  
Old   #4
 
elite*gold: 0
Join Date: Oct 2009
Posts: 123
Received Thanks: 21
i have 2 problems you can release a video?


thesamuraivega is offline  
Old   #5
 
elite*gold: 0
Join Date: Nov 2008
Posts: 25
Received Thanks: 8
i can't find
Quote:
case 2050:
in Packet/PacketHandler.cs
hackerboy10 is offline  
Old   #6
 
elite*gold: 0
Join Date: Oct 2009
Posts: 123
Received Thanks: 21
Quote:
Originally Posted by hackerboy10 View Post
i can't find
in Packet/PacketHandler.cs
i have the same problem
thesamuraivega is offline  
Old   #7
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,196
Received Thanks: 5,305
Solution is simple... try making a broadcast and you'll notice an error in console most likely saying unknown packet type *** (I'm guessing 2050is not in at all) in which case you can just code a new handler for that packet type.


Not a bad release. I'm kinda shocked seeing as almost all of the broadcast systems that got released for the old sources were soooo bad. This is actually decently thought through and should work quite well.

Suggestions for improvement would be minor but why not generate the actual packet to store instead of using a new Broadcast class/struct?

IE:

List<byte[]> Broadcasts = new List<byte[]>();

When creating a new one just generate the chat packet to be sent and add it to broadcast list. The thread then simply checks if Broadcasts has more than 0 elements, if so pulls the first one and simply does a ToServer(Dictionary.Broadcasts[0]); type thing.


Good work though,
P4N
pro4never is offline  
Thanks
3 Users
Old   #8
 
elite*gold: 0
Join Date: Aug 2004
Posts: 26
Received Thanks: 4
Sorry i didn't realize packet 2050 was not in the handler its is simple enough to add anyway.

And thank you pro4never ill try and update it when i update it i am still learning your source and how you organize things. but i shall look into it thank you.


EDIT:
also i was thinking of doing a check to see if a timer would better than a thread sleep im not sure which is more efficient processor wise.
Yaksha is offline  
Old   #9
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,196
Received Thanks: 5,305
I try to avoid timers whenever possible.... but at the same time using an entire thread for something like this does seem a tad excessive.

Personally I'd just do something like...

DateTime LastBroadcast = DateTime.Now; on startup then add in to say... effects thread

if(Broadcasts.Count > 0 && DateTime.Now > LastBroadCast.AddSeconds(30))
{
LastBroadcast = DateTime.Now;
ToServer(Broadcasts[0]);
Broadcasts.RemoveAt(0);
}
pro4never is offline  
Old   #10
 
elite*gold: 0
Join Date: Aug 2004
Posts: 26
Received Thanks: 4
sorry thats what i meant, ok i will try that when i have some spare time thanks
Yaksha is offline  
Old   #11
 
elite*gold: 0
Join Date: Jun 2010
Posts: 23
Received Thanks: 7
good job , i don't want to be a bad person but i think you took it from Conquer Emulator source , released by Jacob , there i saw the same system , whatever , you're good because you knew to put it in this source :P
onlyme23 is offline  
Old   #12
 
elite*gold: 0
Join Date: Aug 2010
Posts: 96
Received Thanks: 9
If its true, or not, that he got it from Co Emulator, still being a great job :P
hyperco is offline  
Old   #13
 
elite*gold: 0
Join Date: Aug 2010
Posts: 760
Received Thanks: 72
Code:
Error	1	The type or namespace name 'Broadcast' could not be found (are you missing a using directive or an assembly reference?)	C:\Users\Alan\Downloads\HellmouthDB\Extra\Dictionary.cs	20	39	Hellmouth
Code:
Error	2	The type or namespace name 'Broadcast' could not be found (are you missing a using directive or an assembly reference?)	C:\Users\Alan\Downloads\HellmouthDB\Extra\Dictionary.cs	20	83	Hellmouth


denominator is offline  
Reply



« Previous Thread | Next Thread »

Similar Threads
Release Spawns sistem for Hellmouth
Hi I hope you understand me, I do not know much English :P im mexican ok... 1.-Open The proyet Hellmouth with VisualStudio c# 2010 =) 2.-Find...
35 Replies - CO2 PServer Guides & Releases
[RELEASE] GM Broadcast item
Today im releasing a script to make a portable GM Broadcast item, I have just made this pretty basic to just give a basic usable idea for anyone to...
3 Replies - EO PServer Guides & Releases
[Release] Broadcast
Well first of all, The broadcast release by ArcherMaster didn't work for me.. So I just made my own This code is better, Because you can't...
24 Replies - CO2 PServer Guides & Releases
[RELEASE]Fix broadcast spam
This is for LOTF 5017, because im currently working on fixing the most things in it. So, i will release some of the stuff. Here is how to fix...
21 Replies - CO2 PServer Guides & Releases



All times are GMT +1. The time now is 18:21.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2017 elitepvpers All Rights Reserved.