Basically, I just want to send a packet from one client to another that says, "I have selected this character and now you can't". Code here:
func _process(delta):
_read_P2P_Packet()
func _send_P2P_Packet(data, send_type, channel):
# If there is more than one user, send packets
if SteamGlobal.LOBBY_MEMBERS.size() > 1:
# Loop through all members that aren't you
for MEMBER in SteamGlobal.LOBBY_MEMBERS:
if MEMBER['steam_id'] != SteamGlobal.STEAM_ID:
Steam.sendP2PPacket(MEMBER['steam_id'], data, send_type, channel)
data = {"type":"function", "character":"", "button_disabled":""}
func _read_P2P_Packet():
var PACKET_SIZE = Steam.getAvailableP2PPacketSize(0)
# There is a packet
if PACKET_SIZE > 0:
var PACKET = Steam.readP2PPacket(PACKET_SIZE, 0)
if PACKET.empty():
print("WARNING: read an empty packet with non-zero size!")
# Get the remote user's ID
var PACKET_ID = str(PACKET.steamIDRemote)
var PACKET_CODE = str(PACKET.data[0])
var READABLE = bytes2var(PACKET.data.subarray(1, PACKET_SIZE - 1))
print("Packet: "+str(READABLE))
# Do something with the data
if READABLE['type'] == "function":
_do_Update(READABLE['character'], READABLE['button_disabled'])
print(SteamGlobal.actor_path, $CharSelect/VBoxContainer/James.disabled)
func _do_Update(character, button_disabled):
character = SteamGlobal.actor_path
button_disabled = $CharSelect/VBoxContainer/James.disabled
func choose_james():
previous_button_pressed = $CharSelect/VBoxContainer/James
print("I can choose jack")
SteamGlobal.actor_path = "res://BlockHeadJackSteam.tscn"
$CharSelect/VBoxContainer/James.disabled = true
$CharSelect/VBoxContainer/James.add_color_override("font_color", Color.green)
$CharSelect/VBoxContainer/Jill.add_color_override("font_color", Color.white)
$CharSelect/VBoxContainer/Jack.add_color_override("font_color", Color.white)
$CharSelect/VBoxContainer/Jeb.add_color_override("font_color", Color.white)
JAMES.play()
func _on_James_pressed():
_send_P2P_Packet([choose_james(), SteamGlobal.actor_path, $CharSelect/VBoxContainer/James.disabled], 0, 0)
What am I doing wrong? I also tried inserting the ID of the player into the send packet function, but it doesn't even trigger the actual function, so the print line doesn't do anything.