Facepunch / garrysmod-requests

Feature requests for Garry's Mod
84 stars 24 forks source link

Implement a way to add custom data to CUserCMD (mainly) for prediction purposes #617

Open Jvs34 opened 8 years ago

Jvs34 commented 8 years ago

Garry does this with the kinect stuff, I know he does, and I want to be able to do the same.

Why would you want this??? Just use net messages you dumb dumb

In most situations yes I could, but in cases where people make clientside modules to interface with something on the input side, such as leap motion, any other kind of controllers and other stuff that people want to make clientside modules for.

At least in my situation I do want that data ready for prediction purposes, syncing net messages with predicted hooks has been hard in my tests.

How would I even implement this??

That's up to you, the best would be to use something like the KeyValues class, hell, even KeyValues are fine themselves, they even have something to save shit to binary, which you can use to even stream them over the network.

Hell when serializing stuff from a KeyValues class you can even give it the remaining space and make it fail to write to the cusercmd stream if shit is too big, the serializing functions allow that.

And the Lua side?

If we were to go via the keyvalues route, I guess we could have specific setters on CUserCmd, such as :SetKVFloat( "myvalue" , 0.5 ) , SetKVTable( "mygamepad" , {} ), SetKVString, SetKVInt, SetKVVector and ofc all the getters

Not gonna do this, I'm scared people will abuse it and overflow CUserCmds with crap

People abuse shit in gmod all the time, they can ddos your server already, and bad servers can cause your gmod to be fucked up until you restart by causing an error during a 3d render, we shouldn't have to babysit bad scripters or people abusing shit intentionally all the time (I'm not talking about exploits).

It's still is a bad idea, sounds annoying to do and it's not gonna be worth it just for your use case

OK, it was worth a shot.

Kefta commented 6 years ago

This would be extremely useful for sending custom predicted key data so that custom binds can do predicted actions. Currently, addons like the Lua Prone have to hijack unused impulse commands to reliably send inputs to the server.

LeQuackers commented 3 years ago

Bump.

Using a stringtable for this would probably work. You could register the identifier as the string and their type(s) as userdata. As for the data you could read/write it in ascending order to the end of the usercmd based on the identifier's index.