Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Catman |
My script:
extends Node2D
const DEFAULT_PORT = 28960
const MAX_CLIENTS = 6
var server = null
var client = null
var ip_address = “”
func _ready() → void:
if OS.get_name() == “Windows”:
ip_address = IP.get_local_addresses()[3]
elif OS.get_name() == “Android”:
ip_address = IP.get_local_addresses()[0]
else:
ip_address = IP.get_local_addresses()[3]
for ip in IP.get_local_addresses():
if ip.begins_with("192.168."):
ip_address = ip
get_tree().connect("connected_to_server", self "_connected_to_server")
get_tree().connect("server_disconnected", self "_server_disconnected")
func create_server() → void:
server = NetworkedMultiplayerENet.new()
server.create_server(DEFAULT_PORT, MAX_CLIENTS)
func _connected_to_server() → void:
print(“Seccessfully connected to the server”)
func _server_disconnected() → void:
print(“Disconnected from server”)
please help ty in advance
It’s hard to say since your code isn’t properly formatted above but I’d guess you might have an indention problem in that area of your code. If you can’t find it, edit the above post and format the code (via the {} button in the forum editor’s toolbar).
jgodfrey | 2022-03-13 15:42
Godot 4 doesn’t exist, you probably meant to say Godot 3.4.?
Take a look at your Godot application, and on the bottom right of the output it’ll tell you the version you’re running.
Aimarekin | 2022-03-13 22:36
To be fair, I’m currently using Godot 4.0 alpha4, but admittedly the “i think” at the end really does add a lot of uncertainty to the version number
CardboardComputers | 2022-03-14 03:14
Im trying to do the same thing!
I also have this error and i have no idea what should i do
I’m using godot stable release 3.5
TheTopHat | 2022-10-27 19:40
“unexpected token” means Godot didn’t expect to see that written where you’ve written it.
In future, if you want help, you should post your actual code, because just saying “I have this error” means we can only guess at what you’ve done wrong. Make sure you format your code correctly - there’s a button for that when you’re posting here (it looks like {}
).
Also, make your own post - don’t reply to a 6 month old post that the original poster never replied to.
kidscancode | 2022-10-27 19:43