GML MP checking who "owns"/ controls a instance

C

CodeBlack

Guest
Hey guys,

I currently have a ds_list from wich you can choose a Player you want to join in his team. The chosen player gets put into a global variable. What i want to do now is pick a instance and then check wether it belongs to the selected player or not, so i can track its x and y position.(i am using gmnet engine)

Any ideas how i could do that?

greetings
CodeBlack
 
C

CodeBlack

Guest
Ok since nobody seems to have an idea ill try to explain more in detail what i want to do.

I want Player A to create a vehicle and then give Player B the ability to select Player A from a dropdown Menu. Afterwards Player B should get a turret that is glued to the Vehicle of Player A.

In short: (Like a Tank) Player A moves and Player B controls a Turret and shoots Stuff.

Everything i tried on my own didnt work at all.

greetings
CodeBlack
 
K

Kenjiro

Guest
Can't just have a variable 'owner'.

owner = player_a

Can't be that hard can it?
 
S

SayBaconOneMoreTime

Guest
I don't know much about networking, so I can't help you with that part of it, but from player B's end, you should be able to do a with() statement with the object that is the tank, find the one that has the appropriate ID of the player (I'm sure you have some way of identifying this, store the player's id in a variable inside the tank when it is created), and spawn a turret that takes the ID of player B. I'm sure it won't be that hard doing that, unless there is more under the hood that I don't realize is happening.
 
S

SayBaconOneMoreTime

Guest
Woahhhh, replied to my own post instead of editing it, my bad.
 
C

CodeBlack

Guest
I don't know much about networking, so I can't help you with that part of it, but from player B's end, you should be able to do a with() statement with the object that is the tank, find the one that has the appropriate ID of the player (I'm sure you have some way of identifying this, store the player's id in a variable inside the tank when it is created), and spawn a turret that takes the ID of player B. I'm sure it won't be that hard doing that, unless there is more under the hood that I don't realize is happening.
Yep...that is what i was trying to do but i ran into problems with that. I get massive desyncs sometimes and when there are more than 2 Players (for example Player A+B and Player C+D) then i end up with all turrets on one Chassis, but always the wrong one. So the Position is different for every Player....that confused me a bit.

ill just put the Code here...maybe its a really stupid beginner error im not seeing ^^
Code:
///setup variables for position check

//get variable from Menu
var_chosentxt = global.var_chosentxt

// create pos vars
obj_chax = "";
obj_chay = "";

//Setup Vars for Loop
type[0] = obj_cha_Baselight;
type[1] = obj_cha_lighthover;
type[2] = obj_cha_lightscout;
types = 3;

///get Chassis Position

for(var t = 0; t < types; t++)
    {
    with(type[t])
        {
        if(other.var_chosentxt == self.var_plname)
            {
            other.obj_chax = x
            other.obj_chay = y
            }
        }
    }
y = obj_chay
x = obj_chax
 
Top