Merge pull request 'Add global cooldown for the bed quick chat feature' (#3645) from bedantispam into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3645mobsarmorfix
commit
becf98875f
|
@ -438,12 +438,14 @@ local playermessagecounter = {}
|
||||||
It gets reset after 10 secs using a globalstep
|
It gets reset after 10 secs using a globalstep
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
local chatbuttonused = false
|
||||||
local globalstep_timer = 0
|
local globalstep_timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
globalstep_timer = globalstep_timer + dtime
|
globalstep_timer = globalstep_timer + dtime
|
||||||
if globalstep_timer >= 10 then
|
if globalstep_timer >= 10 then
|
||||||
globalstep_timer = 0
|
globalstep_timer = 0
|
||||||
playermessagecounter = {}
|
playermessagecounter = {}
|
||||||
|
chatbuttonused = false
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -472,16 +474,22 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local custom_sleep_message
|
||||||
if fields.chatsubmit and fields.chatmessage ~= "" then
|
if fields.chatsubmit and fields.chatmessage ~= "" then
|
||||||
if (not exceeded_rate_limit(player:get_player_name())) and shout_priv_check(player) then
|
custom_sleep_message = fields.chatmessage
|
||||||
minetest.chat_send_all(minetest.format_chat_message(player:get_player_name(), fields.chatmessage))
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.defaultmessage then
|
if custom_sleep_message or fields.defaultmessage then
|
||||||
|
if chatbuttonused then
|
||||||
|
local time_to_wait = math.ceil(10-globalstep_timer)
|
||||||
|
minetest.chat_send_player(player:get_player_name(),S("Sorry, but you have to wait @1 seconds until you may use this button again!", tostring(time_to_wait)))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if (not exceeded_rate_limit(player:get_player_name())) and shout_priv_check(player) then
|
if (not exceeded_rate_limit(player:get_player_name())) and shout_priv_check(player) then
|
||||||
minetest.chat_send_all(minetest.format_chat_message(player:get_player_name(), S("Hey! Would you guys mind sleeping?")))
|
chatbuttonused = true
|
||||||
|
local message = custom_sleep_message or S("Hey! Would you guys mind sleeping?")
|
||||||
|
minetest.chat_send_all(minetest.format_chat_message(player:get_player_name(), message))
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,4 +45,5 @@ Chat:=Chat:
|
||||||
send!=senden!
|
send!=senden!
|
||||||
You are missing the 'shout' privilege! It's required in order to talk in chat...=Ihnen fehlt das 'shout' Privileg! Es wird benötigt, um im Chat reden zu können...
|
You are missing the 'shout' privilege! It's required in order to talk in chat...=Ihnen fehlt das 'shout' Privileg! Es wird benötigt, um im Chat reden zu können...
|
||||||
You exceeded the maximum number of messages per 10 seconds!=Sie haben die maximale Anzahl an Chatnachrichten pro 10 Sekunden überschritten!
|
You exceeded the maximum number of messages per 10 seconds!=Sie haben die maximale Anzahl an Chatnachrichten pro 10 Sekunden überschritten!
|
||||||
Hey! Would you guys mind sleeping?=Hey, würdet Ihr bitte zu Bett gehen?
|
Hey! Would you guys mind sleeping?=Hey, würdet Ihr bitte zu Bett gehen?
|
||||||
|
Sorry, but you have to wait @1 seconds until you may use this button again!=Sie müssen leider noch @1 Sekunden warten, bevor sie diesen Knopf erneut benutzen können!
|
|
@ -45,4 +45,5 @@ Chat:=
|
||||||
send!=
|
send!=
|
||||||
You are missing the 'shout' privilege! It's required in order to talk in chat...=
|
You are missing the 'shout' privilege! It's required in order to talk in chat...=
|
||||||
You exceeded the maximum number of messages per 10 seconds!=
|
You exceeded the maximum number of messages per 10 seconds!=
|
||||||
Hey! Would you guys mind sleeping?=
|
Hey! Would you guys mind sleeping?=
|
||||||
|
Sorry, but you have to wait @1 seconds until you may use this button again!=
|
Loading…
Reference in New Issue