1. 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.

How do i do Donator ammo?

Discussion in 'DarkRP Modding Questions & Help' started by Szhweetie, Jan 3, 2018.

  1. Szhweetie

    Szhweetie New Member

    Hi, i have tried with some methods but always get this error message and all ammo disappears

    [ERROR] Lua is unable to understand file "darkrp_customthings/ammo.lua" because its author made a mistake around line number 109.
    The best help I can give you is this:

    There is an opening '{' bracket at line 104, but this bracket is never closed or not closed in time. It was expected to be closed before the 'customCheck' at line 109.

    Hints:
    - Did you forget a comma?
    - All open brackets ({, (, [) must have a matching closing bracket. Are you sure it's there?
    - Brackets must be opened and closed in the right order. This will work: ({}), but this won't: ({)}.

    ------- End of Simplerr error -------




    Have tried these ones:

    customCheck = function(ply) return table.HasValue({"admin", "premium"}, ply:GetNWString("usergroup")) end, CustomCheckFailMsg = "This ammo is only available for Premium members or higher!",

    and

    function(ply)
    return ply:IsAdmin() or ply:GetNWString("usergroup") == "donator"
    end)


    How do i do so it works properly? Thanks
     
  2. Sir Klutch

    Sir Klutch Active Member

    Code (Lua):
    function(ply) -- What is function? You need a name... function customCheck(ply) for example...
    return ply:IsAdmin() or ply:GetNWString("usergroup") == "donator" -- Unecessary networking. While this will still work as intended, it's just better practice to use ply:IsUserGroup()
    end)
    Code (Lua):
    function customCheck(ply)
    return ply:IsAdmin() or  ply:IsUserGroup("donator")
    end)
     
  3. (FPtje) Atheos

    (FPtje) Atheos Main Developer Staff Member

    What do you mean unnecessary networking?
    Code (Text):

    ply:IsUserGroup("aaa")
     
    is equal to

    Code (Text):
    ply:GetNWString("usergroup") == "aaa"
    Also, ply:GetNW* doesn't network on its own. It gets the value of a variable that is networked at other times. Specifically, when they're changed and when a player joins.
     
    Sir Klutch likes this.
  4. Sir Klutch

    Sir Klutch Active Member

    Oh, I guess I am wrong then. Nevertheless, it would still be bad practice, correct?
     
  5. (FPtje) Atheos

    (FPtje) Atheos Main Developer Staff Member

    Eh, more of a style thing than anything else.
     
    Sir Klutch likes this.

Share This Page