running cs lua through server side file

i’d like learn how to make a clientside lua file run on a players chat message
for example, writing !help would open a cs lua file. if anyone has any examples themselves or know sites that could make
this function more clear, it would be appreciated.

You could just use

OnPlayerChat and check if the text is !help, then just run whatever code you want…you probably shouldn’t be trying to run a CSLua file from a client because that could be exploited pretty easily…unless you want that to happen, then you could use something like

RunString after doing

File:Read on the CSLua file

What are you trying to do? There’s probably a less dangerous alternative

hook.Add( 'OnPlayerChat', 'UNIQUE_NAME', function( ply, txt, team, dead )
    if txt == '!help' then
        --put the code here or do whatever you want to read the lua file
    return false -- this stops the chat message from being surpressed
end )

let me try to explain more,

i have a client side script that ive made, and i want it to open on the player once they’ve typed !help

sorry for any confusion, trying your example now.

Well, can’t you just put the script inside the ‘if’ statement?

hook.Add( 'OnPlayerChat', 'UNIQUE_NAME', function( ply, txt, team, dead )
    if txt == '!help' then

        --Insert the code you want to run

    return false
end )

It’d be a lot easier to put the contents of the file your script is in inside the ‘if’ statement than trying to actually RUN the whole file

i did the following example and put my derma code into the if statement, put it into E:\garry\garrysmod\addons\Hmenu\lua\server, and it still doesn’t seem to be working

That’s because OnPlayerChat is a clientside hook. I thought you said your script was clientside?

If you want it to work serverside, you should use PlayerSay instead:

hook.Add( 'PlayerSay', 'UNIQUE_NAME', function( ply, text, team )
    if text == '!help' then

        --Your code here

end )

Also, try putting the file in this file path instead:

C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\garrysmod\addons\Hmenu\lua\autorun\server

Perhaps then it’ll work. I’ve never heard of GMod running any Lua files from the E: drive…

I think you’re over-complicating it - the net library would do fine

Why use the net library when there are two versions of the PlayerSay function- one clientside and one serverside?

Yeah if it’s not using any data generated from server-side code, keep it all client-side.