So you know how in DarkRP you can just do
AddEntity("Holder", {
ent = "simple_drugs_drugholder",
model = "models/props_junk/PlasticCrate01a.mdl",
price = 100,
max = 5,
cmd = "buyholder",
category = "Cocaine Cooking",
})
And I want to do something like that, But for chat commands.
Everything below here is just me thinking of things. Some of it may be true, some may be not..
So I have my cl_init.lua and in the config, every time example.addcmd is called, in the cl_init file it would automatically generate another command. And depending how many you make, you can have unlimited. How would I go about that?
Would I do
example.addcmds = {
example.AddCmd = {
cmd = "!website",
content = "Goto google.com/help for help" -- example
}
}
or dont do the
example.addcmds {
}
google how to make chat command in gmod
I Already have.. Nothing much helped
https://pastebin.com/JW0BdERX
hook.Add( "OnPlayerChat" , "UNIQUEID" , function( ply , txt , team )
if string.sub( txt , 1 , 5 ) == "!test" then -- txt referencing the function, 1 means 1 word, 5 is the ammount of letters in the text.
-- Place your script here.
end
if txt == "!test" then
-- Place your script here.
end
-- Top one is way nicer imo, you can add a string.lower to allow people to enter their command with uppercase characters (It just converts the uppercase to lower) you can also return false to make the command not allow the command to show in chat.
You forgot and end and closing parenthesis.
Also OnPlayerChat is clientside. PlayerSay is serverside, which is what you want for most things.
Would that go in a client file or server file? Also can I do something with a config?
also how do I do a config for this because im stupid and im new to glua/lua
Yeah, at the time I was working on something so I quickly wrote that without checking, my bad.
Sorry, you need to Log In to post a reply to this thread.