Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Pages: 1
Topic closed
Whipped up this message query, careful as baking a cake
(github link soon)
using PlayerIOClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Yonom.EE;
namespace Bot
{
public class MessageQuery
{
private Connection con;
private Dictionary<string, Action> MessagesCanRecieve = new Dictionary<string, Action>();
private List<Message> Recmessages = new List<Message>();
private List<Message> Senmessages = new List<Message>();
private bool swork = false;
private bool rwork = false;
private bool Initiated = false;
public void Initiate(Connection conn)
{
con = conn;
Initiated = true;
}
public bool CanAddRecieve(Message e)
{
if(MessagesCanRecieve.Keys.Contains(e.Type))
return true;
return false;
}
public void AddCanRecieve(string MessageType, Action Method)
{
MessagesCanRecieve.Add(MessageType, Method);
}
public bool RWorking()
{
return rwork;
}
public bool SWorking()
{
return swork;
}
public void AddRecieveMessage(Message e)
{
redo:
if (!RWorking())
{
if (CanAddRecieve(e))
{
Recmessages.Add(e);
}
}
else
{
while (RWorking())
{
// do nothing
Thread.Sleep(100);
}
goto redo;
}
}
public void AddSendMessage(Message e)
{
redo:
if (!SWorking())
{
Senmessages.Add(e);
}
else
{
while(SWorking())
{
// do nothing
Thread.Sleep(100);
}
goto redo;
}
}
public bool QueryHasRecieveWork()
{
return Recmessages.Count > 0;
}
public bool QueryHasSendWork()
{
return Senmessages.Count > 0;
}
public void FufillSendQuery()
{
if (!Initiated) { return; }
if (!QueryHasSendWork()) { return; }
swork = true;
for (int a = 0; a < Senmessages.Count; a++)
{
Message e = Senmessages[a];
PointTo.con.Send(e);
Thread.Sleep(10);
}
Senmessages.Clear();
swork = false;
}
public void FufillRecieveQuery()
{
bool nil;
if (!QueryHasRecieveWork()) { return; }
rwork = true;
for (int a = 0; a < Recmessages.Count; a++)
{
Message e = Recmessages[a];
if(MessagesCanRecieve.ContainsKey(e.Type))
MessagesCanRecieve[e.Type]();
}
Recmessages.Clear();
rwork = false;
}
}
}
How 2 use:
1) Define a MessageQuery (q) somewhere
2) Use this code to initiate workers
q = new MessageQuery();
new Thread(delegate()
{
while (true)
{
if (q.QueryHasRecieveWork())
q.FufillRecieveQuery();
}
}).Start();
new Thread(delegate()
{
while (true)
{
if (q.QueryHasSendWork())
q.FufillSendQuery();
}
}).Start();
3) Make sure to use some new code snippits
4) Add something to send
q.AddSendMessage(Message.Create("say", "your message junk here"));
Something I found out (that's been discovered many times probebly).
This is just my code, you can make your own if it suits you better.
Eh, it's less message loss, meaning more chance of placing all of those blocks.
Offline
Uh... what? I don't see how this would prevent 'message loss' nor what a 'message query' is.
*u stinky*
Offline
ugh
you stole my idea/code from R42Bot++, and now you make it even worse
pl0x its much more simple than that
@Atilla MESSAGE LOSS means that you send it too fast and lose a sent message (doesnt send)
and MESSAGE QUERY is a list that stores query, where a timer reads the last item, sends, and destroys last item
pl0x
Offline
yeah it sounds like what marco said, but since it stays on two threads the whole time, you're just as well off writing Thread.Sleep(20) after everything you send.
I like the receiving handler thing like what EE code has, and what I did once (idk why) but that doesn't achieve much anyhow
Offline
ugh
you stole my idea/code from R42Bot++, and now you make it even worse
pl0x its much more simple than that@Atilla MESSAGE LOSS means that you send it too fast and lose a sent message (doesnt send)
and MESSAGE QUERY is a list that stores query, where a timer reads the last item, sends, and destroys last item
pl0x
I didn't steal anything, nor would I bother going through the trouble of decompiling and then translating your (possibly messy) code.
Got the idea from spinastar when he said he uses a query.
Offline
Small note: it's called a queue not a query.
"Sometimes failing a leap of faith is better than inching forward"
- ShinsukeIto
Offline
marcoantonimsantos wrote:ugh
you stole my idea/code from R42Bot++, and now you make it even worse
pl0x its much more simple than that@Atilla MESSAGE LOSS means that you send it too fast and lose a sent message (doesnt send)
and MESSAGE QUERY is a list that stores query, where a timer reads the last item, sends, and destroys last item
pl0xI didn't steal anything, nor would I bother going through the trouble of decompiling and then translating your (possibly messy) code.
Got the idea from spinastar when he said he uses a query.
You could credit him first
also R42Bot++ is open-source in case you don't know
so...
You basically did what I did but even worse with much more unneeded lines.
Small note: it's called a queue not a query.
In this case it is a queue, but queries do exist (messy)
Offline
ninjasupeatsninja wrote:marcoantonimsantos wrote:ugh
you stole my idea/code from R42Bot++, and now you make it even worse
pl0x its much more simple than that@Atilla MESSAGE LOSS means that you send it too fast and lose a sent message (doesnt send)
and MESSAGE QUERY is a list that stores query, where a timer reads the last item, sends, and destroys last item
pl0xI didn't steal anything, nor would I bother going through the trouble of decompiling and then translating your (possibly messy) code.
Got the idea from spinastar when he said he uses a query.You could credit him first
also R42Bot++ is open-source in case you don't know
so...You basically did what I did but even worse with much more unneeded lines.
Can you please stop with copyright from your bot. How much haven't you taking code from others?
I don't really care if other people take ideas from my bots. Or making them different.
Seems like you are the only person in this forum page that getting butthurt every time.
Offline
Alright guys. @marco, copyright infringement is against the rules. So. Instead of minimodding, send a DCMA request to Diff and we will have it removed.
@capasha: Copyright is a serious concept and there is no way you can justify copying others without their agreement. Just because you are fine with people using your code doesn't mean everyone else is.
Please no longer post about copyright issues in this thread as it is off-topic.
I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.
Offline
There's no received message loss, and you don't need a 10ms delay between every packet you send, even for blocks.
Seems unnecessarily complex.
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
There's no received message loss, and you don't need a 10ms delay between every packet you send, even for blocks.
Seems unnecessarily complex.
^
This would only be good if you want the bot to say something, in wich that case multiple runs at somewhat same time could lose send.
Offline
honestly this is just something i thought worked and noticed, it seems to work so *shrug*
honestly i think by now it's only i who think this works
*shrug* closing topic *shrug*
Offline
Pages: 1
Topic closed
[ Started around 1732420087.2531 - Generated in 0.096 seconds, 15 queries executed - Memory usage: 1.59 MiB (Peak: 1.79 MiB) ]