determinate determinate

Author Topic: ProfilePrefix 1.0 LUA 5.1x [Strict][API 2]  (Read 632 times)

0 Members and 1 Guest are viewing this topic.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
ProfilePrefix 1.0 LUA 5.1x [Strict][API 2]
« on: July 25, 2010, 10:05:00 pm »
Code: [Select]
--[[

ProfilePrefix 1.0 LUA 5.1x [Strict][API 2]

By Mutor 07/09/10

Set prefixes / tags for your profiles to be used in main chat.
- Use your own custom tags/prefixes or default names pulled from hub
- Option to have tag within user nick or as nick suffix
- Option for letter case none, lower, upper or title case
- Option to accept any punctuation for command prefix or hub prefixes only

Examples:
Tag within nick:
<[MASTER]Mutor> test...
Tag as suffix:
<Mutor> [MASTER] test...

]]

--Set your profiles / permissions here.
-- [#] = "PrefixString"/false, [false = disabled for profile]
local Profiles = {
[-1] = "[GUEST]", --Unregistered
[0] = "[MASTER]", --Master
[1] = "[OP]", --Operator
[2] = "[VIP]", --Vip
[3] = "[REG]", --Registered User
}

-- Accept any punctuation as command prefix? [false hub command prefix only]
local AnyPrefix = false

-- Use tag within nick [false = tag as nick suffix]
local TagInNick = false

-- Use default upper case profile names from PtokaX for all profiles?
-- [false = disable, use Profile table above / Set string for unregistered users] = enable
local Default = false --"[GUEST]"

-- Set tags letter case? [0 = no change, 1 = lower case, 2 = upper case, 3 = title case (first cap.)]
local LetterCase = 3

OnStartup = function()
if AnyPrefix then Prefixes = "%p" else Prefixes = SetMan.GetString(29) end
    if Default then
    Profiles = {}
        for i,v in ipairs(ProfMan.GetProfiles()) do
local p = v.sProfileName:gsub("%s",string.char(160))
Profiles[v.iProfileNumber] = "["..p.."]"
end
Profiles[-1] = Default:gsub("%s",string.char(160))
end
if LetterCase > 0 then
    t = {[1] = function(s) return s:lower() end,
[2] = function(s) return s:upper() end,
[3] = function(s) return s:sub(1,2) :upper()..s:sub(3,-1):lower() end,}
for i,v in pairs(Profiles) do Profiles[i] = t[LetterCase](v) end
end
end

ChatArrival = function(user,data)
local _,_,cmd = data:find("%b<> ["..Prefixes.."](%a+)")
if not cmd then
local p = Profiles[user.iProfile]
if p then
    local c,d = 0
    if TagInNick then d,c = data:gsub("^%<","<"..p) else d,c = data:gsub("^%b<>","%1 "..p) end
if c > 0 then return Core.SendToAll(d),true end
end
end
end
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline TZB

  • Double Ace
  • *
  • Posts: 149
  • Karma: +13/-0
  • ||-T-z-B-||
    • Gigabyte
Re: ProfilePrefix 1.0 LUA 5.1x [Strict][API 2]
« Reply #1 on: July 26, 2010, 05:26:49 am »
Nice Mutor. Great work.
gigahub.no-ip.biz:666

Offline Annie

  • Double Ace
  • *
  • Posts: 110
  • Karma: +13/-5
Re: ProfilePrefix 1.0 LUA 5.1x [Strict][API 2]
« Reply #2 on: July 27, 2010, 02:21:48 pm »
Excellent working great thanks Mutor   :D


Ohh I have noticed if somebody makes a typing mistake in main chat the word replacer picks up on it and it shows the nick as normal not with the prefix on.  Other than that working great :D
« Last Edit: July 27, 2010, 02:28:33 pm by Annie »

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: ProfilePrefix 1.0 LUA 5.1x [Strict][API 2]
« Reply #3 on: July 27, 2010, 11:26:46 pm »
If this script were loaded first, that wouldn't happen.
What would happen is the word replacer wouldn't work.
Load order matters, load first the scripts with priority.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline Annie

  • Double Ace
  • *
  • Posts: 110
  • Karma: +13/-5
Re: ProfilePrefix 1.0 LUA 5.1x [Strict][API 2]
« Reply #4 on: July 29, 2010, 10:16:04 am »
ok Thanks :)

 

determinate determinate