Araa Posted May 27, 2012 Share Posted May 27, 2012 Bueno, hola.. tengo un pequeño problema ._. cuando intento correr el script, este dice "Bad Argument @ 'is Player Muted'" Perdon si es un super fail me cuesta bastante esto, lo que tendria que hacer es mostrar el drawText si el player esta muteado, no siempre... Gracias. --SERVER function mutecheck (thePlayer) if isPlayerMuted ( thePlayer ) then return true else return false end setTimer(mutecheck, 5000,1) addEvent ("checker", true, mutecheck) --CLIENT function showing( ) local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) for _, v in ipairs( getElementsByType 'player' ) do tx, ty, tz = getElementPosition( v ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 30.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( v, 1 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 ) if x and triggerServerEvent ("checker", v) == true then dxDrawText( "Muted ", x, y, x, y, tocolor(150, 0, 0), 0.85 + ( 15 - dist ) * 0.02, "pricedown", "center" ) end end end end end addEventHandler( "onClientRender",root,showing) setTimer (showing, 5000,1) Segun esto Link to comment
Carlossg Posted May 27, 2012 Share Posted May 27, 2012 ¿A quién se supone que esta el isPlayerMuted? El argumento no está definido(eso creo),puede ser que me equivoque EDITO: Toma, creo que este codigo está bien, sólo creo porque soy novato: Client function showing( ) local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) for _, v in ipairs( getElementsByType 'player' ) do tx, ty, tz = getElementPosition( v ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 30.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( v, 1 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 ) if x and triggerServerEvent ("checker", v) == true then dxDrawText( "Muted ", x, y, x, y, tocolor(150, 0, 0), 0.85 + ( 15 - dist ) * 0.02, "pricedown", "center" ) end end end end end addEventHandler( "onClientRender",root,showing) setTimer (showing, 5000,1) function name() --Añadida funcion para obtener el nombre del jugador name = getPlayerName(getLocalPlayer()) end addEvent("Nombre",true) --Añadida posibilidad para triggearlo desde el server addEventHandler("Nombre",getRootElement(),name) Server function mutecheck ()--Aqui si no funciona prueba a poner entre parentesis Obtener, no lo he puesto porque no estoy seguro Obtener = triggerClientEvent("Nombre",getRootElement())--triggeando al cliente, para saber el nombre. if isPlayerMuted ( Obtener ) then return true else return false end setTimer(mutecheck, 5000,1) addEvent ("checker", true)--Considero que como lo tenías antes está mal, ya que en la wiki sólo tiene 2 argumentos. addEventHandler("checker",getRootElement(), mutecheck) Puede ser que esté mal, soy un desastre , pero intento ayudar. Link to comment
Edikosh998 Posted May 27, 2012 Share Posted May 27, 2012 Carlos, no tiene sentido ese script Mira tendria que ser asi : function mutecheck () for i,v in ipairs(getElementsByType("player")) do if isPlayerMuted ( v ) then triggerClientEvent(v,"onMuted",v) end end end -- Faltaba un end ademas... setTimer(muteCheck,5000,0) -- Si lo pones 1 , lo chequea solo una vez. Tenes que poner en 0 Client Side function onMuted() addEventHandler("onClientRender",root,showing) end addEvent("onMuted",true) addEventHandler("onMuted",root,onMuted) function showing( ) local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) for _, v in ipairs( getElementsByType 'player' ) do tx, ty, tz = getElementPosition( v ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 30.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( v, 1 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 ) if x and triggerServerEvent ("checker", v) == true then dxDrawText( "Muted ", x, y, x, y, tocolor(150, 0, 0), 0.85 + ( 15 - dist ) * 0.02, "pricedown", "center" ) end end end end end Ah y el client, tampoco se entiende, pero esperame que me fijo porque no entendi bien. EDIT 1 : Usas clientRender y timer a la vez? EDIT 2 : YA ENTENDI LO QUE BUSCAS mira lo que tenes que hacer... Link to comment
Carlossg Posted May 27, 2012 Share Posted May 27, 2012 Carlos, no tiene sentido ese scriptMira tendria que ser asi : function mutecheck () for i,v in ipairs(getElementsByType("player")) do if isPlayerMuted ( v ) then triggerClientEvent(v,"onMuted",v) end end end -- Faltaba un end ademas... setTimer(muteCheck,5000,0) -- Si lo pones 1 , lo chequea solo una vez. Tenes que poner en 0 Client Side function onMuted() addEventHandler("onClientRender",root,showing) end addEvent("onMuted",true) addEventHandler("onMuted",root,onMuted) function showing( ) local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) for _, v in ipairs( getElementsByType 'player' ) do tx, ty, tz = getElementPosition( v ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 30.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( v, 1 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 ) if x and triggerServerEvent ("checker", v) == true then dxDrawText( "Muted ", x, y, x, y, tocolor(150, 0, 0), 0.85 + ( 15 - dist ) * 0.02, "pricedown", "center" ) end end end end end Ah y el client, tampoco se entiende, pero esperame que me fijo porque no entendi bien. EDIT 1 : Usas clientRender y timer a la vez? EDIT 2 : YA ENTENDI LO QUE BUSCAS mira lo que tenes que hacer... Por favor, me podrías decir enque está mal mi script,te lo agradecería. Por si sirve yo pensé que quería que le pusiera a el mismo player(osea el que juega) si está muteado. Link to comment
Edikosh998 Posted May 27, 2012 Share Posted May 27, 2012 1) DE DONDE sacas el evento "chequear"? No hay trigger ni nada. 2) La variable Obtener devuelve "true/false" no devuelve "player" 3) El evento nombre, vos lo pusiste, creyendo QUE IBA A DEVOLVER EL nombre. Si ves la wiki, los trigger devuelven bool, osea sirven para ejecutar algo tanto en client/server. Espero que te sirva. Link to comment
Araa Posted May 27, 2012 Author Share Posted May 27, 2012 Mmm... funciona, pero cuando el player esta unmuted el texto sigue Link to comment
Carlossg Posted May 27, 2012 Share Posted May 27, 2012 1) DE DONDE sacas el evento "chequear"? No hay trigger ni nada.2) La variable Obtener devuelve "true/false" no devuelve "player" 3) El evento nombre, vos lo pusiste, creyendo QUE IBA A DEVOLVER EL nombre. Si ves la wiki, los trigger devuelven bool, osea sirven para ejecutar algo tanto en client/server. Espero que te sirva. Ok, una cosa que aleguar en mi defensa y otra que preguntar . El evento checker si tiene un trigger en Cliente Leyendo eso, sería imposible, saber si estas muteado tu mismo, de la manera que yo pensaba que quería hacer, osea mediante comprobaciones cada x tiempo¿no? Link to comment
Carlossg Posted May 27, 2012 Share Posted May 27, 2012 Mmm... funciona, pero cuando el player esta unmuted el texto sigue Ponle para que si el isPlayerMuted es false que cambie el texto . Link to comment
Edikosh998 Posted May 27, 2012 Share Posted May 27, 2012 Sabes que carlos, tenes razon. Soy un boludo if x and triggerServerEvent ("checker", v) == true then Pero no pensamo que hay un evento llamado "onPlayerMute" y "onPlayerUnmute", mucho mas facil, no? function onPlayerMut() triggerClientEvent(source,"onMute",source) end addEventHandler("onPlayerMute",root,onPlayerMut) function onPlayerUnMut() triggerClientEvent(source,"unMute",source) end addEventHandler("onPlayerUnmute",root,onPlayerUnMut) Client function onMuted() addEventHandler("onClientRender",root,showing) end addEvent("onMuted",true) addEventHandler("onMuted",root,onMuted) function unMuted() removeEventHandler("onClientRender",root,showing) end addEvent("unMuted",true) addEventHandler("unMuted",root,unMuted) function showing( ) local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) for _, v in ipairs( getElementsByType 'player' ) do tx, ty, tz = getElementPosition( v ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 30.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( v, 1 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 ) if x and triggerServerEvent ("checker", v) == true then dxDrawText( "Muted ", x, y, x, y, tocolor(150, 0, 0), 0.85 + ( 15 - dist ) * 0.02, "pricedown", "center" ) end end end end end Link to comment
Recommended Posts