Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System
- Imports System.Windows.Forms
- Imports GTA
- Imports System.IO
- Public Class SoundsDemo
- Inherits Script
- private bSOn as boolean = false
- Private l As Int32 = 0
- Private linhas As String()
- Private effect As Int32
- private coef as int16 = 1
- private effectSize as double = 1.0
- private sFilter as string = ""
- private xRot, yRot, zRot as double
- private bRadians as boolean
- private soundID as int32 = 0
- private actualSound as string = ""
- private actualSoundBack as string = ""
- private soundPos as vector3
- dim f As File
- Public Sub New()
- Me.Interval = 100
- linhas = f.ReadAllLines(".\scripts\sounds.txt")
- f.WriteAllLines(".\scripts\sounds.txt.back", linhas)
- End Sub
- private sub console_CMD(ByVal sender As Object, ByVal e As ConsoleEventArgs) Handles MyBase.ConsoleCommand
- if e.command = "sd" then
- bSOn = not bSOn
- if bSOn then
- msg("SoundsDemo ON", 3000)
- else
- msg("SoundsDemo OFF", 3000)
- end if
- end if
- if e.command = "sfilter" then
- if not bSOn then exit sub
- if e.parameterCount = 0 then
- game.console.print("Sound filter: " & sFilter)
- else
- sFilter = e.parameter(0).tolower
- l = 0
- end if
- end if
- end sub
- Private Sub msg(ByVal smsg As String, ByVal duracao As int32)
- Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", smsg, duracao, 1)
- End Sub
- Private Function findLinePos
- For c As Int32 = 0 to linhas.length - 1
- If linhas(c) = actualSoundBack then Return c
- next
- Return 0
- End Function
- Shadows Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown
- if not bSOn then exit sub
- If e.Key = Keys.Right Then nextL()
- If e.Key = Keys.Left Then priorL()
- if e.key = keys.back then
- actualSound = actualSound.substring(0, actualSound.length - 1)
- playEffect(false, actualSound)
- end if
- if e.key = keys.numpad9 then
- linhas(findLinePos) = actualSound
- f.WriteAllLines(".\scripts\sounds.txt", linhas)
- msg("saving...", 1000)
- end if
- if e.key = keys.numpad0 then
- coef = 0
- playEffect(false, actualSound)
- msg("Replay: " & actualSound, 5000)
- end if
- if e.key = keys.numpad1 then
- native.function.call("stop_sound", soundID)
- end if
- End Sub
- private sub playEffect(optional bNavigating as boolean = true, optional sTmpString as string = "")
- if not bSOn then exit sub
- Dim sTmp As String
- if sTmpString = "" then
- sTmp = lerLinha
- else
- sTmp = sTmpString
- end if
- If sTmp.Length > 0 Then
- if not bNavigating then
- soundPos = player.character.position
- native.function.call("stop_sound", soundID)
- native.function.call(of int32)("release_sound_id", soundID)
- soundID = native.function.call(of int32)("get_sound_id")
- native.function.call("PLAY_SOUND_FROM_position", soundID, sTmp, soundPos.x, soundPos.y, soundPos.z)
- end if
- actualSound = sTmp
- if sTmpString = "" then actualSoundBack = sTmp
- msg(sTmp, 5000)
- End If
- end sub
- Private Function lerLinha
- if not bSOn then exit function
- Dim sTmp As String
- sTmp = ""
- While sTmp = ""
- l += coef
- If l < 0 Then
- l = 0
- Exit While
- End If
- If l > linhas.Length - 1 Then
- l = linhas.Length - 1
- Exit While
- End If
- sTmp = linhas(l)
- If (sTmp.Trim.Length > 0) andalso ((sfilter = "") orelse ((sfilter <> "") andalso sTmp.tolower.contains(sfilter.tolower))) then
- Exit While
- else
- sTmp = ""
- End If
- End While
- Return sTmp.Trim
- End Function
- Private Sub nextL()
- coef = 1
- playEffect(false)
- End Sub
- Private Sub priorL()
- coef = -1
- playEffect(false)
- End Sub
- Private Sub GraphicsEventHandler(ByVal sender As Object, ByVal e As GTA.GraphicsEventArgs) Handles mybase.PerFrameDrawing
- if bSon then
- e.graphics.drawtext("Sounds demo - Use left/right to navigate, press numpad0 to play and numpad1 to stop", 10, 10)
- e.graphics.drawtext("Sound: " & actualSound, 10, 35)
- e.graphics.drawtext("Distance from sound: " & soundPos.distanceto(player.character.position).tostring, 10, 60)
- e.graphics.drawtext("Filter: " & sFilter, 10, 90)
- e.graphics.drawtext("* Use backspace to remove last character from sound string and retest the sound", 10, 135)
- e.graphics.drawtext("* if its correct, press numpad9 to save the file sounds.txt", 10, 165)
- end if
- end sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement