Custom chat commands [Help]

Hi so I am still a lua noob so I come her for help :3.

I tried to make my own command e.g. a /advert command but instead of [Advert] it would say [Trade].

So I navigated through the gamemode folder and found sv_chatcommands.lua and sh_chatcommands.lua, Opened them both copied the advert codes but changed the words a bit e.g.

This is in the sh_chatcommands.lua



DarkRP.declareChatCommand{
    command = "trade",
    description = "Trade Chat",
    delay = 1.5
}


then I did the same for sv_chatcommands.lua



local function PlayerTrade(ply, args)
    if args == "" then
        DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
        return ""
    end
    local DoSay = function(text)
        if text == "" then
            DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
            return
        end
        for k,v in pairs(player.GetAll()) do
            local col = team.GetColor(ply:Team())
            DarkRP.talkToPerson(v, col, DarkRP.getPhrase("trade") .. " " .. ply:Nick(), Color(255, 255, 0, 255), text, ply)
        end
    end
    return args, DoSay
end
DarkRP.defineChatCommand("trade", PlayerTrade, 1.5)


I have no idea what I am doing wrong since I just copied and pasted [Unless there is something else I need to edit]. Help would be greatly apreciated :slight_smile:

EDIT: Wait it works but instead of having [Trade] “Playername”: “message” It says “SteamName”: /trade “message” Can anyone think of how to remove the /trade once they do it? I don’t get it I just copied the advert :confused:

[editline]12th February 2016[/editline]

Bump?

DarkRP.getPhrase(“trade”)

You don’t have the getPhrase , so replace with (v, Color(255, 0, 0), “[Trade]”,

Could you explain it more if you can? what do you mean I don’t have getPhrase [Sorry I don’t know much lua yet :confused: ]

[editline]13th February 2016[/editline]

EDIT: I did what you asked and I get the same outcome :confused:

Code:



local function PlayerTrade(ply, args)
    if args == "" then
        DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
        return ""
    end
    local DoSay = function(text)
        if text == "" then
            DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
            return
        end
        for k,v in pairs(player.GetAll()) do
            local col = team.GetColor(ply:Team())
            DarkRP.talkToPerson(v, Color(255, 0, 0), "[Trade]", .. " " .. ply:Nick(), Color(255, 255, 0, 255), text, ply)
        end
    end
    return args, DoSay
end
DarkRP.defineChatCommand("trade", PlayerTrade, 1.5)


Delete … " " … and test