Skip to content

Commit

Permalink
Update fr_server.lua
Browse files Browse the repository at this point in the history
I noticed a bug in the freeroam game mode,  

        <setting name=“*chat/blockRepeatMessages” value=“true” />

but I was still able to spam the chat, I looked at the line of code and saw that something was wrong and fixed it
  • Loading branch information
shadylua authored Nov 21, 2024
1 parent 1ff08f9 commit 39ac762
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions [gameplay]/freeroam/fr_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -448,24 +448,21 @@ addEventHandler('onPlayerChat', root,
function(msg, type)
if type == 0 then
cancelEvent()
if not hasObjectPermissionTo(source, "command.kick") and not hasObjectPermissionTo(source, "command.mute") then
if chatTime[source] and chatTime[source] + tonumber(get("*chat/mainChatDelay")) > getTickCount() then
outputChatBox("Stop spamming main chat!", source, 255, 0, 0)
return
else
chatTime[source] = getTickCount()
end
if get("*chat/blockRepeatMessages") == "true" and lastChatMessage[source] and lastChatMessage[source] == msg then

local blockRepeats = get("*chat/blockRepeatMessages") == "true"

if blockRepeats then
if lastChatMessage[source] and lastChatMessage[source] == msg then
outputChatBox("Stop repeating yourself!", source, 255, 0, 0)
return
else
lastChatMessage[source] = msg
end
lastChatMessage[source] = msg
end

if isElement(source) then
local r, g, b = getPlayerNametagColor(source)
outputChatBox(getPlayerName(source) .. ': #FFFFFF' .. stripHex(msg), root, r, g, b, true)
outputServerLog( "CHAT: " .. getPlayerName(source) .. ": " .. msg )
outputServerLog("CHAT: " .. getPlayerName(source) .. ": " .. msg)
end
end
end
Expand Down Expand Up @@ -657,4 +654,4 @@ function handleSuicide()
end
end
addEvent('onFreeroamSuicide', true)
addEventHandler('onFreeroamSuicide', root, handleSuicide)
addEventHandler('onFreeroamSuicide', root, handleSuicide)

0 comments on commit 39ac762

Please sign in to comment.