Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'https://www.youtube.com/user/GTAScripting
- 'http://gtaxscripting.blogspot.com/
- 'http://www.facebook.com/GtaIVScripting
- 'https://twitter.com/julionib
- Imports System
- Imports System.Drawing
- Imports System.Windows.Forms
- Imports GTA
- Imports System.IO
- Imports System.Text
- Public Class BaseScriptProject
- Inherits Script
- Private iniFile As String = ".\Scripts\MyCustomINI.ini"
- Private model_name As String
- Private anFloatValue As Double
- Private hkActivate As Keys
- Private infoFromCustomINI As String
- Private Function ReadIniString(opt As String, cat As String, def As String) As String
- If Settings.GetValueString(opt, cat, "") = "" Then Settings.SetValue(opt, cat, def)
- Return Settings.GetValueString(opt, cat, def)
- End Function
- Private Function ReadIniKey(opt As String, cat As String, def As Keys) As Keys
- If Settings.GetValueString(opt, cat, "") = "" Then Settings.SetValue(opt, cat, def)
- Return Settings.GetValueKey(opt, cat, def)
- End Function
- Public Sub New()
- Me.Interval = 10
- model_name = ReadIniString("name_1", "models", "none")
- anFloatValue = Double.Parse(ReadIniString("multiplier", "explosion", "1.0"))
- hkActivate = ReadIniKey("activate", "hotkeys", Keys.D0)
- Settings.Save()
- 'read custom INI file:
- checkIniExists()
- infoFromCustomINI = ReadINI("test", "category", "")
- If infoFromCustomINI = "" Then WriteINI("test", "category", "default value")
- 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 Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown
- End Sub
- Private Sub keyUp(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyUp
- End Sub
- Private Sub general_tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick
- End Sub
- Private Sub console_CMD(ByVal sender As Object, ByVal e As ConsoleEventArgs) Handles MyBase.ConsoleCommand
- End Sub
- Private Sub GraphicsEventHandler(ByVal sender As Object, ByVal e As GTA.GraphicsEventArgs) Handles MyBase.PerFrameDrawing
- End Sub
- Private Declare Auto Function GetPrivateProfileString Lib "Kernel32" _
- (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As StringBuilder,
- ByVal nSize As Integer, ByVal lpFileName As String) As Integer
- Private Declare Auto Function WritePrivateProfileString Lib "Kernel32" _
- (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
- Private Function ReadINI(ByVal key_name As String, ByVal section_name As String, ByVal default_value As String) As String
- Const MAX_LENGTH As Integer = 500
- Dim string_builder As New StringBuilder(MAX_LENGTH)
- GetPrivateProfileString(section_name, key_name, default_value, string_builder, MAX_LENGTH, iniFile)
- Return string_builder.ToString()
- End Function
- Private Sub WriteINI(ByVal key_name As String, ByVal section_name As String, ByVal value As String)
- WritePrivateProfileString(section_name, key_name, value, iniFile)
- End Sub
- Private Sub checkIniExists()
- If Not File.Exists(iniFile) Then
- File.CreateText(iniFile).Dispose()
- Wait(100)
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement