Jump to content

onPlayerChat


SnoopCat

Recommended Posts

hey hello again im sorry to post a thing like same as others i posted but i need help cuz this time its not working

well i want to do a thing like when a player write somthing on chat plays a sound like a Bip!

here its my code

LUA

function chat (thePlayer) 
     local sound = playSound("chat.mp3",false) 
     setSoundVolume(sound, 0.9) 
end 
   
addEventHandler ( "onPlayerChat", getLocalPlayer(), chat ) 
  
  

META

<meta> 
 <info author="$VL$FuGa" description="this script plays sound when player chats" info="mod" type="misc" version="1.0.4" /> 
    <script src="sonido.lua" type="client"/> 
        <file src="chat.mp3" /> 
</meta> 
  

Link to comment

you are messing server event with client functions this won't work of course, you can do triggerClientEvent

server:

  
function chat (thePlayer) 
triggerClientEvent("sonido",getRootElement()) 
end 
addEventHandler ( "onPlayerChat", getRootElement(), chat ) 

 

client:

 

function playSonido() 
local sound = playSound("chat.mp3",false) 
setSoundVolume(sound, 0.9) 
end 
addEvent("sonido",true) 
addEventHandler("sonido",getRootElement(),playSonido) 

meta:

<meta> 
 <info author="$VL$FuGa" description="this script plays sound when player chats" info="mod" type="misc" version="1.0.4" /> 
    <script src="sonidoC.lua" type="client"/> 
    <script src="sonidoS.lua" type="server"/> 
        <file src="chat.mp3" /> 
</meta> 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...