#Dv^ Posted September 26, 2016 Share Posted September 26, 2016 Hola, tengo este script de la comunidad Mi pregunta es, ¿Cómo puedo hacer qué en el chat salga el tag del gang_system pero que no salga cuando no esté en ninguna gang? Lo intenté así, es decir sale el tag pero también sale el tag "None" cuando no está en ninguna gang, ¿Cómo puedo arreglar eso? settings = { ['enableTeamChat'] = true, ['adminTag'] = { ['enabled'] = true, ['ACL'] = { -- A bit more advanced. { 'Admin', '' }, { 'Moderator', ' ' }, { 'Everyone', '' }, } }, ['swearFilter'] = { ['enabled'] = true, ['swearCost'] = 0, ['swears'] = { -- Allows you to set the blocked swear words, syntax is ['WORD'] = 'REPLACEMENT' ['fghg'] = '*****', ['gffgh'] = '*****' } }, ['antiSpamFilter'] = { ['enabled'] = true, ['execeptionGroups'] = 'Admin', -- Groups which can spam, eg. 'Admin,SuperModerator,Moderator' ['chatTimeOut'] = 1.5 -- Set in seconds. }, ['freezeChat'] = { ['enabled'] = true, ['command'] = 'fchat', -- Command to use when activating frozen chat. ['allowedGroups'] = 'Admin', -- Groups which have access to this command. ['resetTime'] = 5 -- Time in minutes before it automatically resets. }, ['clearChat'] = { ['enabled'] = true, ['command'] = 'cchat', ['allowedGroups'] = 'Admin' } } -- Required variables spam = { } stopChat = false function chatbox(message, msgtype) if stopChat then cancelEvent() outputChatBox('', 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, 0) local check = 0 local spamCheck = false local tag = exports.gang_system:getPlayerGang(source) 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 600 <= #message then outputChatBox('#FF0000Error: El mensaje que escribiste es muy largo!', 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 .. ""..tag..":#FFFFFF " .. text if 600 <= #message then outputChatBox('#FF0000Error: El mensaje que escribiste es muy largo!', 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: Por favor espere '..settings['antiSpamFilter']['chatTimeOut']..' segundos para escribir otro mensaje!', 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('', getRootElement(), 255, 255, 255, true) stopChat = true frozenTimer = setTimer(function() stopChat = false end, (settings['freezeChat']['resetTime'] * 60000), 1) else outputChatBox('', 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('', getRootElement(), 255, 255, 255, true) end ) function RGBToHex(red, green, blue, alpha) return string.format("#%.2X%.2X%.2X", red,green,blue) end Link to comment
Sergioks Posted September 26, 2016 Share Posted September 26, 2016 settings = { ['enableTeamChat'] = true, ['adminTag'] = { ['enabled'] = true, ['ACL'] = { -- A bit more advanced. { 'Admin', '' }, { 'Moderator', ' ' }, { 'Everyone', '' }, } }, ['swearFilter'] = { ['enabled'] = true, ['swearCost'] = 0, ['swears'] = { -- Allows you to set the blocked swear words, syntax is ['WORD'] = 'REPLACEMENT' ['fghg'] = '*****', ['gffgh'] = '*****' } }, ['antiSpamFilter'] = { ['enabled'] = true, ['execeptionGroups'] = 'Admin', -- Groups which can spam, eg. 'Admin,SuperModerator,Moderator' ['chatTimeOut'] = 1.5 -- Set in seconds. }, ['freezeChat'] = { ['enabled'] = true, ['command'] = 'fchat', -- Command to use when activating frozen chat. ['allowedGroups'] = 'Admin', -- Groups which have access to this command. ['resetTime'] = 5 -- Time in minutes before it automatically resets. }, ['clearChat'] = { ['enabled'] = true, ['command'] = 'cchat', ['allowedGroups'] = 'Admin' } } -- Required variables spam = { } stopChat = false function chatbox(message, msgtype) if stopChat then cancelEvent() outputChatBox('', 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, 0) local check = 0 local spamCheck = false local tag = exports.gang_system:getPlayerGang(source) 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 600 <= #message then outputChatBox('#FF0000Error: El mensaje que escribiste es muy largo!', 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 --- if ( tag == "None" ) then gangTag = "" else gangTag = tag end --- local message = v[2] .. RGBToHex(r, g, b) .. name .. ""..gangTag..":#FFFFFF " .. text if 600 <= #message then outputChatBox('#FF0000Error: El mensaje que escribiste es muy largo!', 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: Por favor espere '..settings['antiSpamFilter']['chatTimeOut']..' segundos para escribir otro mensaje!', 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('', getRootElement(), 255, 255, 255, true) stopChat = true frozenTimer = setTimer(function() stopChat = false end, (settings['freezeChat']['resetTime'] * 60000), 1) else outputChatBox('', 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('', getRootElement(), 255, 255, 255, true) end ) function RGBToHex(red, green, blue, alpha) return string.format("#%.2X%.2X%.2X", red,green,blue) end Prueba esto a ver, no lo he testeado, pero algo así haría yo. Link to comment
Simple0x47 Posted September 26, 2016 Share Posted September 26, 2016 Pues añades esto a donde quieres que salga. ( exports.gangscript:isPlayerInGang == true ) and exports.gangscript:getGangName or "" -- Remplaza las funciones de los exports y el nombre del resource por los del que usas. Link to comment
#Dv^ Posted September 26, 2016 Author Share Posted September 26, 2016 (edited) Gracias, la ayuda de ambos me sirvió ¿Sería lo mismo si cambio esto local tag = exports.gang_system:getPlayerGang(source) por esto? local group = exports.gang_system:getPlayerGang(source) local tag = exports.gang_system:getGangData(group, "tag") local tagColor = exports.gang_system:getGangData(group, "color") Lo intenté pero solo me sale este error ERROR: Chat/server.lua: 90 : attempt to concatenate local "tagColor" (a table value) Edited September 26, 2016 by Slash14 Link to comment
#Dv^ Posted September 26, 2016 Author Share Posted September 26, 2016 (edited) Lo intenté así pero me sale estos números local message = v[2] .. RGBToHex(r, g, b) .. name .. ""..tagColor[1]..tagColor[2]..tagColor[3]..""..gangTag..":#FFFFFF " .. text "[Admin] Nick 22700 TAG : Hola" Edited September 26, 2016 by Slash14 Link to comment
MTA Team 0xCiBeR Posted September 26, 2016 MTA Team Share Posted September 26, 2016 No hagas bump y doble post. Te responderan cuando tengan un momento. Estas advertido @Slash14 Link to comment
aka Blue Posted September 26, 2016 Share Posted September 26, 2016 local tag = exports.gang_system:getPlayerGang(source) Creo que podrías poner esto, no sé si funcionaría sinceramente local tag = exports.gang_system:getPlayerGang(source) or "" Link to comment
#Dv^ Posted September 26, 2016 Author Share Posted September 26, 2016 Gracias y perdón @.:CiBeR:. Cuando obtiene el tag de la gang si es que estas en una sale el tag, pero si no estas en una gang me sale este error attempt to concatenate global 'gangTag' (a boolean value) Solo cambié agregué esto en el script local group = exports.gang_system:getPlayerGang(source) local tag = exports.gang_system:getGangData(group, "tag") Y el error me tira por esta parte Línea 88 y 90 if ( tag == "None" ) then gangTag = "" else gangTag = tag end local message = gangTag .. v[2] .. RGBToHex(r, g, b) .. name .. ":#FFFFFF " .. text Link to comment
aka Blue Posted September 26, 2016 Share Posted September 26, 2016 Prueba lo que te dije... local tag = exports.gang_system:getGangData(group, "tag") or "" Link to comment
#Dv^ Posted September 26, 2016 Author Share Posted September 26, 2016 ¿Y con el color? local group = exports.gang_system:getPlayerGang(source) local red, green, blue = unpack(exports.gang_system:getGangData(group, "color") ) or "" local message = RGBToHex(red, green, blue) .. gangTag outputChatBox(message, getRootElement(), 255, 255, 255, true) function RGBToHex(red, green, blue, alpha) return string.format("#%.2X%.2X%.2X", red,green,blue) end Link to comment
Enargy, Posted September 26, 2016 Share Posted September 26, 2016 3 hours ago, Slash14 said: ¿Y con el color? local group = exports.gang_system:getPlayerGang(source) local red, green, blue = unpack(exports.gang_system:getGangData(group, "color") ) or ""local message = RGBToHex(red, green, blue) .. gangTag outputChatBox(message, getRootElement(), 255, 255, 255, true)function RGBToHex(red, green, blue, alpha) return string.format("#%.2X%.2X%.2X", red,green,blue)end local red, green, blue = unpack(exports.gang_system:getGangData(group, "color") or {255, 255, 255}) Link to comment
Recommended Posts