Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Userdata
Userdata
2004-07-04, 11:06 AM #1
I was wondering if anyone knows why userdata doesn't sync in multiplayer, and maybe a way to force it to sync. It's the only thing stopping me from releasing a beta of my ship cog. Right now it works fine in single player, but since it doesn't sync userdata I can't get certain things to work in multiplayer.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-04, 11:32 AM #2
The coders/makers of JK didn't need that verb to be synced, so they didn't. To go around it, create a c/s setup for it.

------------------
Major projects working on:
SATNRT
JK Pistol Mod
Aliens TC
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2004-07-04, 11:43 AM #3
Well, at least I'm on the right track. I've made the client/server cog already, but just need to add the 'join' message in order to sync the values when someone joins.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-05, 2:46 PM #4
Here's another idea... Try thingflags and use something Unknown/Unused.

Just a suggestion...

/Edward
Edward's Cognative Hazards
2004-07-05, 10:12 PM #5
Ya, I didn't bother to think about that.

I may actually do that if I can't get the userdata to sync. Now just to hope that the flags I use really WERE unused [http://forums.massassi.net/html/wink.gif]

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-06, 1:22 AM #6
i realised i allready had a cog for this i hadent tested.. i dunno if you can use it at all..
Code:
#	JK Cog Script
#
#	PJ_USER_SERVER.cog
#
#	this is the server side cog for syncing user data
#
#	[PJB]
flags=0x200
symbols
message	startup
message	pulse
message	trigger

int	channel
flex	rate=0.5
thing	object
int	intval=0
end
code
startup:
setpulse(rate);
setthinguserdata(object,intval);
return;

pulse:
sendtrigger(-3,channel,getthinguserdata(object),object,0,0);
return;

trigger:
if(getsourceref()==channel)
{
setthinguserdata(getparam(1),getparam(0));
}
return;
end

Code:
#	JK Cog Script
#
#	PJ_USER_CLIENT.cog
#
#	this is the clien side cog for syncing user data
#
#	[PJB]
flags=0x240
symbols
message	trigger
int	channel
end

code
trigger:
if(getsourceref()==channel)
{
setthinguserdata(getparam(1),getparam(0));
}
return;
end


in mine insted of useing a "setthinguserdata(ojject, blah);" you'd send the trigger "sendtrigger(-3,channel,blah,object,0,0);"


... dunno if you can use it, just had it around

------------------
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2004-07-07, 4:57 PM #7
Something really weird is going on with this cog. First, it started thinking that my player was dead, preventing the ship from activating. I fixed that after I realized that I had too many variables in my symbols section and removed some. Now I used some debug print statements to find out why it isn't syncing the userdata. Apparently it's not the client side, but rather that the host is not sending the data.

Code:
newplayer:

JkStringClear();
JkStringConcatAsciiString("syncing: ");
JkStringConcatFlex(GetThingUserData(otherplace));
JkStringOutput(-3, -1);

if(IsMulti()==1 && IsServer()==1)	// check if (host and multi)
 if(GetSenderRef()!=GetPlayerThing(0))
 {
   SendTrigger(GetSenderRef(), 999, otherplace, shuttlespot, GetThingUserData(otherplace), GetThingUserData(shuttlespot));


This statement prints out "syncing: 0.000000" as you can see, the userdata is being read as 0. But in every other instance, it is read as 7710 (like it should be). When the other player joins, the host stays at 7710, but the joiner is synced with 0.000000

Don't worry about my variable names, they make sense with how they are used.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-07, 6:29 PM #8
"newplayer" is the message that gets called when you respawn and only occurs locally. You need to either use the "join" message (gets called when a person joins a MP game) or have the client's "newplayer" send a trigger to the host that makes the host send the client a trigger that sync's the userdata. If you use "newplayer" it will get called every time the person respawns.

Quib Mask
2004-07-07, 8:36 PM #9
Actually, newplayer is sent to all cogs on all computers when a player respawns. I really don't mind it syncing when a player respawns since if an error comes up between computers, it would be resynced. The problem is that it isn't getting the right number from the host.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-07, 8:53 PM #10
Just to be safe, I'll try what you said about sending a trigger to the host. At the very least, it work hurt, and it could fix the fact that I'm getting the wrong data.

I'll post back here about what I find.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-07, 8:55 PM #11
If newplayer is called on all comps when a player respawns, then how come it doesn't screw up forcepowers/weapons that use newplayer? If someone else respawning sent a newplayer message out, it'd deactivate some effects. You can't say it's because those cogs are local, because someone dying (sending the killed message to all cogs) does occur, even in weapons and forcepowers and that's why they have the player == GetSenderRef() check in the killed section of every cog.

Regardless, if you don't mind resyncing on every respawn, have a client cog send a trigger to the host asking for the sync, and then have the host send them a trigger with the data. If you use specific targets for the triggers, you'd save a tiny bit of unneeded network traffic. Alternately, when the client asks for a resync, you could have the host broadcast the trigger to all clients, just as a fail-safe.

Quib Mask
2004-07-07, 9:09 PM #12
Well, you're right. You have permission to beat me as hard as you want. I did my test with the trigger to the host, and the data did sync. Thank you, you may have just saved my project.

On another note, if someone can tell SM to update the datamaster with this bit of info about newplayer... It currently says
Code:
Newplayer is sent to all cogs when a player respawns. 
That's why I was confused, even on something that should have been obvious.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-07-08, 7:47 AM #13
That thing on newplayer in DM is correct, but its in the sense of only the local player's cogs and I believe all global cogs.

------------------
Major projects working on:
SATNRT
JK Pistol Mod
Aliens TC
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack

↑ Up to the top!