Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Server side packet sending? EO3 VB6


IFX
 Share

Recommended Posts

So first off I would like to say sorry for first messaging pimp king rich, and then crest with what you are about to read. I know its a little spammy, but I'm in a coding mood and really just need the most instantaneous response I can get. (to rich and crest: I still would like to see what responses you guys have, I just thought I'd widen out my audience some)

without further wait: I understand how to send packets to the server, and I understand how to receive the packets. But I have one little problem, I don't get how to send them back to the client. Like I understand how to set up my buffer, and I get how to send it to the array (kind of). but how does the server know who to send the data to? How can I customize it via username to send it to that username? I don't understand.

And is there a way from the server to get the username of who sent in a packet to use for responding with a packet? Or would I just say senddatato index, buffer.toarray? Idk, I need a little explaining on this one.
Link to comment
Share on other sites

> So first off I would like to say sorry for first messaging pimp king rich, and then crest with what you are about to read. I know its a little spammy, but I'm in a coding mood and really just need the most instantaneous response I can get. (to rich and crest: I still would like to see what responses you guys have, I just thought I'd widen out my audience some)
>
> without further wait: I understand how to send packets to the server, and I understand how to receive the packets. But I have one little problem, I don't get how to send them back to the client. Like I understand how to set up my buffer, and I get how to send it to the array (kind of). but how does the server know who to send the data to? How can I customize it via username to send it to that username? I don't understand.
>
> And is there a way from the server to get the username of who sent in a packet to use for responding with a packet? Or would I just say senddatato index, buffer.toarray? Idk, I need a little explaining on this one.

Been a while since I touched VB6 (C# YAY) but if I remember correctly, the client has only one connection: the server. So, to send data, you use the sub SendData(Buffer.toarray()). But with the server, you have 1 to MAX_PLAYERS potential connections.

The way the packet system works is, you have an array of Subs. Imagine it like HandlingDataSub(1 to ClientPackets.End_Enum). This is why when you write up new packets, you need to add a new value into the enumeration _before_ the End_Enum. When the client or server receives a packet, it checks the first Long in the data. This is the Packet ID. The client or server then run the HandlingDataSub method of the Packet ID's index and pass off the remainder of the data. The only difference between the server and the client in terms of passing arguments is that in each handling data sub on the server, there is an Index argument. This will be the Player index and Socket index it is receiving from. So, to send a packet to a client from the server, just use the sub SendDataTo(index, Buffer.ToArray()). There are a few other subs like SendDataToMap and SendDataToAll, but they all use SendDataTo.

Come to think of it, I might just write up a tutorial on sending packets that goes a little bit more in depth. Anyways, let me know if this helps you!
Link to comment
Share on other sites

SendDataTo = Sends to specific player based on index  

SendDataToMap  = Sends to all players in a map 

SendDataToAll = Sends to all online players 

SendDataToAllBut = Sends to all players but specified players

SendDataToMapBut = Sends to all players in a map but specified players

SendDataToParty = Sends to all players in specified party.

These functions can be used to send data to players. 

It seems you still haven't checked out the source code. You figure stuff out on your own to an extent. If we simply keep spoon-feeding you the answers you won't understand anything. Check out existing parts of the code.
Link to comment
Share on other sites

> It seems you still haven't checked out the source code. You figure stuff out on your own to an extent. If we simply keep spoon-feeding you the answers you won't understand anything. Check out existing parts of the code.

I have been looking through the code, quite a bit. I just have a little bit of trouble grasping things in the code when its all a foreign language to me. I appreciate that you are helping me, and If you are bothered that much by my asking questions I do not require that you respond. 

Now that aside, I had the understanding that Index had something to do with who it sends to, but how would I manipulate "index" to send it to a set player?
Link to comment
Share on other sites

> Now that aside, I had the understanding that Index had something to do with who it sends to, but how would I manipulate "index" to send it to a set player?

You send packets based on specific events. Events like a player presses control, a player causes damage to an entity, an npc moves, an event continues, a player saves something on the editor etc. etc

Based upon the situation you'll already have the index. If you get a packet from a player then you'll have the index of the player who sent the packet. If an NPC moves in a map you send that data to all the players in a map. If a person edits and saves something then send the new data to all etc. 

Whichever method you enter into, there will always be a reference to a player. Either there'll be an index variable or a For Loop which goes through each and every online player. 

And I don't see how anything in the code is a foreign language. The names of methods and variables are very easy to understand. A method like IsPlaying does what it sounds like. It checks whether a specific player is playing. A method like SendDataTo sends data to someone. When I tell you to read the code, I don't mean you just mindlessly go and start reading some random topic. Check out something specific in the engine like a player drops an item in game. The sequence would be something like this: 

Player right clicks inventory to drop item -> Client sends a packet to the server -> Server adds the item to the map, takes the item away from player -> Servers sends new data to all players in the map. 

Check out how what happens when you open up an editor, when you transfer to a different map, etc. etc. 

EDIT: I'm sorry if I come out as rude, telling you to figure out everything on your own. However if you don't solve problems and figure stuff out on your own then there's no use programming. The most important part of programming is figuring out and solving problems.
Link to comment
Share on other sites

> EDIT: I'm sorry if I come out as rude, telling you to figure out everything on your own. However if you don't solve problems and figure stuff out on your own then there's no use programming. The most important part of programming is figuring out and solving problems.

I've been spending a lot of time looking through server side code. The entirety of manipulating the code doesn't bother me, nor does it intimidate me. And in most cases I can troubleshoot things fearlessly. I guess what I'm trying to do just doesn't work in the system. I'm trying to send packets to a client, based off of a username sent in from another client. And nothing in the code seems to show how that works. I've looked at trading systems a lot hoping to find something in there but I just don't know where to start. 

Not trying to sound pitiful or anything but after trial and error for almost a week straight, 2 hours a night each night, coming up with the same issues over and over starts to wear down on someones ego a little bit.
Link to comment
Share on other sites

Okay, you want to send a packet to a client based on the name sent from another client. Break down the processes into steps. 

1. Get the name from another client.
2. Check if the player exists. Check if he is online. (Go through each and every logged in player and check their name with the name you have)
3. If the player is online then get his index. Do w.e you want then.

I don't think you know what exactly the index means. Each server can accept Max_players number of players. This means that each there should be an individual socket for each player. This would mean an array of sockets and players. Each index in that array is what we generally call the player index. 

EDIT: I understand you're looking on how to create a friends system. This forums already has a tutorial for that. Search for the tutorial and see how it work. That'll be a lot more useful then just trying to start from scratch.
Link to comment
Share on other sites

> EDIT: I understand you're looking on how to create a friends system. This forums already has a tutorial for that. Search for the tutorial and see how it work. That'll be a lot more useful then just trying to start from scratch.

The problem is i  HAD added that friend system and it didn't have the key trait I wanted. It doesn't require the other person to accept the friend request for them to be added as a friend. Its more of a stalk button then anything that saves their name in a list and thats it. I plan on going a bit farther then that. 

> 1. Get the name from another client.
> 2. Check if the player exists. Check if he is online. (Go through each and every logged in player and check their name with the name you have)
> 3. If the player is online then get his index. Do w.e you want then.

I have tried. I do understand what a socket is, and recently have learned what an index is (within the time from the beginning of the post till now). My problem is I've searched everywhere using keywords, and by going line by line through all of the connection codes and haven't found where the index and the name cross. I was just hoping for a little help like oh yeah search for "this" in "this" and that should point you in the right direction, and if I have further issues I can come back.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...