Karoffe Posted April 8, 2014 Share Posted April 8, 2014 (edited) SOLVED Edited April 26, 2014 by Guest Link to comment
Karoffe Posted April 8, 2014 Author Share Posted April 8, 2014 try [/code] --[code=lua] Yeah, that works, EDITED Link to comment
WASSIm. Posted April 9, 2014 Share Posted April 9, 2014 make it same button is better Client function mute_btnw (button, state, absoluteX, absoluteY, muted) if (source == mute_btn) then local playernames = guiGridListGetItemText ( player_namesgrd, guiGridListGetSelectedItem ( player_namesgrd ), column ) if (playernames) and not (playernames == "") then triggerServerEvent("mute_player", localPlayer, playernames) end end end addEventHandler( "onClientGUIClick", resourceRoot, mute_btnw) Server function mute_players(playernames) local gplayernames = getPlayerFromName ( playernames ) if (gplayernames) then if isPlayerMuted ( gplayernames ) then setPlayerMuted(gplayernames, false) else setPlayerMuted(gplayernames, true) end end end addEvent("mute_player", true) addEventHandler("mute_player", root, mute_players) Link to comment
Karoffe Posted April 9, 2014 Author Share Posted April 9, 2014 Nah, that's not what i needed WASSIm, i do not want it to be the same button. i want if someone presses mute then a window will apear with a mute button and unmute button which both are disabled, if the selected player is muted then unmute button should be enabled if player is not muted then mute button should be enabled... that's what i am willing to do,, you didn't solve my problem you just said another option which i don't want I appreciate that you're trying to help,, it's kind from you. any other solutions ? Link to comment
Moderators IIYAMA Posted April 10, 2014 Moderators Share Posted April 10, 2014 This is how it can be done. You have to merge it with your button script and set up your buttons. Good luck. server addEvent("check_player_mute", true) addEventHandler("check_player_mute", root, function (playerName) if isElement(source) then local targetPlayer = getPlayerFromName ( playerName ) if targetPlayer then triggerClientEvent(source,"playerMuteStatus",targetPlayer, isPlayerMuted (targetPlayer),playerName) end end end) addEvent("mutePlayer",true) addEventHandler("mutePlayer",root, function(status) if isElement(source) and isElement(client) then setPlayerMuted (source,status) outputChatBox("You have been muted by IIYAMA....",source,255,0,0) end end) client addCommandHandler("checkmute", function(CMD,name) triggerServerEvent("check_player_mute",localPlayer,name) end) addEvent("playerMuteStatus",true) addEventHandler("playerMuteStatus",root, function (muteStatus,targetName) local targetPlayer = source if isElement(targetPlayer) then outputChatBox("You are trying to mute/unmute this person: " .. targetName) end end) --[[ do your button stuff... triggerServerEvent("mutePlayer",targetPlayer,not muteStatus) ]] Link to comment
Karoffe Posted April 10, 2014 Author Share Posted April 10, 2014 (edited) SOLVED Edited April 26, 2014 by Guest Link to comment
Moderators IIYAMA Posted April 10, 2014 Moderators Share Posted April 10, 2014 is this a correction for my code ? What I am trying to show you, is how you can communicate with the server. Isn't that what you want? Knowing if a player is muted or unmuted so you can show the right button? What I have written is designed to request information(muted/unmuted) from the server and send it back to the client who asked for it. Also I added a function which can mute/unmute a player when you press one of those buttons. But what triggers the function: unmute_players ? You don't check if that player does exist that has been given by getPlayerFromName, which will give some warnings. Also source can be a button = onClientGUIClick or a player = triggering, it will not work you have to put some functions in between making sure all data is correct. Also clientside only elements can't switch from side. This code is more complicated then the lines you already have written yet. You can better know then thinking you know, test your variables is a good start. I hope my information can help you further. 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