Register for your free account! | Forgot your password?

You last visited: Today at 00:55

  • 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 04/16/2011, 19:50   #2
 
elite*gold: 0
Join Date: Aug 2007
Posts: 2
Received Thanks: 0
thanks bro


leandrovermelauro is offline  
Old 04/16/2011, 19:53   #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 04/16/2011, 20:32   #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 04/16/2011, 22:34   #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 04/16/2011, 22:41   #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 04/17/2011, 01:37   #7
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,310
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 04/17/2011, 02:34   #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 04/17/2011, 03:03   #9
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,310
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 04/17/2011, 03:06   #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 04/17/2011, 22:29   #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 04/18/2011, 06:58   #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 05/03/2011, 06:19   #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



« [Small-Release] A few nice commands for LOTF | [Lelees!]Steeds Walk »

Similar Threads
Release Spawns sistem for Hellmouth
11/23/2011 - CO2 PServer Guides & Releases - 35 Replies
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 Monster.cs and replace Everything That there for: using System; using System.Collections.Generic;...
[RELEASE] GM Broadcast item
01/02/2011 - EO PServer Guides & Releases - 3 Replies
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 modify to suit there needs cq_action: INSERT INTO cq_action VALUES ('6400030', '6400031', '0000',...
[Release] Broadcast
08/16/2010 - CO2 PServer Guides & Releases - 24 Replies
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 broadcast in botjail.. Nor spam the broadcast.. Lets get started In, Client.cs Search public class...
[RELEASE]Fix broadcast spam
05/01/2010 - CO2 PServer Guides & Releases - 21 Replies
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 broadcast, so you can't spam it. Just wondered why it never was fixed. This should work, but is not...



All times are GMT +2. The time now is 00:55.


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

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