Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //--Accept incoming connections--//
- Incoming = socket_accept(Socket);
- if(Incoming)
- {
- //Set up incoming connection
- ID = NewPlayerID();
- if(ID)
- {
- with(instance_create(0, 0, Player))
- {
- //This is basically the create event for the player object
- ID = other.ID;
- Socket = other.Incoming;
- SetPlayerID(ID, Socket);
- socket_sendbuffer_limit(Socket, 65535);
- //Send the new player to everyone else
- Buffer = buffer_create();
- buffer_clear(Buffer);
- write_ubyte(Buffer, 0);
- write_ubyte(Buffer, ID);
- write_ubyte(Buffer, 1);
- write_string(Buffer, "E");
- socket_send_all(Buffer, Socket);
- Name = "Unnamed";
- Timeout = 0;
- TimeDelta = current_time;
- Input = 0;
- Players += 1;
- }
- //Send all existing players to new one
- with(Player)
- {
- if(ID != other.ID)
- {
- write_ubyte(other.Incoming, 0);
- write_ubyte(other.Incoming, ID);
- write_ubyte(other.Incoming, Length);
- write_string(other.Incoming, Name);
- socket_send(other.Incoming);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment