Jump to content

Search the Community

Showing results for tags 'onvehicleenter'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 1 result

  1. So, i have a problem, im making a script for replacing sounds of cars, the first car i enter works nice, when i change engine state the sound goes off and on but when left a car on with the replaced sound and try to enter to another car and start the engine, it plays the sound on the last car, so if you do this with more cars, the first car plays a lot of sounds. Sorry my english is a bit :~ty cause im spanish. Heres some lua code, server side local wayfarerenginestate = 0 local timerwayfarersound = {} function OnEnterVehicle ( thePlayer, seat, jacked ) if getElementModel( source ) == 586 then local texture2 local sourcetxt = tostring(source) if string.match(sourcetxt, " ") then local extracted = sourcetxt:match("% .+") texture2 = extracted:gsub("% ","") end outputChatBox( texture2 ) if getElementData( source, "timer") == false then outputChatBox ( "Timer started", thePlayer ) timerwayfarersound[texture2] = setTimer( checkwayfarerenginestate, 500, 0, source, texture2 ) setElementData( source, "timer", true) end end end addEventHandler ( "onVehicleEnter", getRootElement(), OnEnterVehicle ) function checkwayfarerenginestate (source, texture2) if getVehicleEngineState( source ) == true and wayfarerenginestate == 0 then triggerClientEvent( "wayfarersoundcevent", resourceRoot, source, texture2) wayfarerenginestate = 1 elseif getVehicleEngineState( source ) == false and wayfarerenginestate == 1 then triggerClientEvent( "wayfarersounddcevent", resourceRoot, texture2) wayfarerenginestate = 0 end end Client side: local wayfarerenginestate = 0 local wayfarersound = {} function wayfarersoundf ( veh, texture2 ) local x, y, z = getElementPosition( veh ) wayfarersound[texture2] = playSound3D( "sounds/wayfarersound.mp3", x, y, z, true ) setSoundVolume( wayfarersound[texture2], 0.45 ) setSoundMaxDistance( wayfarersound[texture2], 100 ) attachElements( wayfarersound[texture2], veh) end addEvent( "wayfarersoundcevent", true ) addEventHandler( "wayfarersoundcevent", resourceRoot, wayfarersoundf ) function wayfarersounddf (texture2) destroyElement( wayfarersound[texture2] ) end addEvent( "wayfarersounddcevent", true ) addEventHandler( "wayfarersounddcevent", resourceRoot, wayfarersounddf ) What is the problem? Which 1 vehicle it works nice but, which more than 1 it bugs
×
×
  • Create New...