abod99119911 Posted August 9, 2014 Author Share Posted August 9, 2014 (edited) Tested it in my server. Everything is fine, but it seems that this is not setting the data, but it does return 'true': function isNotMuted() lol = setElementData(source,"playermuted",0) outputChatBox(tostring(lol)) end addEventHandler("onPlayerUnmute",root,isNotMuted) I guess a... bug? where to put it in the clinet? Edited August 9, 2014 by Guest Link to comment
Bonsai Posted August 9, 2014 Share Posted August 9, 2014 See what you do by just posting a finished, more or less working script? People make more topics and expect to get a working script again. You should ask yourself if you wanna help people or just show off with your "skills". Link to comment
Max+ Posted August 9, 2014 Share Posted August 9, 2014 Try this , ---ClientSide function testing() local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) tx, ty, tz = getElementPosition( localPlayer ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 32.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( localPlayer, 5 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) local r,g,b = getPlayerNametagColor(localPlayer) scale = 0.65 if x then dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) end end end end addEvent ( 'Show', true ) addEventHandler ('Show', root, function ( ) addEventHandler("onClientRender",root,testing) end ) addEvent ( 'Remove', true ) addEventHandler ('Remove', root, function ( ) removeEventHandler ("onClientRender",root,testing) end ) ---ServerSide addEventHandler("onPlayerUnmute",root, function ( ) triggerClientEvent ( source, 'Remove', source ) end ) addEventHandler("onPlayerMute",root, function ( ) triggerClientEvent ( source, 'Show', source ) end ) Link to comment
abod99119911 Posted August 9, 2014 Author Share Posted August 9, 2014 Try this , ---ClientSide function testing() local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) tx, ty, tz = getElementPosition( localPlayer ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 32.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( localPlayer, 5 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) local r,g,b = getPlayerNametagColor(localPlayer) scale = 0.65 if x then dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) end end end end addEvent ( 'Show', true ) addEventHandler ('Show', root, function ( ) addEventHandler("onClientRender",root,testing) end ) addEvent ( 'Remove', true ) addEventHandler ('Remove', root, function ( ) removeEventHandler ("onClientRender",root,testing) end ) ---ServerSide addEventHandler("onPlayerUnmute",root, function ( ) triggerClientEvent ( source, 'Remove', source ) end ) addEventHandler("onPlayerMute",root, function ( ) triggerClientEvent ( source, 'Show', source ) end ) not working. i started the resores and i give mute to any player then its not working Link to comment
Et-win Posted August 9, 2014 Share Posted August 9, 2014 Like I said before, I tested it in my server. For some kind of reason, it's not setting the data with 'setElementData' on the player. It does by event 'onPlayerMute', but it doesn't do it by event 'onPlayerUnmute'. Still, the code 'setElementData' does return 'true', which means it was set. I checked it with a command handler, but it doesn't change at all. I would guess it's a bug in event 'onPlayerUnmute', but I'm not sure. I will try something different now. Link to comment
Et-win Posted August 9, 2014 Share Posted August 9, 2014 Server-Side: function muteHandler() local mutedPlayers = {} for placeNumber, playerData in ipairs(getElementsByType("player")) do if (isPlayerMuted(playerData) == true) then table.insert(mutedPlayers, playerData) end end triggerClientEvent("onServerSendMutedPlayers", getRootElement(), mutedPlayers) end addEventHandler("onPlayerMute", getRootElement(), muteHandler) addEventHandler("onPlayerUnmute", getRootElement(), muteHandler) " Client-Side: mutedPlayers = {} function receiveMutedPlayers(gMutedPlayers) mutedPlayers = gMutedPlayers end addEvent("onServerSendMutedPlayers", true) addEventHandler("onServerSendMutedPlayers", getRootElement(), receiveMutedPlayers) function testing() local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) for placeNumber, playerData in ipairs(mutedPlayers) do tx, ty, tz = getElementPosition( playerData ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 32.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( playerData, 5 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) local r,g,b = getPlayerNametagColor(localPlayer) scale = 0.65 if x then dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) end end end end end addEventHandler("onClientRender",root,testing) Only thing I could think of to 'solve' it. EDIT: I did some tests, and as soon as you put event 'onPlayerMute' in the same resource as where event 'onPlayerUnmute' is, then it doesn't set the element data anymore. So I will report it. Link to comment
abod99119911 Posted August 9, 2014 Author Share Posted August 9, 2014 Server-Side: function muteHandler() local mutedPlayers = {} for placeNumber, playerData in ipairs(getElementsByType("player")) do if (isPlayerMuted(playerData) == true) then table.insert(mutedPlayers, playerData) end end triggerClientEvent("onServerSendMutedPlayers", getRootElement(), mutedPlayers) end addEventHandler("onPlayerMute", getRootElement(), muteHandler) addEventHandler("onPlayerUnmute", getRootElement(), muteHandler) " Client-Side: mutedPlayers = {} function receiveMutedPlayers(gMutedPlayers) mutedPlayers = gMutedPlayers end addEvent("onServerSendMutedPlayers", true) addEventHandler("onServerSendMutedPlayers", getRootElement(), receiveMutedPlayers) function testing() local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) for placeNumber, playerData in ipairs(mutedPlayers) do tx, ty, tz = getElementPosition( playerData ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 32.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( playerData, 5 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) local r,g,b = getPlayerNametagColor(localPlayer) scale = 0.65 if x then dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) end end end end end addEventHandler("onClientRender",root,testing) Only thing I could think of to 'solve' it. EDIT: I did some tests, and as soon as you put event 'onPlayerMute' in the same resource as where event 'onPlayerUnmute' is, then it doesn't set the element data anymore. So I will report it. thx verry much i would like to thank u verry verry much 100% work thank you Link to comment
Et-win Posted August 9, 2014 Share Posted August 9, 2014 You are welcome. For the interested people: It seems to be a bug in Admin Panel. http://bugs.mtasa.com/view.php?id=8446 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