Jump to content

Chat (Ayuda)


#Dv^

Recommended Posts

Posted

Hola!

Disculpen, ¿Dónde se puede editar para que el player cuando ingrese al server no pueda chatear hasta que se loguee?

Es más para evitar esos spammers que entran spamean y se van

Se los agradecería, Gracias.

Posted
addEventHandler ( "onPlayerJoin", root, function() showChat ( source, false ) end ) 
  
addEventHandler("onPlayerLogin", root,  function()  showChat ( source, true ) end) 

Posted
addEventHandler ( "onPlayerJoin", root, function() showChat ( source, false ) end ) 
  
addEventHandler("onPlayerLogin", root,  function()  showChat ( source, true ) end) 

>>>F8 > say OLA

Como ya lo han dicho antes, con el evento onPlayerChat y isGuestAccount

Posted

Esta sería la función, no?

Lo hice así

addEventHandler('onPlayerChat', g_Root, 
    function(msg, type) 
                if isGuestAccount ( sourceAccount ) then 
        if type == 0 then 
            cancelEvent() 
            if chatTime[source] and chatTime[source] + tonumber(get("*chat/mainChatDelay")) > getTickCount() then 
                return 
            else 
                chatTime[source] = getTickCount() 
            end 
            if get("*chat/blockRepeatMessages") == "true" and lastChatMessage[source] and lastChatMessage[source] == msg then 
                return 
            else 
                lastChatMessage[source] = msg 
            end 
            local r, g, b = getPlayerNametagColor(source) 
             
            outputServerLog( "CHAT: " .. getPlayerName(source) .. ": " .. msg ) 
        end 
    end 
) 

Posted
Esta sería la función, no?

Lo hice así

addEventHandler('onPlayerChat', g_Root, 
    function(msg, type) 
                if isGuestAccount ( sourceAccount ) then 
        if type == 0 then 
            cancelEvent() 
            if chatTime[source] and chatTime[source] + tonumber(get("*chat/mainChatDelay")) > getTickCount() then 
                return 
            else 
                chatTime[source] = getTickCount() 
            end 
            if get("*chat/blockRepeatMessages") == "true" and lastChatMessage[source] and lastChatMessage[source] == msg then 
                return 
            else 
                lastChatMessage[source] = msg 
            end 
            local r, g, b = getPlayerNametagColor(source) 
             
            outputServerLog( "CHAT: " .. getPlayerName(source) .. ": " .. msg ) 
        end 
    end 
) 

  
if isGuestAccount ( getPlayerAccount(source) ) then return false end 
  

Posted

Lo he hecho pero aún así los players cuando ingresan pueden chatear aunque no estén logueados

PD: Gracias por tu ayuda

Posted
Lo he hecho pero aún así los players cuando ingresan pueden chatear aunque no estén logueados

PD: Gracias por tu ayuda

Lo agregaste en la primera línea?

Intenta cambiar la sentencia "return false end" por "return end".

Posted

Sí lo puse así

addEventHandler('onPlayerChat', g_Root, 
    function(msg, type) 
    if isGuestAccount ( getPlayerAccount(source) ) then return false end 
        if type == 0 then 
            cancelEvent() 
            if chatTime[source] and chatTime[source] + tonumber(get("*chat/mainChatDelay")) > getTickCount() then 
                return 
            else 
                chatTime[source] = getTickCount() 
            end 
            if get("*chat/blockRepeatMessages") == "true" and lastChatMessage[source] and lastChatMessage[source] == msg then 
                return 
            else 
                lastChatMessage[source] = msg 
            end 
            local r, g, b = getPlayerNametagColor(source) 
             
            outputServerLog( "CHAT: " .. getPlayerName(source) .. ": " .. msg ) 
        end 
    end 
) 
  

Pero lo cambiaré así entonces

addEventHandler('onPlayerChat', g_Root, 
    function(msg, type) 
    if isGuestAccount ( getPlayerAccount(source) ) then return  end 
        if type == 0 then 
            cancelEvent() 
            if chatTime[source] and chatTime[source] + tonumber(get("*chat/mainChatDelay")) > getTickCount() then 
                return 
            else 
                chatTime[source] = getTickCount() 
            end 
            if get("*chat/blockRepeatMessages") == "true" and lastChatMessage[source] and lastChatMessage[source] == msg then 
                return 
            else 
                lastChatMessage[source] = msg 
            end 
            local r, g, b = getPlayerNametagColor(source) 
             
            outputServerLog( "CHAT: " .. getPlayerName(source) .. ": " .. msg ) 
        end 
    end 
) 
  

Posted

En ese caso improvisa un sistema, el cual le asigne un elementData tipo 'chatPermitido' cuando se logeen y compruebalo en el onPlayerChat.

Te dejo un ejemplo:

-- Cuando no está logueado 
local chat_no = getElementData ( source, "chatPermitido" ) == 0 
if chat_no then cancelEvent ( ) end 

Posted
En ese caso improvisa un sistema, el cual le asigne un elementData tipo 'chatPermitido' cuando se logeen y compruebalo en el onPlayerChat.

Te dejo un ejemplo:

-- Cuando no está logueado 
local chat_no = getElementData ( source, "chatPermitido" ) == 0 
if chat_no then cancelEvent ( ) end 

Es mucho mejor usar una variable para eso, setElementData para que sincronice con todo los clientes consume una cantidad de CPU.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...