Jump to content

Chat


Recommended Posts

@TorNix~|nR it didn't work 'cause guest account is not set by default when player joins.

addEventHandler("onPlayerChat",root,function())
	if (not isPedDead(source)) then cancelEvent(); end
end);

You can try by setting their account as guest when they join or using this. but keep in mind, this will even block dead player messages that are logged in. There is even better way doing it, by setting elementdata or variable "logedin = false" when player joins then when player logins in server then set their var to "logedin = true" and then just check when player tries to chat if their var logedin is false then cancel event. (This easier would be to do with setElementData and getElementData)

Edited by Fist
Link to comment
2 hours ago, Lincoln_Richardson said:

addEventHandler ("onPlayerConnect", getRootElement(), 
	function ( )
		showChat ( source, false )
	end
)

addEventHandler("onPlayerJoin", getRootElement(), 
	function ( )
		showChat ( source, true )
	end
)

serverside

Try. This code disconnects the chat when you connect

you do understand that you can still enable it back with console command 'showchat' or even with console command 'say text' which would work as chat aswell. You have to simply disable event when player chats. @TorNix~|nR

function blockChat()
	cancelEvent();
end

addEventHandler ("onPlayerConnect",root,function()
	addEventHandler("onPlayerChat",source,blockChat);
end);

addEventHandler("onPlayerJoin",root,function() 
	removeEventHandler("onPlayerChat",source,blockChat);
end)

 

Edited by Fist
Link to comment
39 minutes ago, TorNix~|nR said:

guys it's not worked

what I want when player join, he can't use chat, when he log in he can, you understand?

help please ?

Did you put it on server side? Did it have any errors? If no then it could be the way i used eventHandlers. Then just do this. (it's server side)

addEventHandler("onPlayerLogin",root,function()
    setElementData(source,"logedin",true);
end);

addEventHandler("onPlayerChat",root,function()
    if (not getElementData(source,"logedin")) then cancelEvent(); end
end);

 

Edited by Fist
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...