Overkillz Posted March 25, 2014 Share Posted March 25, 2014 Hi, I made a easy script with commands and outputchatbox but, I will like to block it if the player is muted, so If the player is muted, he cant use it. What is wrong here ? function hi (player) outputChatBox("#FFFFFF<"..getPlayerName(player).."#ffffff>:Hey #00ffffGuys !",root,255,255,255,true) if isPlayerMuted(source) then cancelEvent() outputChatBox("You are muted.",source, 255, 255, 0,true) return end addCommandHandler ( "hi", hi ) Regards. Link to comment
Arnold-1 Posted March 25, 2014 Share Posted March 25, 2014 (edited) EDIT: ohh i should have noticed that function hi (player) if not isPlayerMuted(player) then outputChatBox("#FFFFFF<"..getPlayerName(player).."#ffffff>:Hey #00ffffGuys !",root,255,255,255,true) else cancelEvent() outputChatBox("You are muted.",player, 255, 255, 0,true) end end addCommandHandler ( "hi", hi ) Edited March 25, 2014 by Guest Link to comment
Overkillz Posted March 25, 2014 Author Share Posted March 25, 2014 hmm, the code seems to be fine, are you sure it's placed server side?, wait i will test it and post the results. "Overkillz" version="1.0" type="script"/> Doesn't work ;( Link to comment
DNL291 Posted March 25, 2014 Share Posted March 25, 2014 function hi (player) if not isPlayerMuted(player) then outputChatBox("#FFFFFF<"..getPlayerName(player).."#ffffff>:Hey #00ffffGuys !",root,255,255,255,true) else outputChatBox("You are muted.",player, 255, 255, 0,true) end end addCommandHandler ( "hi", hi ) Link to comment
Dealman Posted March 25, 2014 Share Posted March 25, 2014 Make the check before you output the message. Also you should use player instead of source for the player source. function exampleCommand_Handler(thePlayer, theCMD) if(isPlayerMuted(thePlayer) ~= true) then outputChatBox("<"..getPlayerName(thePlayer).."#FFFFFF>: #00FFFFHello World!", root, 255, 255, 255, true) else outputChatBox("You're muted and can not use this command.") cancelEvent() end end addCommandHandler("hi", exampleCommand_Handler, false) -- False tells the command handler that it is NOT case-sensitive. Edit: DNL beat me to it Link to comment
Overkillz Posted March 25, 2014 Author Share Posted March 25, 2014 Thanks you guys, and with the PM System ? function privateMessage(player, command, toplayername, ...) local words = { ... } local message = table.concat(words," ") if toplayername then if (findPlayerByName (toplayername)) then toplayer = (findPlayerByName (toplayername)) if not (toplayer == player) then if message then outputChatBox("#FF0000[PM]#00aaff Message to #FFFFFF" .. getPlayerName(toplayer) .. "#FFFFFF: " .. message, player, 255, 255, 255, true) outputChatBox("#FF0000[PM]#00aaff Message from #FFFFFF" .. getPlayerName(player) .. "#FFFFFF: " .. message, toplayer, 255, 255, 255, true) else outputChatBox("#FF0000[PM]#00aaff Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", player, 255, 255, 255, true) return false end else outputChatBox("#FF0000[PM]#00aaff You cannot PM yourself#FFFFFF!", player, 255, 255, 255, true) return false end else outputChatBox("#FF0000[PM]#00aaff Player not found! #FFFFFF("..toplayername..").", player, 255, 255, 255, true) return false end else outputChatBox("#FF0000[PM]#00aaff Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", player, 255, 255, 255, true) return false end end addCommandHandler("pm", privateMessage) Link to comment
Dealman Posted March 25, 2014 Share Posted March 25, 2014 You can try this; function privateMessage(player, command, toplayername, ...) local words = { ... } local message = table.concat(words," ") if(isPlayerMuted(player) ~= true) then if toplayername then if (findPlayerByName (toplayername)) then toplayer = (findPlayerByName (toplayername)) if not (toplayer == player) then if message then outputChatBox("#FF0000[PM]#00aaff Message to #FFFFFF" .. getPlayerName(toplayer) .. "#FFFFFF: " .. message, player, 255, 255, 255, true) outputChatBox("#FF0000[PM]#00aaff Message from #FFFFFF" .. getPlayerName(player) .. "#FFFFFF: " .. message, toplayer, 255, 255, 255, true) else outputChatBox("#FF0000[PM]#00aaff Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", player, 255, 255, 255, true) return false end else outputChatBox("#FF0000[PM]#00aaff You cannot PM yourself#FFFFFF!", player, 255, 255, 255, true) return false end else outputChatBox("#FF0000[PM]#00aaff Player not found! #FFFFFF("..toplayername..").", player, 255, 255, 255, true) return false end else outputChatBox("#FF0000[PM]#00aaff Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", player, 255, 255, 255, true) return false end else outputChatBox("#FF0000[PM]:#00AAFF Failed to send PM - you're muted!", player, 255, 255, 255, true) end end addCommandHandler("pm", privateMessage) Link to comment
Overkillz Posted March 25, 2014 Author Share Posted March 25, 2014 Work fine, thanks so much <3 Link to comment
Dealman Posted March 25, 2014 Share Posted March 25, 2014 Work fine, thanks so much <3 Glad I could be of help 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