• Custom chat commands [Help]
    3 replies, posted
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 [code] DarkRP.declareChatCommand{ command = "trade", description = "Trade Chat", delay = 1.5 } [/code] then I did the same for sv_chatcommands.lua [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, 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) [/code] 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 :) 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 :/ [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 :/ ] [editline]13th February 2016[/editline] EDIT: I did what you asked and I get the same outcome :/ Code: [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) [/code]
[QUOTE=Sir. Pumpin';49730141]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 :/ ] [editline]13th February 2016[/editline] EDIT: I did what you asked and I get the same outcome :/ Code: [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) [/code][/QUOTE] Delete .. " " .. and test
Sorry, you need to Log In to post a reply to this thread.