Blackvein Posted July 12, 2010 Posted July 12, 2010 I have a simple script that displays local text in the chatbox when a player walks into it, and it works fine. Now I want to make it so it plays a .wav file when a player walks into it. I don't see the problem in my script, but obviously there is one. Here it is: function markerHit( hitPlayer, matchingDimension ) if (source == marker1) then outputChatBox ( "" .. text1a .. "", hitPlayer, 0, 255, 0 ) outputChatBox ( "" .. text1b .. "", hitPlayer, 0, 255, 0 ) outputChatBox ( "" .. text1c .. "", hitPlayer, 255, 0, 0 ) elseif (source == marker2) then outputChatBox ( "" .. text2a .. "", hitPlayer, 0, 255, 0 ) outputChatBox ( "" .. text2b .. "", hitPlayer, 0, 255, 0 ) [color=#FF0000]elseif (source == marker3) then [/color] [color=#FF0000]outputChatBox ( "" .. text3a .. "", hitPlayer, 0, 255, 0 )[/color] [color=#FF0000]local sound = playSound("distress.wav",false)[/color] end end addEventHandler ( "onMarkerHit", getRootElement(), markerHit ) Upon hitting marker 3, text3a is displayed, but distress.wav is not played. I checked the server console, and the following error was returned: [2010-07-11 20:18:59] ERROR: TextMarkers/script.lua:22: attempt to call global 'playSound' (a nil value) Any help would be greatly appreciated!
Castillo Posted July 12, 2010 Posted July 12, 2010 its because playSound its a client side function, maybe u can trigger a event to client and then play it.
Blackvein Posted July 12, 2010 Author Posted July 12, 2010 sorry, I'm pretty new to scripting, can you dumb that down a bit? EDIT: The script.lua is set to 'server' in the meta.xml, if I changed that to client, would that help? --> <script src="script.lua" type="server"/>
Castillo Posted July 12, 2010 Posted July 12, 2010 sorry, I'm pretty new to scripting, can you dumb that down a bit? EDIT: The script.lua is set to 'server' in the meta.xml, if I changed that to client, would that help? --> <script src="script.lua" type="server"/> do this, server side: function markerHit( hitPlayer, matchingDimension ) if (source == marker1) then outputChatBox ( "" .. text1a .. "", hitPlayer, 0, 255, 0 ) outputChatBox ( "" .. text1b .. "", hitPlayer, 0, 255, 0 ) outputChatBox ( "" .. text1c .. "", hitPlayer, 255, 0, 0 ) elseif (source == marker2) then outputChatBox ( "" .. text2a .. "", hitPlayer, 0, 255, 0 ) outputChatBox ( "" .. text2b .. "", hitPlayer, 0, 255, 0 ) elseif (source == marker3) then outputChatBox ( "" .. text3a .. "", hitPlayer, 0, 255, 0 ) triggerClientEvent(hitPlayer,"playTheSound",getRootElement()) end end addEventHandler ( "onMarkerHit", getRootElement(), markerHit ) client side: function playIT() local sound = playSound("distress.wav",false) end addEvent( "playTheSound", true ) addEventHandler( "playTheSound", getRootElement(),playIT ) meta.xml <meta> <info name="" author="Blackvein" type="script" version="1.0"/> <script src="scriptclient.lua" type="client" /> <script src="script.lua" type="server" /> <file src="distress.wav" /> </meta>
Castillo Posted July 12, 2010 Posted July 12, 2010 oh ok thanks, ignore the pm i sent ya. Oh, i dont check the PM box much
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