Usage: gms_other_get ( player_id, "variable" )


Returns the value saved in the given player's variable. If the variable doesn't exist, 0 (zero) is returned.

Replies (68)

Last message on 16 Dec 2016

mpgame on 15 Dec 2016, 14:38:41
We can receive value of a variable in obj_other_player from obj_player by gms_other_get ( player_id, "variable") but how we can receive value of a variable in obj_player from obj_other_player?
Size43 (Administrator) on 16 Dec 2016, 21:13:56
You could use the with-statement, or iterate over all other players by using gms_other_count and gms_other_find.
amkgames on 18 May 2015, 20:07:33
Need to replace player_id to obj_player?
Size43 (Administrator) on 18 May 2015, 21:00:49
Nope, player_id is a variable the extension automatically adds to all other player objects.
amkgames on 19 May 2015, 07:09:54
Got error: Unknown Variable player_id
Size43 (Administrator) on 20 May 2015, 11:34:02
The variable isn't available in the create event or when you create other player objects yourself (by placing them in the room, for example). After that, the variable will exist.
amkgames on 20 May 2015, 11:41:48
Then how do i do it? Please can you give me an example like of variable "jump" and if jump = true then jump?
Size43 (Administrator) on 20 May 2015, 12:10:38
What does jump do? If it modifies the position, you won't need to sync it. If it modifies another variable, sync that variable instead. You'll mostly need to sync variables you need to draw the other players correctly.
amkgames on 20 May 2015, 12:40:18
And i am getting error when second player connect:
action number 1
of Begin Step Event
for object __newobject31:

The server is sending corrupt data: The player that was supposed to login, is already logged in. (id = 63791, 15)
Size43 (Administrator) on 23 May 2015, 13:58:06
That error isn't as bad as it sounds. It means the server has sent the same player login info twice. It should not affect the rest of the functionality. Would you mind mailing ( me the gmk/gmz so I can fix it?

In the meantime, you could use gms_debug_hide_errors to hide these errors.
amkgames on 4 Jul 2015, 19:59:40
Hey Size, Did you got my gmk file? or did i sent it to someone else? :O
Size43 (Administrator) on 7 Jul 2015, 15:33:05

It seems like you're having the same problem as namlunthkl. I'm not able to reproduce it, so it's impossible for me to fix.

Also, it seems like you're using instance_deactivate. Make sure to not deactivate the object the extension uses internally (global.__obj), or activate it directly after deactivating. Without it, things like the player position cannot be synced.
amkgames on 7 Jul 2015, 15:44:16
So my problem will not be fixed ever? :O

Oh, Okay thanks. :)
Size43 (Administrator) on 7 Jul 2015, 19:15:52
Well I can't fix it if I can't make the error appear and debug it. Besides, it's not hard to completely hide the error without any side effects (gms_debug_hide_errors). You won't ever see the error again if you call that function after gms_settings, and it won't affect the extension at all. Therefore, I don't think it's worth spending hours trying to find that bug :)
amkgames on 7 Jul 2015, 20:00:10
Okay thanks and that error was not in my laptop(6-7 months ago) but it is appearing in my computer. (my laptop is damaged so i can't check if it appears in it too.)
Size43 (Administrator) on 14 Jul 2015, 22:04:22
In the last 6-7 months a lot has changed. If I ever find a way to get that error on my PC I'll fix it. Otherwise, I can't really do anything. ;)
amkgames on 14 Jul 2015, 23:34:15
:), for multiple players, first player is not being synced to second client. (sorry about this. :P)
I think this is being caused by login error. (there might be something wrong in my computer which is doing this.)
Size43 (Administrator) on 19 Jul 2015, 22:37:25
I believe I did see that error as well, I'll take another look!
amkgames on 12 Aug 2015, 20:25:15
Have you found the problem? or fixed it?
Size43 (Administrator) on 20 Aug 2015, 21:59:37
Apologies for my late reply. Outlook is blocking all mail, which means I don't get notified when you post something.

I'm working on an update that will fix a few bugs. That may fix this one as well. Not too sure about it though. I'll be leaving for a short vacation shortly, so please don't expect the update for another two weeks or so.
amkgames on 21 Aug 2015, 08:57:18
But I didn't had any problems or errors even if I removed hide errors, as long as I not use activate only view region code.
Size43 (Administrator) on 6 Sep 2015, 20:58:52
What's does that "activate only view region code" do? Would you be able to post it (or mail it to
amkgames on 7 Sep 2015, 14:05:11
instance_activate_region(view_xview, view_yview, view_xview + view_wview, view_yview + view_hview, true);
Size43 (Administrator) on 7 Sep 2015, 17:22:14
Are you still having problems with this, or has this been fixed by activating the player objects as well?
amkgames on 8 Sep 2015, 07:43:32
There are problems with this code but thanks to you for the help, after activating player objects as well, there are no problems.

By the way, will game lag if there are so many players in big room? If yes then is it possible to deactivate other players outside view and activate when inside view?
Size43 (Administrator) on 8 Sep 2015, 12:06:15
You can set the local distance on the site to prevent syncing players that are further away than a certain distance. I don't recommend disabling (other) player objects.
amkgames on 8 Sep 2015, 12:14:55
Oh, I have already set it, Thanks. :)
amkgames on 14 Jul 2015, 23:35:45
Because, if problem was in extension then everyone had that problem.
Size43 (Administrator) on 5 Jul 2015, 15:38:19
Yes, I have received it. I haven't had the time to take a look at it, but I will as soon as I can!
amkgames on 5 Jul 2015, 16:18:28
Oh, okay take as much time as you want. :)
amkgames on 28 Jun 2015, 17:24:03
Okay i sent file and 2 player objects are having problems still so may you please take a look on rit? Thanks
amkgames on 23 May 2015, 14:35:57
Okay i will send file soon and may you please check the problem with jump sync too?
Size43 (Administrator) on 23 May 2015, 14:38:35
Sure, I'll take a look. I won't change any code, though. That's up to you :)
amkgames on 23 May 2015, 15:00:39
Thanks :)
amkgames on 20 May 2015, 12:27:44
It modifies position
Size43 (Administrator) on 23 May 2015, 13:55:18
If it modifies position, I'd think you won't need to sync it because the position is already synced.
amkgames on 23 May 2015, 14:39:43
I thinks that it changes position by z, zgravity and zspeed variables so they are not being synced
Size43 (Administrator) on 23 May 2015, 14:41:10
Then you'd have to sync z. You won't need to sync zgravity, zspeed or jump as they all modify z.
amkgames on 23 May 2015, 15:04:13
But i don't know where to use gms_self_set and gms_other_get last time i used self set in create event of obj_player and other get in obj_other_player's create event.
Size43 (Administrator) on 23 May 2015, 19:44:37
Put gms_self_set in the step event, or whenever you change the value of the variable. Put gms_other_get when there's no way your code will work without knowing that variable (for example, if your draw code relies on knowing what z is, put gms_other_get in the draw event). Don't put it in the create event of other player objects, though. That's a limitation in GameMaker.
amkgames on 24 May 2015, 08:00:17
"whenever you change the value of the variable" its what where i am stucked on, i need to do like this?:
z = 0
//Later z will increase
z +=1
//in last of step event i need to put gms_self_set code? Or need to replace all z of step event to gms self set? (i think not)
amkgames on 24 May 2015, 08:17:35
I got now it means whenever i change value then i need to add gms self set too :D
btw if i write z on place of value in gms self set so will it read value of z?
Size43 (Administrator) on 24 May 2015, 11:52:50
Correct. To sync the z-variable, use this code:

gms_self_set('z', z)

Then in, for example, the draw or step event of the other player object, add this code:
z = gms_other_get(player_id, 'z')
amkgames on 24 May 2015, 13:30:40
Yes i tried and it worked :D
but how do i sync its collision with block when other player is on block?
I am using this code in block: Step Event: if player.z>=16 {solid=false exit}solid=true
Size43 (Administrator) on 24 May 2015, 20:56:07
You shouldn't have to sync the collision, because the collision will affect the position of the object again, right? So if you just sync the position the collision will also be synced though the x, y, or z variable.
amkgames on 24 May 2015, 21:00:35
Yes but problem is when player goes on top of block then block becomes not solid
and if i will write player.z or otherplayer.z >=16
Then when other player will be on top, block will be not solid for player too
amkgames on 24 May 2015, 21:04:11
I thinks that its being seen by player that other player is stuck on block because block is solid for player not for other player so i need to do something that will make player see other player is not stuck on block
Size43 (Administrator) on 26 May 2015, 11:09:35
Don't handle collisions for the other player objects at all. If the other player object is solid, try making it not solid. The other player object should just copy movements from another client, not adjust those :)
amkgames on 29 May 2015, 20:16:33
Is there no solution for it? :O
amkgames on 26 May 2015, 19:08:05
Yes but solid is only block and it becomes not solid when player jumps on its top and then when player jumps down it becomes solid again, so when other player jumps on block when block is solid for obj_player so it looks like other player is stuck on it.
Size43 (Administrator) on 30 May 2015, 16:25:58
I don't see how that should be a problem. The extension directly modifies the position of the other player objects, so solid or not solid should not be a problem for the other players. Please send me the gmk/gmz so I can take a look :)
amkgames on 20 Jun 2015, 08:29:33
Hey you was right, i seen it carefully and it not stucks on block it moves later :D but why it works slow? I am making battle between 2 players so how can players play it? Can it be more faster?
Size43 (Administrator) on 20 Jun 2015, 15:18:12
What's your ping like? (gms_info_ping)
amkgames on 20 Jun 2015, 15:31:54
Size43 (Administrator) on 20 Jun 2015, 16:28:01
Does it also lag in the same way when the player is not near a block?

If the problem is caused by connection latency there may not be a solution other than physically moving closer to the server.
amkgames on 21 Jun 2015, 08:49:52
Hmm, Okay Thanks, no matter what i am going to make it anyway :)
amkgames on 30 May 2015, 16:32:34
Oh, Thank you, i will send file as soon as possible :)
amkgames on 20 May 2015, 11:40:11
Then how do i do it? Please can you give me an example like syncing variable jum
amkgames on 18 May 2015, 20:29:42
and need to write variable between "" ?
Size43 (Administrator) on 18 May 2015, 21:00:11
Yes, you need to write variable names between quotes.
amkgames on 19 May 2015, 18:06:52
I had put gms_self_set[/script] in create event of obj_player and gms_other_get[/script] in create event of obj_other_player
amkgames on 19 May 2015, 18:11:02
amkgames on 19 May 2015, 18:08:23
Wow [/script] thing not worked for me :P
amkgames on 19 May 2015, 18:09:19
amkgames on 19 May 2015, 18:09:34
Worked :P
amkgames on 15 Oct 2015, 16:29:25
Trying code thingy.
amkgames on 15 Oct 2015, 16:29:35
WOW! lol
amkgames on 19 May 2015, 06:54:46
Thanks :D