M
MarkRazdrh
Guest
Hello, so I didn't know what i should type in for title cause i cant explain it in short way..
So I have this game where you create an account and pick a character then you press the button and then client(programmed in gamemaker) sends information to server and server stores it in database.
Now everything works fine when you connect in you see the character you picked(for example you choose red cat) but the problem comes when other people join your character becomes same as his character becouse server sends information and client stores it into same global variable so now you are both for example brown cats instead one is brown and other one (which in this example is you) is red.
Now im gonna tell you an example so it will be more understandable:
You create character and choose white cat and then you join, server sends your information back to client, client creates object(white cat) and then another guy joins and server then sends information to both clients then client creates instance of him and replaaces your cat which is white in database but it replaces your cat with his so you now both have black cat. Hope i was clear man this is hard let me put some codes in maybe you'll understand it even better
Now this is the code i have in my script for packet handeling(reading server commands things like that)
case "LOGIN":
status = buffer_read(argument0,buffer_string); //Client reads if login was successful or not
if(status == "TRUE"){
target_room = buffer_read(argument0,buffer_string); //Client reads in which room is the player who logged in
target_x = buffer_read(argument0,buffer_u16); //Client reads players last location
target_y = buffer_read(argument0,buffer_u16); //Client reads players last location
name = buffer_read(argument0,buffer_string); // Client reads the name of the player(so it can draw it later)
global.CatColour = buffer_read(argument0,buffer_string); //Client reads what colour is the player
goto_room = asset_get_index(target_room);
room_goto(goto_room);
with(instance_create(target_x + 40,target_y + 70,obj_player)){
name = other.name;
This is in my player object
var cat = global.CatColour;
switch(cat){
case "white":
sprite_index = spr_cat_down;
break;
case "black":
sprite_index = spr_catBlack_down;
break;
}
this is in my networkplayer object
switch(global.CatColour){
case "white":
sprite_index = spr_cat_down;
break;
case "black":
sprite_index = spr_catBlack_down;
break;
}
I know what the problem is but i just dont know how to fix it..
It is in global.CatColour becouse everytime someone logs in this variable changes(global.CatColour) and becouse every player object(networkplayer and player) uses this variable it's changing colours becouse variable is changing
Hope any of this makes sense if you have anything please type it in the comments and if you need anything else write in comments
Thanks
So I have this game where you create an account and pick a character then you press the button and then client(programmed in gamemaker) sends information to server and server stores it in database.
Now everything works fine when you connect in you see the character you picked(for example you choose red cat) but the problem comes when other people join your character becomes same as his character becouse server sends information and client stores it into same global variable so now you are both for example brown cats instead one is brown and other one (which in this example is you) is red.
Now im gonna tell you an example so it will be more understandable:
You create character and choose white cat and then you join, server sends your information back to client, client creates object(white cat) and then another guy joins and server then sends information to both clients then client creates instance of him and replaaces your cat which is white in database but it replaces your cat with his so you now both have black cat. Hope i was clear man this is hard let me put some codes in maybe you'll understand it even better
Now this is the code i have in my script for packet handeling(reading server commands things like that)
case "LOGIN":
status = buffer_read(argument0,buffer_string); //Client reads if login was successful or not
if(status == "TRUE"){
target_room = buffer_read(argument0,buffer_string); //Client reads in which room is the player who logged in
target_x = buffer_read(argument0,buffer_u16); //Client reads players last location
target_y = buffer_read(argument0,buffer_u16); //Client reads players last location
name = buffer_read(argument0,buffer_string); // Client reads the name of the player(so it can draw it later)
global.CatColour = buffer_read(argument0,buffer_string); //Client reads what colour is the player
goto_room = asset_get_index(target_room);
room_goto(goto_room);
with(instance_create(target_x + 40,target_y + 70,obj_player)){
name = other.name;
This is in my player object
var cat = global.CatColour;
switch(cat){
case "white":
sprite_index = spr_cat_down;
break;
case "black":
sprite_index = spr_catBlack_down;
break;
}
this is in my networkplayer object
switch(global.CatColour){
case "white":
sprite_index = spr_cat_down;
break;
case "black":
sprite_index = spr_catBlack_down;
break;
}
I know what the problem is but i just dont know how to fix it..
It is in global.CatColour becouse everytime someone logs in this variable changes(global.CatColour) and becouse every player object(networkplayer and player) uses this variable it's changing colours becouse variable is changing
Hope any of this makes sense if you have anything please type it in the comments and if you need anything else write in comments
Thanks