Jump to content

trigger problem


Recommended Posts

السلام عليكم

بدي لما يكون اللاعب عليه ميوت ما يقرأ باقي السكريبت 

يعني ما يقدر يكتب في الشات تبع السبورت

serverside:

function checkismuteed (ply)
if isPlayerMuted(ply) then
return end
end
addEvent("mutedplyer",true)
addEventHandler("mutedplyer",resourceRoot, checkismuteed)

clientside:

function sendChatMessage(plyr)
	local time = getRealTime()
	local hours = time.hour
	local minutes = time.minute
	local seconds = time.second
	-- Make sure to add a 0 to the front of single digits.
	if (hours < 10) then
		hours = "0"..hours
	end
	if (minutes < 10) then
		minutes = "0"..minutes
	end
	if (seconds < 10) then
		seconds = "0"..seconds
	end
	if supp_chat and isElement(supp_chat) then
		local newText = guiGetText(support_urmsg)
		triggerServerEvent("mutedplyer", localPlayer)
    			guiSetText(err_label, "You are muted!")
		if newText and string.len(newText) >= 4 then
					guiSetText(err_label, "")
			local oldText = guiGetText(supp_chat)
			
			if not oldText then oldText = "" end
			oldText = ( ( oldText ) ..  "[" .. ( tostring ( hours ) ) .. "-" .. ( tostring ( minutes ) ) .. "-" .. ( tostring ( seconds ) ) .. "]" ..  ( getPlayerName ( localPlayer ) ) .. ": " .. ( newText ) )
			guiSetText(supp_chat, oldText)
			guiSetText(support_urmsg, "")
			guiMemoSetCaretIndex(supp_chat, string.len(oldText))
			else
		end	
	end
end
addEventHandler("onClientGUIAccepted", resourceRoot, sendChatMessage)

 

Edited by Outlaw
Link to comment
-- # Server
addEvent ( "mutedplayer" , true )
function checkismuteed ( )
	if ( isPlayerMuted ( client ) ) then
		mute = true 
	else
		mute = false
	end
	return mute ;
	triggerClientEvent ( client , "mutedplayer" , client , mute )
end
addEventHandler ( "mutedplayer" , resourceRoot , checkismuteed )

-- # Client
local MP ;
addEvent ( "mutedplayer" , true )
function mutedPlayer ( m )
	MP = m;
end
addEventHandler ( "mutedplayer" , resourceRoot , mutedPlayer )


function sendChatMessage ( plyr )
	local time = getRealTime ( )
	local hours = time.hour
	local minutes = time.minute
	local seconds = time.second
	-- Make sure to add a 0 to the front of single digits.
	if (hours < 10) then
		hours = "0"..hours
	end
	if (minutes < 10) then
		minutes = "0"..minutes
	end
	if (seconds < 10) then
		seconds = "0"..seconds
	end
	if ( ( supp_chat )  and ( isElement ( supp_chat ) ) ) then
		local newText = guiGetText ( support_urmsg )
		triggerServerEvent ( "mutedplayer" , localPlayer )
		if ( MP == true ) then
			guiSetText ( err_label , "You are muted!" )
		else
			if ( ( newText ) and ( string.len ( newText ) >= 4 ) ) then
				guiSetText ( err_label , "" )
				local oldText = guiGetText ( supp_chat )
				if ( not oldText )  then
					oldText = "" ;
				end
				oldText = ( ( oldText ) ..  "[" .. ( tostring ( hours ) ) .. "-" .. ( tostring ( minutes ) ) .. "-" .. ( tostring ( seconds ) ) .. "]" ..  ( getPlayerName ( localPlayer ) ) .. ": " .. ( newText ) )
				guiSetText ( supp_chat , oldText )
				guiSetText ( support_urmsg , "" )
				guiMemoSetCaretIndex ( supp_chat , string.len ( oldText ) )
			end	
		end
	end
end
addEventHandler ( "onClientGUIAccepted" , resourceRoot , sendChatMessage )

 

Edited by MrBiG
Link to comment
21 hours ago, MrBiG said:

-- # Server
addEvent ( "mutedplayer" , true )
function checkismuteed ( )
	if ( isPlayerMuted ( client ) ) then
		mute = true 
	else
		mute = false
	end
	return mute ;
	triggerClientEvent ( client , "mutedplayer" , client , mute )
end
addEventHandler ( "mutedplayer" , resourceRoot , checkismuteed )

-- # Client
local MP ;
addEvent ( "mutedplayer" , true )
function mutedPlayer ( m )
	MP = m;
end
addEventHandler ( "mutedplayer" , resourceRoot , mutedPlayer )


function sendChatMessage ( plyr )
	local time = getRealTime ( )
	local hours = time.hour
	local minutes = time.minute
	local seconds = time.second
	-- Make sure to add a 0 to the front of single digits.
	if (hours < 10) then
		hours = "0"..hours
	end
	if (minutes < 10) then
		minutes = "0"..minutes
	end
	if (seconds < 10) then
		seconds = "0"..seconds
	end
	if ( ( supp_chat )  and ( isElement ( supp_chat ) ) ) then
		local newText = guiGetText ( support_urmsg )
		triggerServerEvent ( "mutedplayer" , localPlayer )
		if ( MP == true ) then
			guiSetText ( err_label , "You are muted!" )
		else
			if ( ( newText ) and ( string.len ( newText ) >= 4 ) ) then
				guiSetText ( err_label , "" )
				local oldText = guiGetText ( supp_chat )
				if ( not oldText )  then
					oldText = "" ;
				end
				oldText = ( ( oldText ) ..  "[" .. ( tostring ( hours ) ) .. "-" .. ( tostring ( minutes ) ) .. "-" .. ( tostring ( seconds ) ) .. "]" ..  ( getPlayerName ( localPlayer ) ) .. ": " .. ( newText ) )
				guiSetText ( supp_chat , oldText )
				guiSetText ( support_urmsg , "" )
				guiMemoSetCaretIndex ( supp_chat , string.len ( oldText ) )
			end	
		end
	end
end
addEventHandler ( "onClientGUIAccepted" , resourceRoot , sendChatMessage )

 

كودك خطأ, واحياناً ممكن اللاعب يقدر يرسل رسالة وعليه ميوت

الطريقة الصحيحة, كود ارسال الرسالة يكون عند وصول الحدث من السيرفر

ايضاً حاول ما تكرر اسماء الأحداث مستقبلاً, واستعمالك للمتغيرات بالسيرفر ماله داعي, تحقق وارسل الحدث مباشرةً

Edited by N3xT
Link to comment
On 02/08/2019 at 05:27, N3xT said:

N3xT

-- # Server
addEvent ( "player;checkMuted" , true )
function checkismuteed ( )
	if ( isPlayerMuted ( client ) ) then
		triggerClientEvent ( client , "player;checkedMuted" , client , true )
	else
		triggerClientEvent ( client , "player;checkedMuted" , client , false )
	end
end
addEventHandler ( "player;checkMuted" , resourceRoot , checkismuteed )

-- # Client

addEvent ( "player;checkedMuted" , true )
function mutedPlayer ( m )
	if ( m and type ( m ) == 'boolean' ) then 
		if ( tostring ( m ) == 'true' ) then
			guiSetText ( err_label , "You are muted!" )
		elseif ( tostring ( m ) == 'false' ) then
			local time = getRealTime ( )
			local hours = time.hour
			local minutes = time.minute
			local seconds = time.second
			-- Make sure to add a 0 to the front of single digits.
			if (hours < 10) then
				hours = "0"..hours
			end
			if (minutes < 10) then
				minutes = "0"..minutes
			end
			if (seconds < 10) then
				seconds = "0"..seconds
			end
			local newText = guiGetText ( support_urmsg )
			if ( ( newText ) and ( string.len ( newText ) >= 4 ) ) then
				guiSetText ( err_label , "" )
				local oldText = guiGetText ( supp_chat )
				if ( not oldText )  then
					oldText = "" ;
				end
				oldText = ( ( oldText ) ..  "[" .. ( tostring ( hours ) ) .. "-" .. ( tostring ( minutes ) ) .. "-" .. ( tostring ( seconds ) ) .. "]" ..  ( getPlayerName ( localPlayer ) ) .. ": " .. ( newText ) )
				guiSetText ( supp_chat , oldText )
				guiSetText ( support_urmsg , "" )
				guiMemoSetCaretIndex ( supp_chat , string.len ( oldText ) )
			end	
		end
	end
end
addEventHandler ( "player;checkedMuted" , resourceRoot , mutedPlayer )


function sendChatMessage ( )
	if ( ( supp_chat )  and ( isElement ( supp_chat ) ) ) then	
		if ( guiGetText ( support_urmsg ) ~= '' ) then
			triggerServerEvent ( "player;checkMuted" , localPlayer )
		end
	end
end
addEventHandler ( "onClientGUIAccepted" , resourceRoot , sendChatMessage )

أفضل ؟

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