1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

Custom commands

Discussion in 'DarkRP Modding Questions & Help' started by Киса ^_^, Jan 30, 2019.

  1. Киса ^_^

    Киса ^_^ New Member

    Hi everyone!

    I need some help with creating custom comand on my server.
    So.. this command should work ONLY with player name.. For example "/invite [name]"

    Now this code looking like this..
    Code (Text):
    local function MZ_Inv(ply, team)
        if (string.sub(text, 1, 10) == "/invite_mz") then
            if team
            if ply:Team() == "TEAM_DR" or ply:Team() == "TEAM_DR1" or ply:Team() == "TEAM_MoH"
                    print("Hello. You have been invited to the Ministry of Health care" -- idk :D

    hook.Add("PlayerSay", "MZ_Inv", MZ_Inv)
    I need that player MUST insert nick of the player before "/invite" -> "/invite [name]"
    Last edited: Jan 30, 2019
  2. # VALERY

    # VALERY Member

    This example should help you

    Code (Text):

    local function PM(ply, args)
        local namepos = string.find(args, " ")
        if not namepos then
            DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
            return ""

        local name = string.sub(args, 1, namepos - 1)
        local msg = string.sub(args, namepos + 1)

        if msg == "" then
            DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
            return ""

        local target = DarkRP.findPlayer(name)

        if target then
            local col = team.GetColor(ply:Team())
            local pname = ply:Nick()
            local col2 = Color(255, 255, 255, 255)
            DarkRP.talkToPerson(target, col, "(PM) " .. pname, col2, msg, ply)
            DarkRP.talkToPerson(ply, col, "(PM) " .. pname, col2, msg, ply)
            DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("could_not_find", tostring(name)))

        return ""
    DarkRP.defineChatCommand("pm", PM, 1.5)
  3. # VALERY

    # VALERY Member

    What? No, this is pm (personal message) function from DarkRP core. You can create your own command by looking how it was done there.
  4. Киса ^_^

    Киса ^_^ New Member

    I know. I just try to rewrite this

Share This Page