TorNix~|nR Posted April 9, 2017 Share Posted April 9, 2017 hello guys, I want to disable the chat onPlayerJoin when the player is downloading only onPlayerLogin, can use chat, help me please,? Link to comment
!#NssoR_) Posted April 9, 2017 Share Posted April 9, 2017 (edited) Use this function "isGuestAccount" with this event " onPlayerChat " and if he's doesn't logged in cancel the event by this " cancelEvent() ". isGuestAccount you should use getPlayerAccount function with it. Edited April 9, 2017 by !#NssoR_) Link to comment
Function Posted April 9, 2017 Share Posted April 9, 2017 function disableChat() local account = getPlayerAccount(source) if isGuestAccount(account) then cancelEvent() end end addEventHandler("onPlayerChat",root,disableChat) 1 Link to comment
TorNix~|nR Posted April 12, 2017 Author Share Posted April 12, 2017 On 10/04/2017 at 23:03, Function said: function disableChat() local account = getPlayerAccount(source) if isGuestAccount(account) then cancelEvent() end end addEventHandler("onPlayerChat",root,disableChat) It won't work Link to comment
Fist Posted April 12, 2017 Share Posted April 12, 2017 (edited) @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 April 12, 2017 by Fist Link to comment
TorNix~|nR Posted April 12, 2017 Author Share Posted April 12, 2017 @Fist, I'm sorry but I didn't understand Link to comment
Lincoln_Richardson Posted April 12, 2017 Share Posted April 12, 2017 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 Link to comment
Fist Posted April 12, 2017 Share Posted April 12, 2017 (edited) 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 April 12, 2017 by Fist Link to comment
TorNix~|nR Posted April 12, 2017 Author Share Posted April 12, 2017 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 ? Link to comment
Fist Posted April 12, 2017 Share Posted April 12, 2017 (edited) 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 April 12, 2017 by Fist Link to comment
TorNix~|nR Posted April 12, 2017 Author Share Posted April 12, 2017 it's server-side, but not worked Link to comment
#BrosS Posted April 12, 2017 Share Posted April 12, 2017 Do you have a costume tag system running or something like that ? Link to comment
TorNix~|nR Posted April 12, 2017 Author Share Posted April 12, 2017 @#BrosS Yes ACL & Team tags Link to comment
#BrosS Posted April 13, 2017 Share Posted April 13, 2017 8 hours ago, TorNix~|nR said: @#BrosS Yes ACL & Team tags Can you give some server side codes Just few about when you chat Link to comment
TorNix~|nR Posted April 13, 2017 Author Share Posted April 13, 2017 (edited) it's just server-side, there is no client-side. if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("TEST")) then outputChatBox("[TEST] "..getPlayerName(source)..": #FFFFFF"..msg, getRootElement(), 255, 0, 0, true) Edited April 13, 2017 by TorNix~|nR Link to comment
#BrosS Posted April 13, 2017 Share Posted April 13, 2017 Well you should put this before outputChatBox thing.... local account = getPlayerAccount(source) if isGuestAccount(account) then return outputChatBox("Please login first",source,255,0,0) end 1 Link to comment
TorNix~|nR Posted April 13, 2017 Author Share Posted April 13, 2017 It's finally worked, thank you so much guys Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now