bcirpggithubmirror/Phase2/Networking/Server/Server/Server.gd

24 lines
571 B
GDScript

extends Node
var network = NetworkedMultiplayerENet.new()
var port = 8080
var max_players = 4
func _ready():
start_server()
func start_server():
network.create_server(port, max_players)
get_tree().set_network_peer(network)
network.connect("peer_connected", self, "_player_connected")
network.connect("peer_disconnected", self, "_player_disconnected")
print("Server Started")
func _player_connected(player_id):
print("Player: " + str(player_id) + " Connected")
func _player_disconnected(player_id):
print("Player: " + str(player_id) + " Disconnected")