#How to achieve Client side only changes
68 messages · Page 1 of 1 (latest)
you can send fake sync vars to the players that need to be affected
EXILED has a way to do this, you can check how it works here: https://github.com/Exiled-Team/EXILED/blob/master/Exiled.API/Extensions/MirrorExtensions.cs
-# may be slightly outdated
hmm that does look like something that would fit my case
thank you ^^
im just not sure how much longer exiled is supported qwq
it's still in active development, check out their discord server
things happened that is not for discussion here
alright ^^
np
DesiredPlayer.SendFakeSyncVar<Color>(primitiveObjectToy.netIdentity, typeof(PrimitiveObjectToy), nameof(PrimitiveObjectToy.NetworkMaterialColor), Color.red);
oh wait
for primitives the uh
the dirty bits have to be written twice because the AdminToyBase and its inheritor classes both write the dirty bits
Thank you ^^
Hm sadly i dont know anything about Dirty Bits or exactly how the ToyBase and stuff works
So basically the code above wouldn't change the color as it would get overwritten by itself again instantly?
you'd need to alter the CustomSyncVarGenerator method slightly to write the dirty bits twice if the type is an admin toy
basically just copy the first line and put it behind an if statement targetType.IsSubclassOf(typeof(AdminToyBase))
Thank you ^^
If i run into issues ill come back x3
Prefer use ExMod-Team instead of Exiled-Team
Repo was unavailable at the time of writing
Available on gitlab
Lemme find the repo
At least its up to date
I didn't think of using gitlab tbh
The following line:
Owner.SendFakeSyncVar<PrimitiveFlags>(TargetingSphere.netIdentity, typeof(PrimitiveObjectToy), nameof(PrimitiveObjectToy.PrimitiveFlags), PrimitiveFlags.Visible);
Does not get executed/causes a silent error somehow
I am trying to send the Visible flag to the Player stored in "Owner"
"TargetingSphere" is a PrimitiveObjectToy and was already checked to not be null
And i create it using ProjectMERs function
use NetworkPrimitiveType
nvm its the wrong one
NetworkPrimitiveFlags
instead of PrimitiveFlags
FakeSyncVar only can happen if the setter using SyncVarSetter
:o
Thank you!
So i should look out to only be using types with Network in their name?
Usually, Otherwise if not just see if the setter has a SyncVar
ye you see the GeneratedSyncVarSetter if it didnt has you cant fake that
Thank you ^^
Well it doesnt create an error anymore, but nothing seems to happen
Owner.SendFakeSyncVar<PrimitiveFlags>(
TargetingSphere.netIdentity,
typeof(PrimitiveObjectToy),
nameof(PrimitiveObjectToy.NetworkPrimitiveFlags),
PrimitiveFlags.Visible
);
New lines only for readability here. In my code its one line
are you sure you spawned? first would be check if actually exists there so it can be set hidden after ensuring spawned/exists
If i spawn it with the flag Visible, it shows up... But i will try and find out what changed between MER and ProjectMER and maybe my spawning is wrong...
It does exist
I can also move it using TargetingSphere.transform.position
-# Changing TargetingSphere.Position or .NetworkPosition didnt seem to work
I kept it visible but replaced the SendFakeSyncVar with the exact same one you sent in using the NetworkMaterialColor
Also doesnt do anything
Would anyone else have any idea what might be wrong?
I trying to check these stuff.
Run the log.bat and open the log you would see something like
OnDeserialize failed Exception=System.IO.EndOfStreamException (see below) object=PrimitiveObjectToy(Clone) component=AdminToys.PrimitiveObjectToy netId=593. Possible Reasons:
* Do AdminToys.PrimitiveObjectToy's OnSerialize and OnDeserialize calls write the same amount of data?
* Was there an exception in AdminToys.PrimitiveObjectToy's OnSerialize/OnDeserialize code?
* Are the server and client the exact same project?
* Maybe this OnDeserialize call was meant for another GameObject? The sceneIds can easily get out of sync if the Hierarchy was modified only in the client OR the server. Try rebuilding both.
hm i only have access to the server via Terabit, and not sure what/where log.bat is, sorry :/
inside your client
yup
ah, that, right
// the primitive
PrimitiveObjectToy primitiveObjectToy = PrimitiveObjectToy.Create(player.Position);
primitiveObjectToy.Type = PrimitiveType.Sphere;
player.SendFakeSyncVar(primitiveObjectToy.Base.netIdentity, primitiveObjectToy.Base, 32UL, PrimitiveType.Cube, (writer, value) =>
{
writer.WriteLong(32);
writer.WriteInt((int)value);
});
// the snycvar faker
public static void SendFakeSyncVar<T>(this Player target, NetworkIdentity networkIdentity, NetworkBehaviour networkBehaviour, ulong dirtyBit, T syncVar, Action<NetworkWriter, T>? writer_func)
{
if (target.Connection == null)
return;
NetworkWriterPooled writer = NetworkWriterPool.Get();
ulong value = 0;
for (int i = 0; i < networkIdentity.NetworkBehaviours.Length; i++)
{
if (networkIdentity.NetworkBehaviours[i] == networkBehaviour)
{
value = 1UL << (i & 31);
break;
}
}
// always writing 1?
Compression.CompressVarUInt(writer, value);
int position = writer.Position;
writer.WriteByte(0);
int position2 = writer.Position;
networkBehaviour.SerializeObjectsDelta(writer);
if (writer_func != null)
{
writer.WriteULong(dirtyBit);
writer_func(writer, syncVar);
}
int position3 = writer.Position;
writer.Position = position;
writer.WriteByte((byte)((position3 - position2) & 255));
writer.Position = position3;
// Copy owner to observer
if (networkBehaviour.syncMode != SyncMode.Observers)
CL.Warn("Well snyc mode is not observers, sucks to be you I guess.");
target.Connection.Send(new EntityStateMessage
{
netId = networkIdentity.netId,
payload = writer.ToArraySegment(),
});
}
i guess works
its a shpere but box for me
OnDeserialize failed Exception=System.IO.EndOfStreamException (see below) object=PrimitiveObjectToy(Clone) component=AdminToys.PrimitiveObjectToy netId=571. Possible Reasons:
* Do AdminToys.PrimitiveObjectToy's OnSerialize and OnDeserialize calls write the same amount of data?
* Was there an exception in AdminToys.PrimitiveObjectToy's OnSerialize/OnDeserialize code?
* Are the server and client the exact same project?
* Maybe this OnDeserialize call was meant for another GameObject? The sceneIds can easily get out of sync if the Hierarchy was modified only in the client OR the server. Try rebuilding both.
yes
ye seems like the issue was axwobo said
the current thing writing twice the dirtyBit
Right... this thing....
I sadly have no idea where this CustomSyncVarGenerator is but it sounds like it is part of LabAPI itself? Should i really be messing with it?
its inside Exiled
but you cant really do that
since exiled privated MakeCustomSyncWriter what i used
So im just at a dead end? :c
you can use this code
isnt really good
PrimitiveObjectToy primitiveObjectToy = PrimitiveObjectToy.Create(player.Position);
primitiveObjectToy.Type = PrimitiveType.Sphere;
player.SendFakeSyncVar(primitiveObjectToy.Base, 32L, PrimitiveType.Cube);
@elfin cove Copy the FaksyncExtension somehwere you can rename the namespace and include the namespace into the code above