The PtokaX Portal
News: READ THE RULES
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 05, 2010, 11:15:25 AM


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: ProfilePrefix 1.0 LUA 5.1x [Strict][API 2]  (Read 206 times)
0 Members and 1 Guest are viewing this topic.
Mutor
Global Moderator
Forum God
*****

Karma: +372/-18
Offline Offline

Posts: 3 627


To err is human, to arr is pirate...


View Profile WWW
« on: July 25, 2010, 10:05:00 PM »

Code:
--[[

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
Logged

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
TZB
Double Ace
*

Karma: +12/-0
Offline Offline

Posts: 141


||-T-z-B-||


View Profile WWW
« Reply #1 on: July 26, 2010, 05:26:49 AM »

Nice Mutor. Great work.
Logged

gigahub.no-ip.biz:666
Annie
Double Ace
*

Karma: +13/-5
Offline Offline

Posts: 110



View Profile
« Reply #2 on: July 27, 2010, 02:21:48 PM »

Excellent working great thanks Mutor   Cheesy


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 Cheesy
« Last Edit: July 27, 2010, 02:28:33 PM by Annie » Logged

Mutor
Global Moderator
Forum God
*****

Karma: +372/-18
Offline Offline

Posts: 3 627


To err is human, to arr is pirate...


View Profile WWW
« 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.
Logged

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
Annie
Double Ace
*

Karma: +13/-5
Offline Offline

Posts: 110



View Profile
« Reply #4 on: July 29, 2010, 10:16:04 AM »

ok Thanks Smiley
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc


Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 7.898 seconds with 31 queries.