Jump to content

marker causes sound script


Recommended Posts

Posted

Hello guys :D

Im new in this forum and i really need your help :oops:

I don't know how to script in Lua and i don't even want to learn it, because i'm skilled enough in VBS,GTA modding and HTML...

the thing is: i'd like to have a script for my upcoming server:

when you're driving as a player with the freight train thorugh markers which are located on the tracks

there should be caused a mp3 sound which will be played at the exact same time at the next train station

but the marker would be a client and the soundplayer would be a script

please, i really need your help :oops:

i'd really appreciate it, as a countermove i would give you a customized modded original car from the original car list

for example that theres written on a car something like "Big City reallife" or a "flash" stretch limousine :)

please answer, i'd appreciate any answer

Posted
We don't accept requests here, and if you already come by "I don't even want to learn", well, you're in the wrong forum then.

:o i mean mean,i have to lean it but i dont know how?Lua is like VBS and i can speak VBS

please im ready to learn if i must to do it :oops:

Posted
It should be, but since trains aren't synced, you'll have to do some tricks I think.

how to get it work?

function MarkerHit( hitElement, matchingDimension ) 
if hitElement== getLocalPlayer() then 
outputChatBox( "warned train station" ) 
end 
addEventHandler("onClientMarkerHit", getLocalPlayer(), MarkerHit) 
  
function playHBFMusic() 
local uSound = playSound3D( 'sound/sirene.mp3', -1901.9541015625, 341.8291015625, 43.750392913818 )  
setSoundMaxDistance( uSound, 3000 ) 
setSoundMinDistance( uSound, 1000 ) 
end 
addEventHandler("onClientResourceStart", getRootElement(), playHBFMusic) 

Posted

Your errors :

- The root of "onClientMarkerHit" can be the root element or a marker ( can't be a player ) .

- You're missing an "end" for the "if" at the first function .

* And the "onClientResourceStart", If set the root of it to the root element, The function will be called every time a resource starts ( any resource ) .

You should use getResourceRootElement instead .

Posted
  
local hi = createMarker ( 0, 0, 2, "cylinder", 1.5, 255, 255, 0, 170 ) -- This its the Marker 
  
function MarkerHit( hitElement, matchingDimension ) 
outputChatBox( "warned train station", source, 255, 255, 255, 255, false ) -- This output send on player hit the marker (hi) 
end 
addEventHandler("onClientMarkerHit", hi, MarkerHit)  
  
function playHBFMusic() 
local uSound = playSound3D( 'sound/sirene.mp3', -1901.9541015625, 341.8291015625, 43.750392913818 ) 
setSoundMaxDistance( uSound, 3000 ) 
setSoundMinDistance( uSound, 1000 ) 
end 
addEventHandler("onClientResourceStart", getRootElement(), playHBFMusic) 

Posted
  
local hi = createMarker ( 0, 0, 2, "cylinder", 1.5, 255, 255, 0, 170 ) -- This its the Marker 
  
function MarkerHit( hitElement, matchingDimension ) 
outputChatBox( "warned train station", source, 255, 255, 255, 255, false ) -- This output send on player hit the marker (hi) 
end 
addEventHandler("onClientMarkerHit", hi, MarkerHit)  
  
function playHBFMusic() 
local uSound = playSound3D( 'sound/sirene.mp3', -1901.9541015625, 341.8291015625, 43.750392913818 ) 
setSoundMaxDistance( uSound, 3000 ) 
setSoundMinDistance( uSound, 1000 ) 
end 
addEventHandler("onClientResourceStart", getRootElement(), playHBFMusic) 

OutputchatBox function there's no player text visible argument. Also read Pain's code again.

Posted
-- Client Side ! 
local marker = createMarker ( 0, 0, 2, "cylinder", 1.5, 255, 255, 0, 170 ) 
  
function MarkerHit( hitElement, matchingDimension ) 
    if ( hitElement == getLocalPlayer() )  then 
        outputChatBox( "warned train station" ) 
    end 
end 
addEventHandler( "onClientMarkerHit",marker,MarkerHit,false ) 
  
function playHBFMusic() 
        local uSound = playSound3D( 'sound/sirene.mp3', -1901.9541015625, 341.8291015625, 43.750392913818 )  
        setSoundMaxDistance( uSound, 3000 ) 
        setSoundMinDistance( uSound, 1000 ) 
end 
addEventHandler( "onClientResourceStart",resourceRoot, playHBFMusic ) 

Use it client side make sure the sound is added to meta .

Posted

Use it client side make sure the sound is added to meta .

thanks but it play my sound when i start the script not if the freight hit the marker it comes only my outputchatbox

    -- Client Side ! 
    local marker = createMarker ( -1873.587890625, -1262.5078125, 15.474542617798, "cylinder", 1.5, 255, 255, 0, 170 ) 
      
    function MarkerHit( hitElement, matchingDimension ) 
        if ( hitElement == getLocalPlayer() )  then 
            outputChatBox( "Zugstation wurde gewarnt!" ) 
        end 
    end 
    addEventHandler( "onClientMarkerHit",marker,MarkerHit,false ) 
      
    function playHBFMusic() 
            local uSound = playSound3D( 'ansage/ansage.mp3',-1937.876953125, 128.0166015625, 26.273441314697 ) 
            setSoundMaxDistance( uSound, 10000 ) 
            setSoundMinDistance( uSound, 5000 ) 
    end 
    addEventHandler( "onClientResourceStart",resourceRoot, playHBFMusic ) 
     

how i can make to play the sound when the freight hit the marker? :?: thanks for your code :wink: but not fix :(

Posted

Not sure but i think you want this :

-- Client Side ! 
local marker = createMarker ( -1873.587890625, -1262.5078125, 15.474542617798, "cylinder", 1.5, 255, 255, 0, 170 ) 
  
function MarkerHit( hitElement, matchingDimension ) 
    if ( hitElement == getLocalPlayer() )  then 
    if uSound and isElement ( uSound ) then destroyElement ( 
    uSound 
    ) 
    end 
        uSound = playSound3D( 'ansage/ansage.mp3',-1937.876953125, 128.0166015625, 26.273441314697 ) 
        setSoundMaxDistance( uSound, 10000 ) 
        setSoundMinDistance( uSound, 5000 ) 
        outputChatBox( "Zugstation wurde gewarnt!" ) 
    end 
end 
addEventHandler( "onClientMarkerHit",marker,MarkerHit,false ) 
  

Posted
Not sure but i think you want this :
-- Client Side ! 
local marker = createMarker ( -1873.587890625, -1262.5078125, 15.474542617798, "cylinder", 1.5, 255, 255, 0, 170 ) 
  
function MarkerHit( hitElement, matchingDimension ) 
    if ( hitElement == getLocalPlayer() )  then 
    if uSound and isElement ( uSound ) then destroyElement ( 
    uSound 
    ) 
    end 
        uSound = playSound3D( 'ansage/ansage.mp3',-1937.876953125, 128.0166015625, 26.273441314697 ) 
        setSoundMaxDistance( uSound, 10000 ) 
        setSoundMinDistance( uSound, 5000 ) 
        outputChatBox( "Zugstation wurde gewarnt!" ) 
    end 
end 
addEventHandler( "onClientMarkerHit",marker,MarkerHit,false ) 
  

OMG THANKS ALOT :D But tell me your idea of a custom gta car and it is still possible the marker utilizable only for trains to pacemakers?i mean the freight :D

  • 3 weeks later...
Posted
You're welcome , No idea.

Now i just test it with a friend! :D but he doesnt hear the sound :( what is the problem :?:

Edit: find my train horn topic is locked :o

the same problem on the train horn script. No player hear the horn only the player who takes the horn :(

any ideas?

how to unlock a topic?

Posted
Because it's client side return for the local player .. Ask solid snake.

clientsite=for everyone :o i think it was that! :shock:

but local player is not the mp player :?:

hööö? now I'm confused :?

i mean like a real train station speaker

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...