R1S1NG Posted September 4, 2018 Share Posted September 4, 2018 Olá novamente, e desculpa ser chato kkk mas tenho um script que coloca id no chat e algumas coisas a mais, mas o MTA me exibe o seguinte erro: SCRIPT ERROR: localização do script X\server.lua:342: 'end' expected (to close 'function' at line 222) near 'else' ERROR: localização do script X\server.lua:313: attempt to concatenate a boolean value --[[ ########################################################################## ## ## ## ## ## Criador: Volklack ## ## ## ## ## ########################################################################## [C] Copyright 2012-2016, Apollo ]] local idname = get ( "idDataCaption" ) or "id" g_Players = {} function table.find(t, ...) if type(t) ~= 'table' then return false end local args = { ... } if #args == 0 then for k,v in pairs(t) do if v then return k, v end end return false end local value = table.remove(args) if value == '[nil]' then value = nil end for k,v in pairs(t) do for i,index in ipairs(args) do if type(index) == 'function' then v = index(v) else if index == '[last]' then index = #v end v = v[index] end end if v == value then return k, t[k] end end return false end function addElem(list, elem) local id local globList local newtable = { elem = elem } if not id then id = 1 while list[id] do id = id + 1 end end list[id] = newtable setElemID(elem, id) return id, newtable end function removeElem(list, elem) local id = table.find(list, 'elem', elem) if id then list[id] = nil setElemID(elem, nil) return id end end function getPlayerFromID(id) return g_Players[id] and isElement(g_Players[id].elem) and g_Players[id].elem end function getPlayerID(player) return getElemID(player) end function getElemID(elem) return elem and isElement(elem) and getElementData(elem, idname) end function setElemID(elem, id) if elem and isElement(elem) then setElementData(elem, idname, id) end end function onResourceStart () call ( getResourceFromName ( "scoreboard" ), "addScoreboardColumn", idname, root, 1, 0.05 ) for k, v in ipairs(getElementsByType("player")) do addElem(g_Players, v) end end addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) function onPlayerJoin() addElem(g_Players, source) setElementData (source, "mpb", true) end addEventHandler ( "onPlayerJoin", root, onPlayerJoin ) function onPlayerQuit (reason) local playerID = getElemID(source) g_Players[playerID] = nil end addEventHandler('onPlayerQuit', root, onPlayerQuit) function pmCommand(player, command, id, ...) if(id) then local playerID = tonumber(id) if(playerID) then local sdx = getPlayerFromID(playerID) if getElementData(sdx, "AnonAdmin") == true then if playerID > 2 then playerID = playerID -1 else playerID = playerID + 1 end end local target = getPlayerFromID(playerID) if(target) then local args = { ... } local msg = "" for k,v in pairs(args) do msg = msg .. ' ' .. v end for a, b in ipairs(getElementsByType("player")) do local bcc = getAccountName(getPlayerAccount(b)) if isObjectInACLGroup("user."..bcc, aclGetGroup("Console")) then outputChatBox("#FF0000Chat: #FFFFFF "..getPlayerName(player).."#FFFFFF("..(getPlayerID(player) or "???")..")#FF8000 é um #FF0000viadão#FF8000.", b, 255, 255, 255, true) end end outputChatBox("bad character", player, 255, 0, 0, true) return 1 end if(msg ~= "") then local mpb = getElementData (target, "mpb" ) if mpb == false then outputChatBox ( "#FF8000Mensagen privada:#ffffff Não foi enviada, pois o destinatário está com as mensagens privadas bloqueadas.",player, 255, 165, 0, true) else outputChatBox ( "#FF8000Mensagen privada:#FFFFFF #00FF00enviada para #FF8000" .. getPlayerName(target) .. " #FF8000(" .. id .. "): #FFFFFF"..msg.."", player, 255, 165, 0, true) if getElementData(player, "AnonAdmin") == true then outputChatBox ( "#FF8000Mensagen anônima: #FFFFFF"..msg.."", target, 255, 165, 0, true) else local mpb = getElementData (target, "mpb" ) if mpb == false then else outputChatBox ( "#FF8000Mensagen privada:#FFFFFF #FF0000recebida de #FF8000"..getPlayerName(player).." #FF8000(" .. (getPlayerID(player) or "???") .. "):#FFFFFF "..msg.."", target, 255, 165, 0, true) end end if getElementData(player, "AnonAdmin") == true then outputChatBox("#FFFFFFVocê recebeu uma mensagen anônima.", target, 255, 165, 0, true) else local mpb = getElementData (target, "mpb" ) if mpb == false then else outputChatBox("#FFFFFFVocê recebeu uma #FF8000Mensagen privada#FFFFFF!, para responder use #FF8000/pm ".. (getPlayerID(player) or "???").." (menssagem)", target, 255, 165, 0, true) end end for a, b in ipairs(getElementsByType("player")) do local bcc = getAccountName(getPlayerAccount(b)) if target ~= b and player ~= b and isObjectInACLGroup("user."..bcc, aclGetGroup("Console")) then outputChatBox("#FF8000Stalkeador: #FFFFFF"..getPlayerName(player).."#FFFFFF("..(getPlayerID(player) or "???")..")#FF0000 para#FFFFFF ".. getPlayerName(target).."#FFFFFF("..id.."): #FF0000 "..msg.."", b, 255, 255, 255, true) end end end else outputChatBox ( "[ERRO] menssagen em branco.", player, 200, 0, 0) end else outputChatBox ( "[ERRO] Jogador(a) (" .. id .. ") não foi encontrado.", player, 200, 0, 0) end else outputChatBox ( "[ERRO] ID (" .. id .. ") invalida.", player, 200, 0, 0) end else outputChatBox ( "#FF0000Chat:#FFFFFF Use /pm (id) (msg) para mandar mensagens privadas.", player, 255, 255, 255, true) outputChatBox ( "Não abuse das mensagens privadas.", player, 255, 255, 255, true) end end addCommandHandler("pm", pmCommand) function cleanchat(player) local accountname = getAccountName(getPlayerAccount(player)) if ( hasObjectPermissionTo ( player, "command.mute", true ) ) then outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox( "".. getPlayerName(player) .. " #fffffflimpou o chat.", root, 0, 255, 255, true) end end addCommandHandler("lc", cleanchat) Link to comment
Jonas^ Posted September 5, 2018 Share Posted September 5, 2018 16 hours ago, R1S1NG said: Olá novamente, e desculpa ser chato kkk mas tenho um script que coloca id no chat e algumas coisas a mais, mas o MTA me exibe o seguinte erro: SCRIPT ERROR: localização do script X\server.lua:342: 'end' expected (to close 'function' at line 222) near 'else' ERROR: localização do script X\server.lua:313: attempt to concatenate a boolean value --[[ ########################################################################## ## ## ## ## ## Criador: Volklack ## ## ## ## ## ########################################################################## [C] Copyright 2012-2016, Apollo ]] local idname = get ( "idDataCaption" ) or "id" g_Players = {} function table.find(t, ...) if type(t) ~= 'table' then return false end local args = { ... } if #args == 0 then for k,v in pairs(t) do if v then return k, v end end return false end local value = table.remove(args) if value == '[nil]' then value = nil end for k,v in pairs(t) do for i,index in ipairs(args) do if type(index) == 'function' then v = index(v) else if index == '[last]' then index = #v end v = v[index] end end if v == value then return k, t[k] end end return false end function addElem(list, elem) local id local globList local newtable = { elem = elem } if not id then id = 1 while list[id] do id = id + 1 end end list[id] = newtable setElemID(elem, id) return id, newtable end function removeElem(list, elem) local id = table.find(list, 'elem', elem) if id then list[id] = nil setElemID(elem, nil) return id end end function getPlayerFromID(id) return g_Players[id] and isElement(g_Players[id].elem) and g_Players[id].elem end function getPlayerID(player) return getElemID(player) end function getElemID(elem) return elem and isElement(elem) and getElementData(elem, idname) end function setElemID(elem, id) if elem and isElement(elem) then setElementData(elem, idname, id) end end function onResourceStart () call ( getResourceFromName ( "scoreboard" ), "addScoreboardColumn", idname, root, 1, 0.05 ) for k, v in ipairs(getElementsByType("player")) do addElem(g_Players, v) end end addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) function onPlayerJoin() addElem(g_Players, source) setElementData (source, "mpb", true) end addEventHandler ( "onPlayerJoin", root, onPlayerJoin ) function onPlayerQuit (reason) local playerID = getElemID(source) g_Players[playerID] = nil end addEventHandler('onPlayerQuit', root, onPlayerQuit) function pmCommand(player, command, id, ...) if(id) then local playerID = tonumber(id) if(playerID) then local sdx = getPlayerFromID(playerID) if getElementData(sdx, "AnonAdmin") == true then if playerID > 2 then playerID = playerID -1 else playerID = playerID + 1 end end local target = getPlayerFromID(playerID) if(target) then local args = { ... } local msg = "" for k,v in pairs(args) do msg = msg .. ' ' .. v end for a, b in ipairs(getElementsByType("player")) do local bcc = getAccountName(getPlayerAccount(b)) if isObjectInACLGroup("user."..bcc, aclGetGroup("Console")) then outputChatBox("#FF0000Chat: #FFFFFF "..getPlayerName(player).."#FFFFFF("..(getPlayerID(player) or "???")..")#FF8000 é um #FF0000viadão#FF8000.", b, 255, 255, 255, true) end end outputChatBox("bad character", player, 255, 0, 0, true) return 1 end if(msg ~= "") then local mpb = getElementData (target, "mpb" ) if mpb == false then outputChatBox ( "#FF8000Mensagen privada:#ffffff Não foi enviada, pois o destinatário está com as mensagens privadas bloqueadas.",player, 255, 165, 0, true) else outputChatBox ( "#FF8000Mensagen privada:#FFFFFF #00FF00enviada para #FF8000" .. getPlayerName(target) .. " #FF8000(" .. id .. "): #FFFFFF"..msg.."", player, 255, 165, 0, true) if getElementData(player, "AnonAdmin") == true then outputChatBox ( "#FF8000Mensagen anônima: #FFFFFF"..msg.."", target, 255, 165, 0, true) else local mpb = getElementData (target, "mpb" ) if mpb == false then else outputChatBox ( "#FF8000Mensagen privada:#FFFFFF #FF0000recebida de #FF8000"..getPlayerName(player).." #FF8000(" .. (getPlayerID(player) or "???") .. "):#FFFFFF "..msg.."", target, 255, 165, 0, true) end end if getElementData(player, "AnonAdmin") == true then outputChatBox("#FFFFFFVocê recebeu uma mensagen anônima.", target, 255, 165, 0, true) else local mpb = getElementData (target, "mpb" ) if mpb == false then else outputChatBox("#FFFFFFVocê recebeu uma #FF8000Mensagen privada#FFFFFF!, para responder use #FF8000/pm ".. (getPlayerID(player) or "???").." (menssagem)", target, 255, 165, 0, true) end end for a, b in ipairs(getElementsByType("player")) do local bcc = getAccountName(getPlayerAccount(b)) if target ~= b and player ~= b and isObjectInACLGroup("user."..bcc, aclGetGroup("Console")) then outputChatBox("#FF8000Stalkeador: #FFFFFF"..getPlayerName(player).."#FFFFFF("..(getPlayerID(player) or "???")..")#FF0000 para#FFFFFF ".. getPlayerName(target).."#FFFFFF("..id.."): #FF0000 "..msg.."", b, 255, 255, 255, true) end end end else outputChatBox ( "[ERRO] menssagen em branco.", player, 200, 0, 0) end else outputChatBox ( "[ERRO] Jogador(a) (" .. id .. ") não foi encontrado.", player, 200, 0, 0) end else outputChatBox ( "[ERRO] ID (" .. id .. ") invalida.", player, 200, 0, 0) end else outputChatBox ( "#FF0000Chat:#FFFFFF Use /pm (id) (msg) para mandar mensagens privadas.", player, 255, 255, 255, true) outputChatBox ( "Não abuse das mensagens privadas.", player, 255, 255, 255, true) end end addCommandHandler("pm", pmCommand) function cleanchat(player) local accountname = getAccountName(getPlayerAccount(player)) if ( hasObjectPermissionTo ( player, "command.mute", true ) ) then outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox( "".. getPlayerName(player) .. " #fffffflimpou o chat.", root, 0, 255, 255, true) end end addCommandHandler("lc", cleanchat) Cara, andei olhando seu código e seu código esta sem formatação alguma. Você copiou errado eu acho e deu um TAB no código, esta todo errado, tem final de função no lugar errado, logicamente vai dar erro. Link to comment
Other Languages Moderators Lord Henry Posted September 5, 2018 Other Languages Moderators Share Posted September 5, 2018 Não se usa else seguido por um if dentro do escopo do else. Ou você fecha o escopo do else e abre o if, ou vc usa elseif. E também não precisa ficar entupindo o código de linha vazia. Vc só deixa linhas em branco entre uma função e outra. Link to comment
Other Languages Moderators Lord Henry Posted September 5, 2018 Other Languages Moderators Share Posted September 5, 2018 Código com a indentação corrigida e com comentários nos erros: Spoiler --[[ ########################################################################## ## ## ## ## ## Criador: Volklack ## ## ## ## ## ########################################################################## [C] Copyright 2012-2016, Apollo ]] local idname = get ( "idDataCaption" ) or "id" g_Players = {} function table.find(t, ...) if type(t) ~= 'table' then return false end local args = { ... } if #args == 0 then for k,v in pairs(t) do if v then return k, v end end return false end local value = table.remove(args) if value == '[nil]' then value = nil end for k,v in pairs(t) do for i,index in ipairs(args) do if type(index) == 'function' then v = index(v) else -- Não é recomendável fazer isso. Prefira usar ELSEIF if index == '[last]' then index = #v end v = v[index] end end if v == value then return k, t[k] end end return false end function addElem(list, elem) local id local globList local newtable = { elem = elem } if not id then id = 1 while list[id] do id = id + 1 end end list[id] = newtable setElemID(elem, id) return id, newtable end function removeElem(list, elem) local id = table.find(list, 'elem', elem) if id then list[id] = nil setElemID(elem, nil) return id end end function getPlayerFromID(id) return g_Players[id] and isElement(g_Players[id].elem) and g_Players[id].elem end function getPlayerID(player) return getElemID(player) end function getElemID(elem) return elem and isElement(elem) and getElementData(elem, idname) end function setElemID(elem, id) if elem and isElement(elem) then setElementData(elem, idname, id) end end function onResourceStart () call ( getResourceFromName ( "scoreboard" ), "addScoreboardColumn", idname, root, 1, 0.05 ) for k, v in ipairs(getElementsByType("player")) do addElem(g_Players, v) end end addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) function onPlayerJoin() addElem(g_Players, source) setElementData (source, "mpb", true) end addEventHandler ( "onPlayerJoin", root, onPlayerJoin ) function onPlayerQuit (reason) local playerID = getElemID(source) g_Players[playerID] = nil end addEventHandler('onPlayerQuit', root, onPlayerQuit) function pmCommand(player, command, id, ...) if(id) then local playerID = tonumber(id) if(playerID) then local sdx = getPlayerFromID(playerID) if getElementData(sdx, "AnonAdmin") == true then if playerID > 2 then playerID = playerID -1 else playerID = playerID + 1 end end local target = getPlayerFromID(playerID) if(target) then local args = { ... } local msg = "" for k,v in pairs(args) do msg = msg .. ' ' .. v end for a, b in ipairs(getElementsByType("player")) do local bcc = getAccountName(getPlayerAccount(b)) if isObjectInACLGroup("user."..bcc, aclGetGroup("Console")) then outputChatBox("#FF0000Chat: #FFFFFF "..getPlayerName(player).."#FFFFFF("..(getPlayerID(player) or "???")..")#FF8000 é um #FF0000viadão#FF8000.", b, 255, 255, 255, true) end end outputChatBox("bad character", player, 255, 0, 0, true) return 1 end if(msg ~= "") then local mpb = getElementData (target, "mpb" ) if mpb == false then outputChatBox ( "#FF8000Mensagen privada:#ffffff Não foi enviada, pois o destinatário está com as mensagens privadas bloqueadas.",player, 255, 165, 0, true) else outputChatBox ( "#FF8000Mensagen privada:#FFFFFF #00FF00enviada para #FF8000" .. getPlayerName(target) .. " #FF8000(" .. id .. "): #FFFFFF"..msg.."", player, 255, 165, 0, true) if getElementData(player, "AnonAdmin") == true then outputChatBox ( "#FF8000Mensagen anônima: #FFFFFF"..msg.."", target, 255, 165, 0, true) else local mpb = getElementData (target, "mpb" ) if mpb == false then -- ERRO, condição vazia. else outputChatBox ( "#FF8000Mensagen privada:#FFFFFF #FF0000recebida de #FF8000"..getPlayerName(player).." #FF8000(" .. (getPlayerID(player) or "???") .. "):#FFFFFF "..msg.."", target, 255, 165, 0, true) end end if getElementData(player, "AnonAdmin") == true then outputChatBox("#FFFFFFVocê recebeu uma mensagen anônima.", target, 255, 165, 0, true) else local mpb = getElementData (target, "mpb" ) if mpb == false then -- ERRO, condição vazia. else outputChatBox("#FFFFFFVocê recebeu uma #FF8000Mensagen privada#FFFFFF!, para responder use #FF8000/pm ".. (getPlayerID(player) or "???").." (menssagem)", target, 255, 165, 0, true) end end for a, b in ipairs(getElementsByType("player")) do local bcc = getAccountName(getPlayerAccount(b)) if target ~= b and player ~= b and isObjectInACLGroup("user."..bcc, aclGetGroup("Console")) then outputChatBox("#FF8000Stalkeador: #FFFFFF"..getPlayerName(player).."#FFFFFF("..(getPlayerID(player) or "???")..")#FF0000 para#FFFFFF ".. getPlayerName(target).."#FFFFFF("..id.."): #FF0000 "..msg.."", b, 255, 255, 255, true) end end end else outputChatBox ( "[ERRO] menssagen em branco.", player, 200, 0, 0) end else outputChatBox ( "[ERRO] Jogador(a) (" .. id .. ") não foi encontrado.", player, 200, 0, 0) end else outputChatBox ( "[ERRO] ID (" .. id .. ") invalida.", player, 200, 0, 0) end else -- ERRO, ELSE sem ter um IF em aberto. outputChatBox ( "#FF0000Chat:#FFFFFF Use /pm (id) (msg) para mandar mensagens privadas.", player, 255, 255, 255, true) outputChatBox ( "Não abuse das mensagens privadas.", player, 255, 255, 255, true) end end -- ERRO, END sem escopo. addCommandHandler("pm", pmCommand) function cleanchat(player) local accountname = getAccountName(getPlayerAccount(player)) if ( hasObjectPermissionTo ( player, "command.mute", true ) ) then outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox( "".. getPlayerName(player) .. " #fffffflimpou o chat.", root, 0, 255, 255, true) end end addCommandHandler("lc", cleanchat) Obs: Eu não corrigi o código, mas deixei ele legível e com comentários onde há erros. Link to comment
Gw8 Posted September 5, 2018 Share Posted September 5, 2018 Da pra fazer tudo isso que você fez usando menos de 180 linhas, muito menos. Tente. Link to comment
R1S1NG Posted September 5, 2018 Author Share Posted September 5, 2018 15 minutes ago, Gw8 said: Da pra fazer tudo isso que você fez usando menos de 180 linhas, muito menos. Tente. 1 hour ago, Lord Henry said: Código com a indentação corrigida e com comentários nos erros: Hide contents --[[ ########################################################################## ## ## ## ## ## Criador: Volklack ## ## ## ## ## ########################################################################## [C] Copyright 2012-2016, Apollo]]local idname = get ( "idDataCaption" ) or "id"g_Players = {}function table.find(t, ...) if type(t) ~= 'table' then return false end local args = { ... } if #args == 0 then for k,v in pairs(t) do if v then return k, v end end return false end local value = table.remove(args) if value == '[nil]' then value = nil end for k,v in pairs(t) do for i,index in ipairs(args) do if type(index) == 'function' then v = index(v) else -- Não é recomendável fazer isso. Prefira usar ELSEIF if index == '[last]' then index = #v end v = v[index] end end if v == value then return k, t[k] end end return falseendfunction addElem(list, elem) local id local globList local newtable = { elem = elem } if not id then id = 1 while list[id] do id = id + 1 end end list[id] = newtable setElemID(elem, id) return id, newtableendfunction removeElem(list, elem) local id = table.find(list, 'elem', elem) if id then list[id] = nil setElemID(elem, nil) return id endendfunction getPlayerFromID(id) return g_Players[id] and isElement(g_Players[id].elem) and g_Players[id].elemendfunction getPlayerID(player) return getElemID(player)endfunction getElemID(elem) return elem and isElement(elem) and getElementData(elem, idname)endfunction setElemID(elem, id) if elem and isElement(elem) then setElementData(elem, idname, id) endendfunction onResourceStart () call ( getResourceFromName ( "scoreboard" ), "addScoreboardColumn", idname, root, 1, 0.05 ) for k, v in ipairs(getElementsByType("player")) do addElem(g_Players, v) endendaddEventHandler ( "onResourceStart", resourceRoot, onResourceStart )function onPlayerJoin() addElem(g_Players, source) setElementData (source, "mpb", true)end addEventHandler ( "onPlayerJoin", root, onPlayerJoin )function onPlayerQuit (reason) local playerID = getElemID(source) g_Players[playerID] = nilendaddEventHandler('onPlayerQuit', root, onPlayerQuit) function pmCommand(player, command, id, ...) if(id) then local playerID = tonumber(id) if(playerID) then local sdx = getPlayerFromID(playerID) if getElementData(sdx, "AnonAdmin") == true then if playerID > 2 then playerID = playerID -1 else playerID = playerID + 1 end end local target = getPlayerFromID(playerID) if(target) then local args = { ... } local msg = "" for k,v in pairs(args) do msg = msg .. ' ' .. v end for a, b in ipairs(getElementsByType("player")) do local bcc = getAccountName(getPlayerAccount(b)) if isObjectInACLGroup("user."..bcc, aclGetGroup("Console")) then outputChatBox("#FF0000Chat: #FFFFFF "..getPlayerName(player).."#FFFFFF("..(getPlayerID(player) or "???")..")#FF8000 é um #FF0000viadão#FF8000.", b, 255, 255, 255, true) end end outputChatBox("bad character", player, 255, 0, 0, true) return 1 end if(msg ~= "") then local mpb = getElementData (target, "mpb" ) if mpb == false then outputChatBox ( "#FF8000Mensagen privada:#ffffff Não foi enviada, pois o destinatário está com as mensagens privadas bloqueadas.",player, 255, 165, 0, true) else outputChatBox ( "#FF8000Mensagen privada:#FFFFFF #00FF00enviada para #FF8000" .. getPlayerName(target) .. " #FF8000(" .. id .. "): #FFFFFF"..msg.."", player, 255, 165, 0, true) if getElementData(player, "AnonAdmin") == true then outputChatBox ( "#FF8000Mensagen anônima: #FFFFFF"..msg.."", target, 255, 165, 0, true) else local mpb = getElementData (target, "mpb" ) if mpb == false then -- ERRO, condição vazia. else outputChatBox ( "#FF8000Mensagen privada:#FFFFFF #FF0000recebida de #FF8000"..getPlayerName(player).." #FF8000(" .. (getPlayerID(player) or "???") .. "):#FFFFFF "..msg.."", target, 255, 165, 0, true) end end if getElementData(player, "AnonAdmin") == true then outputChatBox("#FFFFFFVocê recebeu uma mensagen anônima.", target, 255, 165, 0, true) else local mpb = getElementData (target, "mpb" ) if mpb == false then -- ERRO, condição vazia. else outputChatBox("#FFFFFFVocê recebeu uma #FF8000Mensagen privada#FFFFFF!, para responder use #FF8000/pm ".. (getPlayerID(player) or "???").." (menssagem)", target, 255, 165, 0, true) end end for a, b in ipairs(getElementsByType("player")) do local bcc = getAccountName(getPlayerAccount(b)) if target ~= b and player ~= b and isObjectInACLGroup("user."..bcc, aclGetGroup("Console")) then outputChatBox("#FF8000Stalkeador: #FFFFFF"..getPlayerName(player).."#FFFFFF("..(getPlayerID(player) or "???")..")#FF0000 para#FFFFFF ".. getPlayerName(target).."#FFFFFF("..id.."): #FF0000 "..msg.."", b, 255, 255, 255, true) end end end else outputChatBox ( "[ERRO] menssagen em branco.", player, 200, 0, 0) end else outputChatBox ( "[ERRO] Jogador(a) (" .. id .. ") não foi encontrado.", player, 200, 0, 0) end else outputChatBox ( "[ERRO] ID (" .. id .. ") invalida.", player, 200, 0, 0) endelse -- ERRO, ELSE sem ter um IF em aberto. outputChatBox ( "#FF0000Chat:#FFFFFF Use /pm (id) (msg) para mandar mensagens privadas.", player, 255, 255, 255, true) outputChatBox ( "Não abuse das mensagens privadas.", player, 255, 255, 255, true)endend -- ERRO, END sem escopo.addCommandHandler("pm", pmCommand) function cleanchat(player) local accountname = getAccountName(getPlayerAccount(player)) if ( hasObjectPermissionTo ( player, "command.mute", true ) ) then outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox(" ") outputChatBox( "".. getPlayerName(player) .. " #fffffflimpou o chat.", root, 0, 255, 255, true) endendaddCommandHandler("lc", cleanchat) Obs: Eu não corrigi o código, mas deixei ele legível e com comentários onde há erros. 1 hour ago, OverKILL said: Cara, andei olhando seu código e seu código esta sem formatação alguma. Você copiou errado eu acho e deu um TAB no código, esta todo errado, tem final de função no lugar errado, logicamente vai dar erro. Obrigado a todos, reparei nos erros estou aprendendo a programar em TI programação C, algo bem similar. Obrigado de coração! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now