Jump to content

How to fix this bug in script?


Turbe$Z

Recommended Posts

When i type a big character, the script mute me.. But i want, when i type more than one big character, then mute me. How to fix this? /sorry for my bad english/

code: (server only)

addEventHandler('onPlayerChat',getRootElement(),function(key)  
      if string.byte(key) > 40 and string.byte(key) < 91  then -- pressed an alphabedical symbol with CAPS LOCK ON! 
		 setPlayerMuted( source, true )
		 gPlayerMuteTimer[ source ] = setTimer( unmutePlayer, gSettings.muteTime * 1000, 1, source )
		 outputChatBox( "#14B866[M] #FF699CPlaybot#898395: #696969Ne írj csupa nagybetűvel a chatben. Köszi! (#ffFFff"..getPlayerName(source).."#696969) (mute)", root, 255, 0, 0, true )	
     end 
 end) 

 

Link to comment
  • Administrators
function capsMute(message)
	c = 0
	for i = 1, #message do
	if (string.match(message, "%u")) then
		c = c + 1
	end
	end
	if c >= 2 then
		outputChatBox("Muted")
		-- mute player
	end
end
addEventHandler("onPlayerChat", root, capsMute)

I guess something like this should work.

Change the "2" to increase the amount of capitals needed to mute. For example, if I changed it from 2 to 10, I'd have to type "AAAAAAAAAA" to get muted, rather than "AA"

 

Also,

45 minutes ago, Dimos7 said:

that you can do it with that  


string.len 

 

No you can't. Not just with "string.len"

Edited by LopSided_
  • Like 1
Link to comment
3 minutes ago, LopSided_ said:

function capsMute(message)
	c = 0
	for i = 1, #message do
	if (string.match(message, "%u")) then
		c = c + 1
	end
	end
	if c >= 2 then
		outputChatBox("Muted")
		-- mute player
	end
end
addEventHandler("onPlayerChat", root, capsMute)

I guess something like this should work.

Change the "2" to increase the amount of capitals needed to mute. For example, if I changed it from 2 to 10, I'd have to type "AAAAAAAAAA" to get muted, rather than "AA"

Thanks :D

13 minutes ago, LopSided_ said:

function capsMute(message)
	c = 0
	for i = 1, #message do
	if (string.match(message, "%u")) then
		c = c + 1
	end
	end
	if c >= 2 then
		outputChatBox("Muted")
		-- mute player
	end
end
addEventHandler("onPlayerChat", root, capsMute)

I guess something like this should work.

Change the "2" to increase the amount of capitals needed to mute. For example, if I changed it from 2 to 10, I'd have to type "AAAAAAAAAA" to get muted, rather than "AA"

 

Also,

No you can't. Not just with "string.len"

oh wait.. :S when i type this 'Asd asd asd' for example, me muted.. why?

  • Like 1
Link to comment
32 minutes ago, LopSided_ said:

function capsMute(message)
	c = 0
	for i = 1, #message do
	if (string.match(message, "%u")) then
		c = c + 1
	end
	end
	if c >= 2 then
		outputChatBox("Muted")
		-- mute player
	end
end
addEventHandler("onPlayerChat", root, capsMute)

I guess something like this should work.

Change the "2" to increase the amount of capitals needed to mute. For example, if I changed it from 2 to 10, I'd have to type "AAAAAAAAAA" to get muted, rather than "AA"

 

Also,

No you can't. Not just with "string.len"

oh wait.. :S when i type this 'Asd asd asd' for example, me muted.. why?

Link to comment
  • Administrators
function capsMute(message)
	c = 0
	for i = 1, #message do
	if (string.match(message, "%u%u")) then
		c = c + 1
	end
	end
	if c >= 2 then
		outputChatBox("Muted")
		-- mute player
	end
end
addEventHandler("onPlayerChat", root, capsMute)

Fixed, my bad.

  • Like 1
Link to comment
3 minutes ago, LopSided_ said:

function capsMute(message)
	c = 0
	for i = 1, #message do
	if (string.match(message, "%u%u")) then
		c = c + 1
	end
	end
	if c >= 2 then
		outputChatBox("Muted")
		-- mute player
	end
end
addEventHandler("onPlayerChat", root, capsMute)

Fixed, my bad.

ahh thanks :D

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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