gms_instance_sync_var_add

Usage: gms_instance_sync_var_add ( "variable", value [, precision] )

Description

Adds a variable to the list of variabeles that are sent on the next call to an server_instance_sync function. Only needed in GM:Studio.

Replies (4)

Last message on 20 May 2017

perilousproductions on 20 May 2017, 17:21:54
/// DUMMY OBJECT CREATE EVENT
//----Session variables for player (Immitation)
gms_instance_sync_var_add("healthMax", 100);
gms_instance_sync_var_add("health", 100);
gms_instance_sync_var_add("kills", 0);
gms_instance_sync(id, is_onetime | isc_local);

/// BULLET END STEP EVENT
// Hit player
var p = collision_line(x, y,
x + lengthdir_x(speed, direction),
y + lengthdir_y(speed, direction),
//obj_player, 1, 1);
obj_dummy, 1, 1);

if p != noone{
show_debug_message(p); // DEBUG
//var pid = gms_instance_get(p, "player_id");
var hp = gms_instance_get(p, "health");
show_debug_message(hp); // DEBUG
if hp > 0{
if hp - damage > 0{
gms_instance_set(p, "health", hp - damage);
}else{
gms_instance_set(p, "health", 0);
var kls = gms_other_get(from, "kills");
gms_instance_set(from, "kills", kls + 1);
}
instance_destroy();
}
}
perilousproductions on 20 May 2017, 17:23:40
/// BULLET CREATE SCRIPT
var xx, yy, dir, b;
xx = argument0;
yy = argument1;
dir = argument2
b = instance_create(xx, yy, obj_bullet);
b.sprite_index = argument3;
b.image_angle = dir;
b.direction = dir;
b.speed = argument4;
b.damage = argument5;
b.from = argument6;
gms_instance_sync_var_add("damage", b.damage);
gms_instance_sync_var_add("from", b.damage);
gms_instance_sync(b, is_onetime | isc_local);

hp keeps returning 0 in the show_debug_message and I'm not sure why? :S
perilousproductions on 20 May 2017, 18:38:40
Never mind I missed the part about user event 12 for Game Maker Studio!
You really have thought of everything haven't you :P
Thanks you so much this is the best thing ever!!!!
Forgeio on 11 Mar 2017, 22:35:50
Hey Size, I'm having trouble with this, it's not syncing bullets being created and I can't figure out why. Can you look over this and see what's wrong with it? The problem would probably be in either the slimeball object or the slime object.https://drive.google.com/file/d/0B7e-hfTOC5R0MXdVUUFPeVFscEE/view?usp=sharing