Jump to content

طلب بمود التكرار بالشات


Recommended Posts

سلام عليكم ابي اسوي لو الشخص كتب كلمة - وكتب علطول بعدها كلمة

يقوله الرجاء الانتظار 5- 4 - 3 - 2 - 1

محاولتي


function convertMilliseconds( i ) 
    if ( i ) then 
        sec = math.fmod( math.floor( i / 1000 ), 60 ) 
        return string.format( '%2d', sec ) 
    end 
end
					local timer2 = convertMilliseconds( getTimerDetails( timer[root] ) )
					outputChatBox( "Don't repeat yourself!!! wait ".. timer2 .."", source, 255, 0, 0 )

 

Link to comment
3 hours ago, Mr.Mostafa said:

سلام عليكم ابي اسوي لو الشخص كتب كلمة - وكتب علطول بعدها كلمة

يقوله الرجاء الانتظار 5- 4 - 3 - 2 - 1

محاولتي


function convertMilliseconds( i ) 
    if ( i ) then 
        sec = math.fmod( math.floor( i / 1000 ), 60 ) 
        return string.format( '%2d', sec ) 
    end 
end

					local timer2 = convertMilliseconds( getTimerDetails( timer[root] ) )
					outputChatBox( "Don't repeat yourself!!! wait ".. timer2 .."", source, 255, 0, 0 )

 

 

timer = {}

function convertMilliseconds( i )
if ( i ) then
sec = math.fmod( math.floor( i / 1000 ), 60 )
return string.format( '%2d', sec )
end
end


local timer2 = convertMilliseconds( getTimerDetails( timer[root] ) )
outputChatBox( "Don't repeat yourself!!! wait [ ".. timer2 .." ]", source, 255, 0, 0, true )



timer[root] = setTimer( function() end, 5000, 1 )

 

Link to comment
On ٥‏/٦‏/٢٠١٨ at 10:36, +Source|> said:

 


timer = {}

function convertMilliseconds( i )
if ( i ) then
sec = math.fmod( math.floor( i / 1000 ), 60 )
return string.format( '%2d', sec )
end
end


local timer2 = convertMilliseconds( getTimerDetails( timer[root] ) )
outputChatBox( "Don't repeat yourself!!! wait [ ".. timer2 .." ]", source, 255, 0, 0, true )



timer[root] = setTimer( function() end, 5000, 1 )

 

ما اشتغل

Link to comment
1 minute ago, +Source|> said:

حط اكوادك


local gPlayerTickCount = { }
local gPlayerSpams = { }
local gPlayerMessage = { }
local gPlayerMsgNum = { }
local gPlayerMuteTimer = { }

local gSettings = { }

addEventHandler( "onPlayerChat", getRootElement( ),
    function( message )
        if not gPlayerSpams[ source ] then
			gPlayerSpams[ source ] = true
			gPlayerTickCount[ source ] = getTickCount( )
            gPlayerMessage[ source ] = message
        else
			if getTickCount( ) - gPlayerTickCount[ source ] > gSettings.delay then
				gPlayerMsgNum[ source ] = 0
				gPlayerMessage[ source ] = nil;
				gPlayerTickCount[ source ] = getTickCount( )
				return
			else
				if gPlayerMsgNum[ source ] >= gSettings.msgNum then
					gPlayerTickCount[ source ] = getTickCount( )
					cancelEvent( )
					if gSettings.mutePlayers then
						mutePlayer( source );
					end
				elseif message == gPlayerMessage[ source ] then
					cancelEvent( )
					outputChatBox( "Don't repeat yourself!!!", source, 255, 0, 0 )
				end
				gPlayerMsgNum[ source ] = gPlayerMsgNum[ source ] + 1
			end
        end
		gPlayerMessage[ source ] = message
    end
)

function mutePlayer( player )
	setPlayerMuted( player, true );
	gPlayerMuteTimer[ player ] = setTimer( unmutePlayer, gSettings.muteTime * 1000, 1, player );
	outputChatBox( "Don't flood the chat!!! You are now muted for " .. gSettings.muteTime .." seconds.", player, 255, 0, 0 )
end

function unmutePlayer( player )
	setPlayerMuted( player, false );
	outputChatBox( "You can talk again. Remeber, do NOT spam!", player, 255, 0, 0 );
end

addEventHandler( "onPlayerJoin", getRootElement( ),
	function( )
		gPlayerMsgNum[ source ] = 0
	end
)

addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ),
    function( )
        gSettings.delay = get( "@differenceBetweenMessages_ms" )
		gSettings.msgNum = get( "@messagesNumber" )
		gSettings.mutePlayers = ( get( "@mutePlayers" ) == "true" ) and true or false;
		gSettings.muteTime = get( "@muteTime" );
		for _, plr in pairs( getElementsByType( "player" ) ) do
			gPlayerMsgNum[ plr ] = 0
		end
    end
)

addEventHandler( "onResourceStop", getResourceRootElement(),
	function( )
		local players = getElementsByType( "player" );
		for i, plr in pairs( players ) do
			if isPlayerMuted( plr ) then
				setPlayerMuted( plr, false );
			end
		end
	end
)

 

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...