Overkillz Posted March 25, 2014 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.
Arnold-1 Posted March 25, 2014 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 Ingame Name: Arnold If you need my help, contact me on Skype @bshr.ara NOTE:DO NOT ASK ME FOR SCRIPTS, ASK ME FOR HELP
Overkillz Posted March 25, 2014 Author 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 ;(
DNL291 Posted March 25, 2014 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 ) Please do not PM me with scripting related question nor support, use the forums instead.
Dealman Posted March 25, 2014 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 If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Overkillz Posted March 25, 2014 Author 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)
Dealman Posted March 25, 2014 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) If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Dealman Posted March 25, 2014 Posted March 25, 2014 Work fine, thanks so much <3 Glad I could be of help If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
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