#GitHub - AwertaDreams/gm-dialog: Garry's...

1 messages · Page 1 of 1 (latest)

glacial portal
#

Oh boy, okay, a few things:

  1. You don't mention that gm_express is required
  2. 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.
  1. 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.
  2. 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.
ancient marsh
glacial portal
#

Must have skimmed past it, I see

ancient marsh
# glacial portal 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

glacial portal
#

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!

ancient marsh
#

Since i expect that in future when ill be doing my gamemode those dialog files will get bigger

glacial portal
#

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
ancient marsh
# glacial portal Oh boy, okay, a few things: 1. You don't mention that gm_express is required 2....

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.

glacial portal
ancient marsh
#

The script name, the player, and the entity if specified.

glacial portal