#GitHub - AwertaDreams/gm-dialog: Garry's...
1 messages · Page 1 of 1 (latest)
Oh boy, okay, a few things:
- You don't mention that gm_express is required
- Please don't use express like this: https://github.com/AwertaDreams/gm-dialog/blob/main/gamemode/lib/sh_dialog_load.lua#L25
- You need to combine all of the file data into a single message and send only one express message. Never use express in a for loop.
- This here creates an opportunity for reflection attack - why is this an express message anyway? Players could spam this message and cause you to constantly send data back to them.
- This is just a straight up exploit. I could cause infinite explosions on every entity in your server. You need to protect this, or make it not a net message at all.
- I mention in requirements that gm-express is required.
Thanks for the feedback, ill try to clean this up.
Must have skimmed past it, I see
Generally, this was a rather fast-coding that doesn't really follow any Lua guidelines and is probably probe to exploits. Since I don't have enough time after highschool haha. Thank you yet again for pointing these to me.
And the 4th point was rather a showcase of how registering the function work
But nonetheless ill clean that up also
How big are these dialog files expected to get? Express is only faster if you're sending 192kb+
The dialogs in your example are ~4kb - those could fit in a single message, uncompressed!
I was planning to add a switch boolean to use net calls instead of gm_Express too
Since i expect that in future when ill be doing my gamemode those dialog files will get bigger
even 64kb of compressed json is a lot, mind you.
another way to save a lot of bytes is to:
local contents = file.Read( "dialogue/file1.json", "GAME" )
local tbl = util.JSONToTable( contents )
local smaller = util.TableToJSON( tbl )
this lets you store the contents with spaces so they're easy to edit, but then you only network the unformatted json
content = file.Read( "dialogue1.json" )
#content
2418
#util.TableToJSON( util.JSONToTable( content ) )
1563
About 3th point. This express message exists because of
function dispatch(script, ply, ent)
if CLIENT then
log("Dispatching script via clientside " .. script .. " for player " .. tostring(ply))
express.Send( "dialog_dispatch_server", {script, ent})
else
log("Dispatching script via serverside " .. script .. " for player " .. tostring(ply) .. " Hes about to talk to ")
express.Send("dialog_dispatch_client", {script, ent}, ply)
end
end
I fixed the express in the for loop, thanks for pointing it out.
But what is the client actually sending to the server?
The script name, the player, and the entity if specified.
That can just be a net message right?