blinkerchris Posted March 23, 2014 Posted March 23, 2014 Hey, I started on a new chatmute script and it seems to have errors, I know there are errors in the script because of the debugscript which says: ERROR: Loading script failed: localmute\client.lua:5: '' expected near 'end' I can't get it to work (I know that there are alot of mistakes) function chatdis(command) cancelEvent() outputChatBox("#E3E8B7The chat has been disabled by (localPlayerName)",source,255,0,0) addEventHandler("onPlayerChat",getRootElement(),chatdis) end end end ) function chaten(command) outputChatBox("#E3E8B7The chat has been enabled by (localPlayerName)",getRootElement(),255,0,0) removeEventHandler("onPlayerChat",getRootElement(),chatdis) end ) ) addCommandHandler("myname", function() local localPlayerName = getPlayerName(getLocalPlayer()) end ) addCommandHandler("chatoff",chatdis) addCommandHandler("chaton",chaten) Can you correct me? Thanks
xXMADEXx Posted March 23, 2014 Posted March 23, 2014 You had all sorts of errors... function chatdis( ) cancelEvent() outputChatBox("#E3E8B7The chat has been disabled by (localPlayerName)",source,255,0,0) addEventHandler("onPlayerChat",getRootElement(),chatdis) end function chaten( ) outputChatBox("#E3E8B7The chat has been enabled by (localPlayerName)",getRootElement(),255,0,0) removeEventHandler("onPlayerChat",getRootElement(),chatdis) end addCommandHandler("myname", function() local localPlayerName = getPlayerName(getLocalPlayer()) end ) addCommandHandler("chatoff",chatdis) addCommandHandler("chaton",chaten)
Karuzo Posted March 23, 2014 Posted March 23, 2014 You made a Typo in (localPlayerName) since it's still in the string it will output (localPlayerName) only.
blinkerchris Posted March 23, 2014 Author Posted March 23, 2014 Yea, I know =/ do you know how to make it, if I write /chaton it will say 'The chat has been enabled by (the name im using) do you know how to make it like that?
Baseplate Posted March 23, 2014 Posted March 23, 2014 local chat = true function chatDis(thePlayer) outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end addCommandHandler("chaton",chatEn) function onChat() if (chat == false) then cancelEvent() end end addEventHandler("onPlayerChat", root, onChat) I'm not sure if this is gonna work, but give it a try.. Serversided.
blinkerchris Posted March 23, 2014 Author Posted March 23, 2014 local chat = true function chatDis(thePlayer) outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end addCommandHandler("chaton",chatEn) function onChat() if (chat == false) then cancelEvent() end end addEventHandler("onPlayerChat", root, onChat) I'm not sure if this is gonna work, but give it a try.. Serversided. Thanks that works perfectly. Do you know how to make teamchat allowed? but the main chat disabled Also, only admins can /chaton /chatoff, not everyone. thanks again
Baseplate Posted March 24, 2014 Posted March 24, 2014 local chat = true function chatDis(thePlayer) local accName = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then outputChatBox("#E3E8B7The chat has been disabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) local accName = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then outputChatBox("#E3E8B7The chat has been enabled by "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end end addCommandHandler("chaton",chatEn) function onChat(msg, msgType) if (chat == false) and (msgType == 0) then cancelEvent() end end addEventHandler("onPlayerChat", root, onChat)
Noki Posted March 25, 2014 Posted March 25, 2014 @ Samer, why output to root when a loop is much more efficient? root can be tens of thousands of elements, but looping through players is so much more efficient.
Moderators IIYAMA Posted March 25, 2014 Moderators Posted March 25, 2014 @ Samer, why output to root when a loop is much more efficient? root can be tens of thousands of elements, but looping through players is so much more efficient. Where do you see Samer? O_o Root is more efficient, since it only can be send to players. A loop will call the outputChatBox function over and over, which uses much more memory. You can test that with getTickCount(), if you don't believe me.
Noki Posted March 25, 2014 Posted March 25, 2014 @ Samer, why output to root when a loop is much more efficient? root can be tens of thousands of elements, but looping through players is so much more efficient. Where do you see Samer? O_o abxf is Samer. I never knew that root outputs to players... I'll have to test this myself lol damn.
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