Sync Owner

Posted by Chibi
Ok, so I've got a question.
I (Player) Instanciate a object and i get that instance owner with
That instance will create another instance, so I used gms_instance_sync(is_onetime,object,"owner"); once again.
When the player collides with the last created instance it gets killed and a death is added to the highscores, and when the other player (oOther) collides with it the player gets a kill (whos added on the scoreboard as well).
The problem here is : This doesn't happens, it says that it couldn't find the owner of the second instance.
How can I get the Owner of the second instance then ?
Sorry to bother you (Size43) once again with this question, but I'm having trouble to see this bug fixed.
Thanks, Chibi.

Replies (12)

Last message on 28 Dec 2017

Size43 (Administrator) on 25 Dec 2017, 14:41:09
Are you putting the object name in place of 'object'? That might sync the wrong instance.

You don't need the "owner" bit at the end. Every instance that's synced, will have the owner variable set by the extension automatically.
Chibi (Topicstarter) on 25 Dec 2017, 16:46:22
Yeah I've used the right name of the object on the code, look at it:
(On the Object Player (keyboard_check(vk_space)))

if Bombs > 0 {
if !gms_chat_istyping(){
if !place_meeting(self.x,self.y,oBomb){
i = instance_create(oPlayer.x,oPlayer.y,oBomb);
gms_instance_sync(i, is_onetime, "owner");
Bombs -= 1;

(On the object Bomb (Create Event))

owner = gms_self_name();
gms_instance_sync_var_add("owner", owner);
gms_instance_sync(self, is_onetime | isc_local);

and then I've just added a script on the object explosion who adds the score to the highscore list.

(Collision with oOther)

if owner != noone {
// and here the highscore part (who works well so far)

Any mistakes ?
Size43 (Administrator) on 26 Dec 2017, 12:14:05
Try using id instead of self. That might be throwing off the extension.

Also don't sync the variable 'owner'. The extension will automatically set that variable to the player_id of the player that created the instance.

So if you want to check if the collision is with a bomb created by another player, do something like this:

if owner != gms_self_playerid()
    // Do things
Chibi (Topicstarter) on 26 Dec 2017, 21:48:30
So I've tried to use:
if owner != gms_self_playerid()
    // Do things
But it wasn't working so I tried to use:
if owner = gms_self_playerid()
    // Do things
It worked, but not really well, now the player gets the kill once the oOther collides with the it's explosion (oPlayer's explosion) , but the problem's that when the oOther collides with the Explosion that he created the oPlayer gets a kill as well :/
What can I do ? (I'm completely lost)
Size43 (Administrator) on 27 Dec 2017, 13:15:39
Apologies, I'm getting a bit confused.

So you have a synced oBomb, which creates & syncs an oExplosion. Then you check in oOther if there's a collision with the oExplosion, and if there is you give the player that created the oExplosion a point?
Chibi (Topicstarter) on 27 Dec 2017, 13:37:15
Oh ok, what I did was to check the collision of oOther on the oExplosion, instead of checking it on the oOther. So the script that I've mentioned before was written on the oExplosion.
My objective is to give a point to the owner, if the explosion have been created by himself, if it wasn't created by him (if the oOther collides with the explosion that he created) then I don't want the server to give a point to the owner, but just give a death to the oOther.
Should I move this piece of code to the oOther ?
Size43 (Administrator) on 27 Dec 2017, 15:36:08
Wouldn't it be much easier to just check in oPlayer, and send a p2p message to the person that got a point? (new p2p tutorial is coming soon).

So basically:

1. A creates explosion
2. B oPlayer collides with explosion
3. explosion.owner is A's playerID, so owner != gms_self_playerid()
4. B dies, sends p2p message to A p2p_got_kill
5. A receives message, increases score
Chibi (Topicstarter) on 28 Dec 2017, 03:13:39
I got what you said here, but now the problem is that it says that the var isn't defined.
I used the same scripts that you've used on the shooter example that comes with gms, but a bit modified.

if(other.owner != gms_self_playerid() && !gms_team_player_is_friend(other.owner))
//If we didn't create the instance & it wasn't created by someone on the same team..
//..we get hit.
effect_create_above(ef_explosion, x, y, 0, c_red);

gms_chat(" was killed by " + gms_other_get_string(other.owner, "name"), c_blue);
gms_p2p_send(p2p_kill, other.owner);


and then I've set a macro called p2p_kill (value 0) and on the game start event I've added the following code:


Even after of all of this it says that the var owner wasn't created or the game simply crashes :/

What could it be ?
Size43 (Administrator) on 28 Dec 2017, 10:27:14
Then I'm not convinced the instance has actually been synced. The exension should set the owner variable as soon as you call gms_instance_sync.

Would you mind mailing me your gmk/gmz at
Chibi (Topicstarter) on 28 Dec 2017, 14:21:20
Sent you the with the full project including gmx file.
Chibi (Topicstarter) on 27 Dec 2017, 17:23:58
Seems like that will work fine, but about the p2p function, are you talking about:
gms_p2p_send ( id, player_id_to, arg0, arg1, arg2... )
or a specific script called p2p_got_kill ?
Chibi (Topicstarter) on 26 Dec 2017, 17:20:45
Im going to try using gms_self_playerid(), but still the collision I want to check is with the Explosion.