GMS 2.3+ undefined variable of undefined object?

flexflower

Member
sSendKey script:

Code:
buffer_seek(buffer, buffer_seek_start, 0)
buffer_write(buffer, buffer_u8, PACKET_KEY)
buffer_write(buffer, buffer_u8, argument0)
buffer_write(buffer, buffer_u8, argument1)
network_send_packet(socket, buffer, buffer_tell(buffer))
create event of obj client

Code:
socket = network_create_socket(network_socket_tcp)
global.socket = socket
buffer = buffer_create(16384, buffer_grow, 1)
step event of obj client

Code:
if(keyboard_check_pressed(vk_left)){
    sSendKey(KEY_LEFT, true)
}

if(keyboard_check_released(vk_left)){
    sSendKey(KEY_LEFT, false)
}

if(keyboard_check_pressed(vk_right)){
    sSendKey(KEY_RIGHT, true)
}

if(keyboard_check_released(vk_right)){
    sSendKey(KEY_RIGHT, false)
}
and i get this error when i start the game

Code:
ERROR in
action number 1
of Create Event
for object <undefined>:
Variable <unknown_object>.buffer(100003, -2147483648) not set before reading it.
the obj client isnt in the room right when i start, thats maybe why, but i cannot put it in directly. if thats the problem, how do i resolve it, if its not then what is iitttt please help me im struggling with that for almost a week now
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
You are not creating a function for the script "sSendKey" and so the code is being run at the global scope before anything else in the game, as per the new rules for scripts. I suggest that you read up on how scripts work now in 2.3... ;)

 
Top