amama12345
Wiek: 25 Na forum: 4422 dni Posty: 50
Nick w MP: AmaMa
Piwa : 3
Witam jak po??czy? admintag z systemem id?
admintag:
Cytat: -- DISCLAIMER
--[[
Any user of this resource is allowed to modify the code for personal use, and are not allowed to share their own version with people. Do not attempt to resell this resource as it is avaiblable for FREE. Anyone caught breaking the disclamer will find themselves in trouble with the law under the Copyright Act 2008. You may use / edit only for PERSONAL USE. This code is copyrighted to Christopher Graham Smith (Urangan, Queensland, AUS).
]]
-- Settings - These settings will change the scripts functions and allow you to disable certain parts.
settings = {
['enableTeamChat'] = true,
['adminTag'] = {
['enabled'] = true,
['ACL'] = { -- A bit more advanced.
{ 'Admin', '#00B7FF[Administator] ' },
{ 'JuniorAdmin', '#33ff66[JuniorAdmin] ' },
{ 'SuperModerator', '#F200FF[SuperModerator] ' },
{ 'Moderator', '#A1FF9C[Moderator] ' },
{ 'VIP', '#ffff33[V.I.P] ' },
{ 'Everyone', '[Gracz] ' }
}
},
['swearFilter'] = {
['enabled'] = true,
['swearCost'] = 0,
['swears'] = { -- Allows you to set the blocked swear words, syntax is ['WORD'] = 'REPLACEMENT'
['asshole'] = '*******',
['fuck'] = '****',
['slut'] = '****',
['bitch'] = '*****',
['cunt'] = '****',
['whore'] = '*****',
['k****'] = '*****',
['fag'] = '***',
['perro'] = '*****',
['puta'] = '****',
['joder'] = '*****'
}
},
['antiSpamFilter'] = {
['enabled'] = true,
['execeptionGroups'] = 'Admin,SuperModerator', -- Groups which can spam, eg. 'Admin,SuperModerator,Moderator'
['chatTimeOut'] = 0.75 -- Set in seconds.
},
['freezeChat'] = {
['enabled'] = true,
['command'] = 'freezechat', -- Command to use when activating frozen chat.
['allowedGroups'] = 'Admin,SuperModerator', -- Groups which have access to this command.
['resetTime'] = 5 -- Time in minutes before it automatically resets.
},
['clearChat'] = {
['enabled'] = true,
['command'] = 'clearchat',
['allowedGroups'] = 'Admin,SuperModerator'
}
}
-- Required variables
spam = { }
stopChat = false
function chatbox(message, msgtype)
if stopChat then cancelEvent() outputChatBox('#FF0000[FREEZECHAT] #FFFFFFAn admin has recently frozen chat.', source, 255, 255, 255, true) return end
local account = getAccountName(getPlayerAccount(source))
local name = getPlayerName(source)
local serial = getPlayerSerial(source)
local r, g, b = getPlayerNametagColor(source)
local text = message:gsub("%a", string.upper, 1)
local check = 0
local spamCheck = false
if settings['swearFilter']['enabled'] then
for i, v in pairs(settings['swearFilter']['swears']) do
while text:lower():find(i:lower(),1,true) do
local start, end_ = text:lower():find(i:lower(),1,true)
local found = text:sub(start,end_)
text = text:gsub(found,v)
if settings['swearFilter']['swearCost'] ~= 0 then
takePlayerMoney(source, settings['swearFilter']['swearCost'])
end
end
end
end
if msgtype == 0 then
cancelEvent()
if not settings['adminTag']['enabled'] and not spam[serial] then
message = RGBToHex(r, g, b) .. name .. ':#FFFFFF ' .. text
if 128 <= #message then
outputChatBox('#FF0000Error: The message you entered is too big, please lower it!', source, 255, 255, 255, true)
else
outputChatBox(message, getRootElement(), 255, 255, 255, true)
aclgroup = split(settings['antiSpamFilter']['execeptionGroups'], ', ') or settings['antiSpamFilter']['execeptionGroups']
for i, v in ipairs(aclgroup) do if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup(v)) then spamCheck = true end end
if not spamCheck then
if settings['antiSpamFilter']['enabled'] then
spam[serial] = true
setTimer(function()
spam[serial] = false
end, settings['antiSpamFilter']['chatTimeOut']*1000, 1)
end
end
outputServerLog('CHAT: ' .. name .. ': ' .. text)
end
return
end
for _,v in ipairs(settings['adminTag']['ACL']) do
if isObjectInACLGroup('user.' .. account, aclGetGroup(v[1])) and check == 0 and not spam[serial] then
local message = v[2] .. RGBToHex(r, g, b) .. name .. ":#FFFFFF " .. text
if 128 <= #message then
outputChatBox('#FF0000Error: The message you entered is too big, please lower it!', source, 255, 255, 255, true)
check = 1
else
check = 1
outputChatBox(message, getRootElement(), 255, 255, 255, true)
if settings['antiSpamFilter']['enabled'] then
aclgroup = split(settings['antiSpamFilter']['execeptionGroups'], ', ') or settings['antiSpamFilter']['execeptionGroups']
for i, v in ipairs(aclgroup) do if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup(v)) then spamCheck = true end end
if not spamCheck then
spam[serial] = true
check = 1
setTimer(function()
spam[serial] = false
end, settings['antiSpamFilter']['chatTimeOut']*1000, 1)
end
end
outputServerLog('CHAT: '.. v[2] .. name .. ': ' .. text)
end
elseif spam[serial] and check == 0 then
outputChatBox('#FF0000Error: Please wait '..settings['antiSpamFilter']['chatTimeOut']..' seconds before saying a message!', source, 255, 255, 255, true)
check = 1
end
end
elseif msgtype == 1 and not settings['enableTeamChat'] then
cancelEvent()
end
end
addEventHandler("onPlayerChat", getRootElement(), chatbox)
addEventHandler("onPlayerQuit", getRootElement(),
function()
local serial = getPlayerName(source)
spam[serial] = false
end )
-- Freeze chat
addCommandHandler(settings['freezeChat']['command'],
function(player)
if not settings['freezeChat']['enabled'] then return end
aclgroup = split(settings['freezeChat']['allowedGroups'], ', ') or settings['freezeChat']['allowedGroups']
for i, v in ipairs(aclgroup) do if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup(v)) then check = true end end
if not check then return end
if not stopChat then
outputChatBox('#FF0000[FREEZECHAT] #FFFFFF'..getPlayerName(player)..' has frozen the chat!', getRootElement(), 255, 255, 255, true)
stopChat = true
frozenTimer = setTimer(function() stopChat = false end, (settings['freezeChat']['resetTime'] * 60000), 1)
else
outputChatBox('#FF0000[FREEZECHAT] #FFFFFF'..getPlayerName(player)..' has unfrozen the chat!', getRootElement(), 255, 255, 255, true)
stopChat = false
end
end
)
-- Clear chat
addCommandHandler(settings['clearChat']['command'],
function(player)
if not settings['clearChat']['enabled'] then return end
aclgroup = split(settings['clearChat']['allowedGroups'], ',') or settings['clearChat']['allowedGroups']
for i, v in ipairs(aclgroup) do if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup(v)) then check = true end end
if not check then return end
for i = 2, getElementData(player, 'chatLines') do
outputChatBox(' ')
end
outputChatBox('#FF0000[CLEARCHAT]#FFFFFF '..getPlayerName(player)..' has cleared the chat', getRootElement(), 255, 255, 255, true)
end
)
function RGBToHex(red, green, blue, alpha)
return string.format("#%.2X%.2X%.2X", red,green,blue)
end
ID:
Cytat: function findPlayer(plr,cel)
local target=nil
if (tonumber(cel) ~= nil) then
target=getElementByID("p"..cel)
else -- podano fragment nicku
for _,thePlayer in ipairs(getElementsByType("player")) do
if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), cel:lower(), 1, true) then
if (target) then
outputChatBox("Znaleziono wiecej niz jednego gracza o pasujacym nicku, podaj wiecej liter.", plr)
return nil
end
target=thePlayer
end
end
end
return target
end
local function findFreeValue(tablica_id)
table.sort(tablica_id)
local wolne_id=0
for i,v in ipairs(tablica_id) do
if (v==wolne_id) then wolne_id=wolne_id+1 end
if (v>wolne_id) then return wolne_id end
end
return wolne_id
end
function assignPlayerID(plr)
local gracze=getElementsByType("player")
local tablica_id = {}
for i,v in ipairs(gracze) do
local lid=getElementData(v, "id")
if (lid) then
table.insert(tablica_id, tonumber(lid))
end
end
local free_id=findFreeValue(tablica_id)
setElementData(plr,"id", free_id)
setElementID(plr, "p" .. free_id)
return free_id
end
function getPlayerID(plr)
if not plr then return "" end
local id=getElementData(plr,"id")
if (id) then
return id
else
return assignPlayerID(plr)
end
end
addEventHandler ("onPlayerJoin", getRootElement(), function()
assignPlayerID(source)
end)