gms_self_set_precision

Usage: gms_self_set_precision ( "variable", precision )

Description

Sets the precision for the given variable. 'precision' describes how precise the variable must be sent. A precision of 0.4 means that the sent value will never differ more than 0.4.

Replies (8)

Last message on 23 Dec 2020

DarkerClarke on 12 Dec 2020, 23:06:29
I have set GMS setting for simple mode off (I want to completely control what is and isn't sync'd).
I have it setup in a way that hspeed and vspeed are sent if the direction the player is going in changes e.g left and now going right - if the direction is continuing in the same way as the previous step - no update is sent.

I have included that if the direction of the character is changed or comes to a stop or carries out an action THEN it will send an x and y update to ensure the player is in the right place.

I have :
gms_self_set_precision(x, 16) //movement corrected if object is more than 32 pixels off
gms_self_set_precision(y , 16); //as above but on the y axis
in the Create Code of the Player Object.

This function of gms_self_set_precision does it work as :
A) When I choose to send the x and y it will ensure that the player object's x and y are updated to be within 16 (pixels)
B) If X and Y are ever 16 pixels out of sync it automatically sends an update? Thanks in advance for clarity.
Size43 (Administrator) on 14 Dec 2020, 19:04:00
Also, note that gms_self_set does not actually send the value. It compares the value with the previous value, and marks it as changed if the values differ. When you call gms_step, all variables that have been marked as changed are sent in one go.

I'm mentioning this because it sounds like you have duplicated some of that logic in your code as well. Having just a single gms_self_set("hspeed", hspeed) in your step event would likely do the same thing as you have now, but saves you a lot of code.
DarkerClarke on 22 Dec 2020, 19:40:56
Thank you so much - I didn't want to request stuff or anything like I see across this board and I know you have dedicated so much time to responding and running this service so I didn't even pause to think you had included this logic into the system already!
Thank you - what you mentioned is exactly true - I was building a logic around only sending changed variables - knowing that gms_self_set does this means I can just add this to all my custom variables outside the standard set and it will sync up once I use the corresponding my_face = gms_other_get(player_id, "my_face"); to update in the "other" player object.

Thanks again! I'll also add the quotes to get the precision that I need. Thank you Size43
Size43 (Administrator) on 14 Dec 2020, 18:55:12
The short answer for why your code isn't working, is that you need quotes around the variable names:

gms_self_set_precision("x", 16) //movement corrected if object is more than 32 pixels off
gms_self_set_precision("y", 16); //as above but on the y axis


Otherwise, you're specifying the precision of a variable named like the value of string(x). You'll probably notice that even with these fixes, this still does nothing. That's because x, y, speed and direction are special cases with fixed precisions optimized for sending them as efficiently as possible.

In general, this function sets the maximum error that is permitted when sending a value. For example, if you set the precision to 0.1 and send a value of 5, the value will be received as a value between 4.9 and 5.1. The function has no effect on how often the values are sent.
DarkerClarke on 22 Dec 2020, 21:07:37
I am unable to create a new thread and I realised the one I responded to is over a month old - just a heads up

Hi the server connection appears to be down - I'm checking status.gamemakerserver.com as suggested to do last time.
Is there anyway to make a paypal donation or something to get a dedicated slot or maybe support such a thing?
Thanks :)

Showing Connection issues since 6:40pm GMT 22 December 2020

I am also available on Discord as DarkerClarke#1160

SORRY for posting here - it would not let me create a new topic "Database Error"
Size43 (Administrator) on 23 Dec 2020, 23:39:18
While I'm certainly open to consider dedicated "slots" or something similar, I do have to point out that the benefit to you would likely be minimal.

Due to technical limitations of the current codebase, everything has to run on a single server. More specifically, everything has to pass through a single process on a single server -- so there will always be a common point of failure shared with all other games.

The issues you're experiencing are presumably because of a bug that causes server crashes. I would not be able to tell you whether getting a separate node just for your game would isolate you from the crashes or not (although existing clients already connected to the server would most likely keep working if your game was on a separate node).

If you are still interested -- feel free to contact me via DM on Discord or by mailing gamemakerserver@outlook.com to see if we can work something out.
Size43 (Administrator) on 23 Dec 2020, 23:28:08
Hi again! I have pushed an update that fixes the Database error when creating a new topic.

I've also scheduled some downtime next Monday to update the server. This will include a patch for a potential bug I currently believe to be the source of the crashes. With a bit of luck, it will fix most of the issues you've been seeing.

In the mean time I've increased the node count with 2 additional nodes, to limit the impact from the crashes as much as possible.

I believe you're in the "official" GameMaker Server Discord server -- feel free to ping me there for important issues like server downtime. Whether you contact me via the site here or on Discord is up to your preference, both are fine for me. While I do monitor the account somewhat regularly to be able to respond to important issues, my replies for normal questions aren't much faster than here on the site since I usually reply to everything in one go once a week or so.
Size43 (Administrator) on 22 Dec 2020, 21:30:34
Hi, thanks for letting me know! I have restarted an instance, which seems to have resolved the issue for now. If you're still unable to connect -- please let me know. I'll follow up on this and your other posts soon, when I have some more free time.