Jump to content
Mr. Green Gaming

MTA Local sound script


Recommended Posts

EDIT:

Got the sound working. But it's low range. Read the bottom of the post pl0x.

Hi.

For my new map I need a script that plays local sounds and then, when you're in range of the coordinates you can hear the mp3 playing. Though I'm an absolute noob on scripting shizzle, I needz sum helpz

SDK is already trying to help me, so thnx to him I found this:

http://wiki.multitheftauto.com/wiki/PlaySound3D

So I created localsound1.lua which has this line in it:

playSound3D("sounds/crysis.mp3", 4243, -932, 460, true)

My mp3 is inside a folder and the mp3 is called Crysis, so that should work right?

Then I edited the meta so it looks like this


<meta>
<info gamemodes="race" type="map" name="DDestruction Race by Cookie" author="Cookie" version="1.0" description="Ruuuuuuun fucking ruuuuuuuuun" />
<map src="aa9.map" dimension="0" />
<settings>
<setting name="#skins" value='[ "cj" ]' />
<setting name="#maxplayers" value="[ 32 ]" />
<setting name="#gamespeed" value="[ 1 ]" />
<setting name="#ghostmode" value='[ "false" ]' />
<setting name="#time" value="1:0" />
<setting name="#vehicleweapons" value='[ "false" ]' />
<setting name="#minplayers" value="[ 0 ]" />
<setting name="#weather" value="[ 7 ]" />
<setting name="#gravity" value="[ 0.008000 ]" />
<setting name="#waveheight" value="[ 0 ]" />
<setting name="#respawntime" value="[ 5 ]" />
<setting name="#locked_time" value="[ false ]" />
<setting name="#duration" value="[ 1800 ]" />
<setting name="#respawn" value='[ "timelimit" ]' />
</settings>
<script src="localsound1.lua" type="client" />
</meta>

Though when I test the map I can't hear shit. In testing mode nor construct mode. What am I doing wrong?

EDIT:

It's working. I forgot to put

<file src="files/music.mp3" />

Into the meta.

It's range is very low though. How do I increase the range?

Edited by Cookie
Link to comment

Yes i'm figuring that out atm, but I have no clue how it works.

So I have this in my localsound1.lua

playSound3D("sounds/crysis.mp3", 4243, -932, 460, true)

If I want a wider range, what do I need to put beneath it?

something like:

setSoundMaxDistance ( "localsound1.lua", 50 )

Or something?

Edited by Cookie
Link to comment

Thnx it works now!

Now I need another script that triggers a moving object. Is that easy to do? I already made the moving object. Now when you drive on it, (for example) it leaves in 10 seconds.

This is the moving object:

function omg_lift3()
lift3 = createObject(10789, 4186.8369140625, -938.10723876953, 616.61059570313, 0, 0, 69.818115234375)
omgMovelift3(1)
end

function omgMovelift3(point)
if point == 1 then
moveObject(lift3, 30000, 4186.8369140625, -938.10723876953, 457.21499633789, 0, 0, 0)
setTimer(omgMovelift3, 30000+6000, 1, 2)
elseif point == 2 then
moveObject(lift3, 30000, 4186.8369140625, -938.10723876953, 616.61059570313, 0, 0, 0)
setTimer(omgMovelift3, 30000+6000, 1, 1)
end
end

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), omg_lift3)

Edited by Cookie
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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