Advertisement
fabi202cool

MTA Converter 0.9

Dec 2nd, 2011
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 5.33 KB | None | 0 0
  1. #cs ----------------------------------------------------------------------------
  2.  
  3.  AutoIt Version: 3.3.6.1
  4.  Author:         fabi202cool
  5.  
  6.  Script Function:
  7.     MTA to PAWN Converter v0.9
  8.  
  9. #ce ----------------------------------------------------------------------------
  10.  
  11. #include <String.au3>
  12. #include <Array.au3>
  13. #include "Ordner.au3"
  14. #include <ButtonConstants.au3>
  15. #include <ComboConstants.au3>
  16. #include <EditConstants.au3>
  17. #include <GUIConstantsEx.au3>
  18. #include <StaticConstants.au3>
  19. #include <WindowsConstants.au3>
  20. #include <GuiEdit.au3>
  21.  
  22. $Form1 = GUICreate("MTA Converter v0.9", 330, 244, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE))
  23. GUISetBkColor(0xFFFFFF)
  24. $Label1 = GUICtrlCreateLabel("MTA Converter", 16, 8, 298, 25)
  25. GUICtrlSetFont(-1, 12, 800, 0, "Blackoak Std")
  26. GUICtrlSetColor(-1, 0x0000FF)
  27. $Edit1 = GUICtrlCreateEdit("", 16, 48, 297, 145)
  28. GUICtrlSetData(-1, "Drop files here...")
  29. $Label2 = GUICtrlCreateLabel("by fabi202cool", 16, 24, 193, 19)
  30. GUICtrlSetFont(-1, 8, 800, 0, "Blackoak Std")
  31. GUICtrlSetColor(-1, 0x00FF00)
  32. $Combo1 = GUICtrlCreateCombo("Select File...", 16, 208, 161, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
  33. GUICtrlSetData(-1, "Select File...")
  34. $Button1 = GUICtrlCreateButton("Convert", 232, 206, 83, 25)
  35. GUISetState(@SW_SHOW)
  36.  
  37. Const $WM_DROPFILES = 0x233
  38. GUIRegisterMsg($WM_DROPFILES, "On_WM_DROPFILES")
  39.  
  40. Dim $ConvertLine[1]
  41. Global $object
  42.  
  43. $RegPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Multi Theft Auto: San Andreas All\1.1","Last Run Location")
  44.  
  45. $dateien = _ordner_rekursiv($RegPath & "\server\mods\deathmatch\resources", 1)
  46.  
  47. For $i=1 To UBound($dateien)-1
  48.     If StringRegExp($dateien[$i][1],".map")=0 Then
  49.         $dateien[$i][0]=""
  50.     EndIf
  51. Next
  52.  
  53. For $i=1 To UBound($dateien)-1
  54.     If $dateien[$i][0] <> "" Then
  55.         GUICtrlSetData($Combo1,$dateien[$i][1])
  56.     EndIf
  57. Next
  58.  
  59. While 1
  60.     $nMsg = GUIGetMsg()
  61.     Switch $nMsg
  62.         Case $GUI_EVENT_CLOSE
  63.             Exit
  64.         Case $Button1
  65.             OpenCombo()
  66.     EndSwitch
  67. WEnd
  68.  
  69. Func OpenCombo()
  70.     $map = GUICtrlRead($Combo1)
  71.     if StringInStr($map,".map") Then
  72.             OpenFile($RegPath & "\server\mods\deathmatch\resources\" & StringTrimRight(GUICtrlRead($Combo1),4) & "\" & $map)
  73.         Else
  74.             MsgBox(0,"Fehler","Es werden nur .map Dateien unterstützt.")
  75.         EndIf
  76. EndFunc
  77.  
  78. Func Object($line)
  79.     $objectline=FileReadLine($FileOpen,$line)
  80.  
  81.     $Bezeichnung=_StringBetween($objectline,'id="','"')
  82.     $ID=_StringBetween($objectline,'model="','"')
  83.     $posX=_StringBetween($objectline,'posX="','"')
  84.     $posY=_StringBetween($objectline,'posY="','"')
  85.     $posZ=_StringBetween($objectline,'posZ="','"')
  86.     $rotX=_StringBetween($objectline,'rotX="','"')
  87.     $rotY=_StringBetween($objectline,'rotY="','"')
  88.     $rotZ=_StringBetween($objectline,'rotZ="','"')
  89.  
  90.     $posX[0]=StringFormat("%f",$posX[0])
  91.     $posY[0]=StringFormat("%f",$posY[0])
  92.     $posZ[0]=StringFormat("%f",$posZ[0])
  93.     $rotX[0]=StringFormat("%f",$rotX[0])
  94.     $rotY[0]=StringFormat("%f",$rotY[0])
  95.     $rotZ[0]=StringFormat("%f",$rotZ[0])
  96.  
  97.     $object &= "CreateObject("&$ID[0]&", "&$posX[0]&", "&$posY[0]&", "&$posZ[0]&", "&$rotX[0]&", "&$rotY[0]&", "&$rotZ[0]&"); //"&$Bezeichnung[0] & @CRLF
  98.  
  99. EndFunc
  100.  
  101. Func Vehicle($line)
  102.     $objectline=FileReadLine($FileOpen,$line)
  103.  
  104.     $Bezeichnung=_StringBetween($objectline,'id="','"')
  105.     $ID=_StringBetween($objectline,'model="','"')
  106.     $posX=_StringBetween($objectline,'posX="','"')
  107.     $posY=_StringBetween($objectline,'posY="','"')
  108.     $posZ=_StringBetween($objectline,'posZ="','"')
  109.     $rotZ=_StringBetween($objectline,'rotZ="','"')
  110.  
  111.     $posX[0]=StringFormat("%f",$posX[0])
  112.     $posY[0]=StringFormat("%f",$posY[0])
  113.     $posZ[0]=StringFormat("%f",$posZ[0])
  114.     $rotZ[0]=StringFormat("%f",$rotZ[0])
  115.  
  116.     $object &= "AddStaticVehicleEx("&$ID[0]&", "&$posX[0]&", "&$posY[0]&", "&$posZ[0]&", "&$rotZ[0]&", -1, -1, 15); //"&$Bezeichnung[0] & @CRLF
  117.  
  118. EndFunc
  119.  
  120. Func OpenFile($Path)
  121.     Global $FileOpen = FileOpen($Path)
  122.     $FileCheck = FileReadLine($FileOpen,1)
  123. If StringRegExp($FileCheck,"<map")=1 Then
  124.     For $i=1 To 999 Step 1
  125.         $LineCheck = FileReadLine($FileOpen,$i)
  126.         If StringRegExp($LineCheck,"<object")=1 Then
  127.             Object($i)
  128.         ElseIf StringRegExp($LineCheck,"<vehicle")=1 Then
  129.             Vehicle($i)
  130.         ElseIf StringRegExp($LineCheck,"</map>")=1 Then
  131.             ExitLoop
  132.         EndIf
  133.     Next
  134.     _GUICtrlEdit_SetText($Edit1,$object)
  135.     ClipPut($object)
  136.     Global $object=""
  137. EndIf
  138. EndFunc
  139.  
  140. Func filter(ByRef $dFiles)
  141.     For $i = 0 To UBound($dFiles)-1
  142.         if StringInStr($dFiles[$i],".map") Then
  143.             OpenFile($dFiles[$i])
  144.         Else
  145.             MsgBox(0,"Fehler","Es werden nur .map Dateien unterstützt.")
  146.         EndIf
  147.     Next
  148. EndFunc
  149.  
  150. Func On_WM_DROPFILES($hWnd, $Msg, $wParam, $lParam)
  151.     Local $tDrop, $i, $aRet, $iCount;
  152.  
  153.     $aRet = DllCall("shell32.dll", "int", "DragQueryFileW", "ptr", $wParam, "uint", -1, "ptr", 0, "uint", 0 )
  154.     $iCount = $aRet[0]
  155.  
  156.     local $aDraggedFiles[$iCount];
  157.     For $i = 0 To $iCount-1
  158.         $aRet = DllCall("shell32.dll", "int", "DragQueryFileW", "ptr", $wParam, "uint", $i, "ptr", 0, "uint", 0)
  159.         Local $tDrop = DllStructCreate("wchar[" & $aRet[0]+1 & "]")
  160.         $aRet = DllCall("shell32.dll", "int", "DragQueryFileW", "ptr", $wParam, "uint", $i, "ptr", DllStructGetPtr($tDrop), "uint", $aRet[0]+1)
  161.         $aDraggedFiles[$i] = DllStructGetData($tDrop, 1);
  162.     Next
  163.  
  164.     DllCall("shell32.dll", "int", "DragFinish", "ptr", $wParam)
  165.  
  166.     filter($aDraggedFiles)
  167. EndFunc
  168.  
  169.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement