megaman54 Posted August 18, 2011 Share Posted August 18, 2011 I'm making a mute script wich is different than the default one. It should work like this: i type /smute and it mutes that player without using the setPlayerMuted function. I want to make it like that no-one can see when someone gets muted and when the muted player tries to speak, he wont get the "you are muted" message. So, here is my problem: i must store the muted player names in a table, but i dont know how to check if the name is in the table. Here is what i have done so far: muted = {} function silentMute() I know it isnt much but thats all i can do by myself. I'm a very noob with tables... I hope someone can help me with this. Link to comment
will briggs Posted August 18, 2011 Share Posted August 18, 2011 Hmmm, Maybe you should go check out the wiki, But heres what you wanted... function muteOurPlayer(player, command, mutedguy, time, reason) if mutedguy and time and reason then local muted = getPlayerFromName(mutedguy) if muted then if( not isPlayerMuted(muted) ) then setPlayerMuted(muted, true) outputChatBox(..getPlayerName(muted).." has been muted for "..time.." minutes. (Reason: "..reason.."#FF0000 )", getRootElement(), 255, 0, 0, true) setElementData(muted, "Muted", 1) setElementData(muted, "MutedTime", time) setElementData(muted, "Reason", reason) end end else outputChatBox("Mute command: /mute ", player) end end addCommandHandler("mute", muteOurPlayer) Link to comment
megaman54 Posted August 18, 2011 Author Share Posted August 18, 2011 Ehm... I clearly stated that i want to do it without setPlayerMuted function. Link to comment
Baseplate Posted August 18, 2011 Share Posted August 18, 2011 you can't do it without setPlayerMuted function Link to comment
JR10 Posted August 18, 2011 Share Posted August 18, 2011 Have already made the mute functionality? for tables: muted = { } --onPlayerMuted table.insert ( muted , player ) This is what you want? Link to comment
megaman54 Posted August 18, 2011 Author Share Posted August 18, 2011 Have already made the mute functionality?for tables: muted = { } --onPlayerMuted table.insert ( muted , player ) This is what you want? Yes! Thanks. But the probelm is, how i could check if the name is in the table? Link to comment
JR10 Posted August 18, 2011 Share Posted August 18, 2011 What you mean a name? That table can only contains players. if muted [ player ] ~= nil then Link to comment
SDK Posted August 18, 2011 Share Posted August 18, 2011 To check, you'll need a loop: function checkPlayerMuted ( thePlayer ) for k, player in ipairs(muted) do if player == thePlayer then return true end end return false end To disable the chat (=muted), cancel the onPlayerChat event if the player is in the table: function checkMute ( ) local player = source if checkPlayerMuted ( player ) then cancelEvent() end end addEventHandler("onPlayerChat", root, checkMute) Link to comment
megaman54 Posted August 18, 2011 Author Share Posted August 18, 2011 Thanks to you all! I thnik i'm gonna figure this out more quickly with your help thanks. 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