Advertisement
JeffryUGP

[jTool] Offline Map Konverter

Apr 13th, 2015
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '-------------------------------------------------------------------------'
  2. '                                                                         '
  3. '                     [jTool] - Offline Map Konverter                     '
  4. '                            jMapKonverter.vbs                            '
  5. '                                                                         '
  6. '                         Version 1.0 - 13.04.2015                        '
  7. '                                                                         '
  8. '                                © Jeffry                                 '
  9. '                                                                         '
  10. '-------------------------------------------------------------------------'
  11.  
  12. '======================================================================================'
  13. 'Für Änderungen am Ausgabe-Layout die Einstellungen hier vornehmen:                    '
  14. '======================================================================================'
  15. objectOutStr = "CreateDynamicObject($model, $x, $y, $z, $rx, $ry, $rz);"               '
  16. vehicleOutStr = "CreateVehicle($model, $x, $y, $z, $ra, $color1, $color2, -1);"        '
  17. pickupOutStr = "AddStaticPickup($model, $x, $y, $z);"                                  '
  18. '======================================================================================'
  19.  
  20.  
  21.  
  22. Set fs = CreateObject("Scripting.FileSystemObject")
  23. pfad = fs.GetParentFolderName(Wscript.ScriptFullName)
  24.  
  25. objects = 0
  26. vehicles = 0
  27. pickups = 0
  28. allobjects = 0
  29. allvehicles = 0
  30. allpickups = 0
  31. emptystr = "                                 "
  32. findstr = ""
  33.  
  34. out_id = ""
  35. out_x = ""
  36. out_y = ""
  37. out_z = ""
  38. out_rx = ""
  39. out_ry = ""
  40. out_rz = ""
  41. out_col1 = ""
  42. out_col2 = ""
  43. out_type = ""
  44.  
  45. Set sDir = fs.getfolder(pfad)
  46. For Each file In sDir.Files
  47.     If LCase(Right(file.path, 4)) = ".map" Then
  48.         fail = 0
  49.         Set rFile = fs.OpenTextFile(file.path, 1)
  50.         Set wFile = fs.CreateTextFile(Left(file.path, Len(file.path)-3) & "txt", True)
  51.         Do While rFile.AtEndOfStream <> True
  52.             str = rFile.ReadLine
  53.             If InStr(str, "<object id") > 0 And InStr(str, "</object>") > 0 Then
  54.                 objects = objects + 1
  55.                 findstr = "id="""
  56.                 find = InStr(str, findstr)+Len(findstr)
  57.                 out_type = Mid(str, find, InStr(find, str, """")-find)
  58.                 findstr = "model="""
  59.                 find = InStr(str, findstr)+Len(findstr)
  60.                 out_id = Mid(str, find, InStr(find, str, """")-find)
  61.                 findstr = "posX="""
  62.                 find = InStr(str, findstr)+Len(findstr)
  63.                 out_x = Mid(str, find, InStr(find, str, """")-find)
  64.                 If InStr(out_x, ".") = 0 Then out_x = out_x & ".0"
  65.                 findstr = "posY="""
  66.                 find = InStr(str, findstr)+Len(findstr)
  67.                 out_y = Mid(str, find, InStr(find, str, """")-find)
  68.                 If InStr(out_y, ".") = 0 Then out_y = out_y & ".0"
  69.                 findstr = "posZ="""
  70.                 find = InStr(str, findstr)+Len(findstr)
  71.                 out_z = Mid(str, find, InStr(find, str, """")-find)
  72.                 If InStr(out_z, ".") = 0 Then out_z = out_z & ".0"
  73.                 findstr = "rotX="""
  74.                 find = InStr(str, findstr)+Len(findstr)
  75.                 out_rx = Mid(str, find, InStr(find, str, """")-find)
  76.                 If InStr(out_rx, ".") = 0 Then out_rx = out_rx & ".0"
  77.                 findstr = "rotY="""
  78.                 find = InStr(str, findstr)+Len(findstr)
  79.                 out_ry = Mid(str, find, InStr(find, str, """")-find)
  80.                 If InStr(out_ry, ".") = 0 Then out_ry = out_ry & ".0"
  81.                 findstr = "rotZ="""
  82.                 find = InStr(str, findstr)+Len(findstr)
  83.                 out_rz = Mid(str, find, InStr(find, str, """")-find)
  84.                 If InStr(out_rz, ".") = 0 Then out_rz = out_rz & ".0"
  85.                 str = objectOutStr
  86.                 str = Replace(str, "$model", out_id)
  87.                 str = Replace(str, "$x", out_x)
  88.                 str = Replace(str, "$y", out_y)
  89.                 str = Replace(str, "$z", out_z)
  90.                 str = Replace(str, "$rx", out_rx)
  91.                 str = Replace(str, "$ry", out_ry)
  92.                 str = Replace(str, "$rz", out_rz)
  93.                 str = str & " //" & Replace(Replace(out_type, "(", "["), ")", "]")
  94.                 wFile.WriteLine str
  95.             End If
  96.         Loop
  97.         rFile.Close
  98.         Set rFile = fs.OpenTextFile(file.path, 1)
  99.         Do While rFile.AtEndOfStream <> True
  100.             str = rFile.ReadLine
  101.             If InStr(str, "<vehicle id") > 0 And InStr(str, "</vehicle>") > 0 Then
  102.                 vehicles = vehicles + 1
  103.                 findstr = "id="""
  104.                 find = InStr(str, findstr)+Len(findstr)
  105.                 out_type = Mid(str, find, InStr(find, str, """")-find)
  106.                 findstr = "model="""
  107.                 find = InStr(str, findstr)+Len(findstr)
  108.                 out_id = Mid(str, find, InStr(find, str, """")-find)
  109.                 findstr = "posX="""
  110.                 find = InStr(str, findstr)+Len(findstr)
  111.                 out_x = Mid(str, find, InStr(find, str, """")-find)
  112.                 If InStr(out_x, ".") = 0 Then out_x = out_x & ".0"
  113.                 findstr = "posY="""
  114.                 find = InStr(str, findstr)+Len(findstr)
  115.                 out_y = Mid(str, find, InStr(find, str, """")-find)
  116.                 If InStr(out_y, ".") = 0 Then out_y = out_y & ".0"
  117.                 findstr = "posZ="""
  118.                 find = InStr(str, findstr)+Len(findstr)
  119.                 out_z = Mid(str, find, InStr(find, str, """")-find)
  120.                 If InStr(out_z, ".") = 0 Then out_z = out_z & ".0"
  121.                 findstr = "rotZ="""
  122.                 find = InStr(str, findstr)+Len(findstr)
  123.                 out_rz = Mid(str, find, InStr(find, str, """")-find)
  124.                 If InStr(out_rz, ".") = 0 Then out_rz = out_rz & ".0"
  125.                 findstr = "color="""
  126.                 find = InStr(str, findstr)+Len(findstr)
  127.                 out_col1 = Mid(str, find, InStr(find, str, ",")-find)
  128.                 find = InStr(find, str, ",")+1
  129.                 out_col2 = Mid(str, find, InStr(find, str, ",")-find)
  130.                 str = vehicleOutStr
  131.                 str = Replace(str, "$model", out_id)
  132.                 str = Replace(str, "$x", out_x)
  133.                 str = Replace(str, "$y", out_y)
  134.                 str = Replace(str, "$z", out_z)
  135.                 str = Replace(str, "$ra", out_rz)
  136.                 str = Replace(str, "$color1", out_col1)
  137.                 str = Replace(str, "$color2", out_col2)
  138.                 str = str & " //" & Replace(Replace(out_type, "(", "["), ")", "]")
  139.                 wFile.WriteLine str
  140.             End If
  141.         Loop
  142.         rFile.Close
  143.         Set rFile = fs.OpenTextFile(file.path, 1)
  144.         Do While rFile.AtEndOfStream <> True
  145.             str = rFile.ReadLine
  146.             If InStr(str, "<pickup id") > 0 And InStr(str, "</pickup>") > 0 Then
  147.                 pickups = pickups + 1
  148.                 findstr = "id="""
  149.                 find = InStr(str, findstr)+Len(findstr)
  150.                 out_type = Mid(str, find, InStr(find, str, """")-find)
  151.                 findstr = "type="""
  152.                 find = InStr(str, findstr)+Len(findstr)
  153.                 out_id = Mid(str, find, InStr(find, str, """")-find)
  154.                 findstr = "posX="""
  155.                 find = InStr(str, findstr)+Len(findstr)
  156.                 out_x = Mid(str, find, InStr(find, str, """")-find)
  157.                 If InStr(out_x, ".") = 0 Then out_x = out_x & ".0"
  158.                 findstr = "posY="""
  159.                 find = InStr(str, findstr)+Len(findstr)
  160.                 out_y = Mid(str, find, InStr(find, str, """")-find)
  161.                 If InStr(out_y, ".") = 0 Then out_y = out_y & ".0"
  162.                 findstr = "posZ="""
  163.                 find = InStr(str, findstr)+Len(findstr)
  164.                 out_z = Mid(str, find, InStr(find, str, """")-find)
  165.                 If InStr(out_z, ".") = 0 Then out_z = out_z & ".0"
  166.                 Select case out_id
  167.                     case "10": out_id = "321" 'Dildo
  168.                     case "11": out_id = "322" 'Dildo
  169.                     case "12": out_id = "323" 'Vibrator
  170.                     case "13": out_id = "324" 'Vibrator
  171.                     case "14": out_id = "325" 'Flower
  172.                     case "15": out_id = "326" 'Cane
  173.                     case "1": out_id = "331" 'Brassknuckle
  174.                     case "2": out_id = "333" 'Golfclub
  175.                     case "3": out_id = "334" 'Nightstick
  176.                     case "4": out_id = "335" 'Knife
  177.                     case "5": out_id = "336" 'Bat
  178.                     case "6": out_id = "337" 'Shovel
  179.                     case "7": out_id = "338" 'Poolstick
  180.                     case "8": out_id = "339" 'Katana
  181.                     case "9": out_id = "341" 'Chainsaw
  182.                     case "16": out_id = "342" 'Grenade
  183.                     case "17": out_id = "343" 'Teargas
  184.                     case "18": out_id = "344" 'Molotov
  185.                     case "22": out_id = "346" 'Colt 45
  186.                     case "23": out_id = "347" 'Silenced
  187.                     case "24": out_id = "348" 'Deagle
  188.                     case "25": out_id = "349" 'Shotgun
  189.                     case "26": out_id = "350" 'Sawed-off
  190.                     case "27": out_id = "351" 'Combat Shotgun
  191.                     case "28": out_id = "352" 'UZI
  192.                     case "29": out_id = "353" 'MP5
  193.                     case "30": out_id = "355" 'AK-47
  194.                     case "31": out_id = "356" 'M4
  195.                     case "33": out_id = "357" 'Rifle
  196.                     case "34": out_id = "358" 'Sniper
  197.                     case "35": out_id = "359" 'Rocket Launcher
  198.                     case "36": out_id = "360" 'Rocket Launcher HS
  199.                     case "37": out_id = "361" 'Flamethrower
  200.                     case "38": out_id = "362" 'Minigun
  201.                     case "39": out_id = "363" 'Satchel
  202.                     case "40": out_id = "364" 'Bomb
  203.                     case "41": out_id = "365" 'Spraycan
  204.                     case "42": out_id = "366" 'Fire Extinguisher
  205.                     case "43": out_id = "367" 'Camera
  206.                     case "44": out_id = "368" 'Nightvision
  207.                     case "45": out_id = "369" 'Infrared
  208.                     case "46": out_id = "371" 'Parachute
  209.                     case "32": out_id = "372" 'Tec-9
  210.                     case "health": out_id = "1240" 'Health
  211.                     case "armor": out_id = "1242" 'Armor
  212.                     case else: out_id = "???" 'Unknown?
  213.                 End Select
  214.                 str = pickupOutStr
  215.                 str = Replace(str, "$model", out_id)
  216.                 str = Replace(str, "$x", out_x)
  217.                 str = Replace(str, "$y", out_y)
  218.                 str = Replace(str, "$z", out_z)
  219.                 str = str & " //" & Replace(Replace(out_type, "(", "["), ")", "]")
  220.                 wFile.WriteLine str
  221.             End If
  222.         Loop
  223.         wFile.WriteLine ""
  224.         str = "/*************************************************"
  225.         wFile.WriteLine str
  226.         str = "* Die folgenden Items wurden konvertiert:        *"
  227.         wFile.WriteLine str
  228.         If objects = 1 Then
  229.             str = ""
  230.         Else:
  231.             str = "e"
  232.         End If
  233.         str = "*     - " & objects & " Objekt" & str & " " & Left(emptystr, 33-Len(objects)-Len(str)) & "*"
  234.         wFile.WriteLine str
  235.         If vehicles = 1 Then
  236.             str = ""
  237.         Else:
  238.             str = "e"
  239.         End If
  240.         str = "*     - " & vehicles & " Fahrzeug" & str & " " & Left(emptystr, 31-Len(vehicles)-Len(str)) & "*"
  241.         wFile.WriteLine str
  242.         If pickups = 1 Then
  243.             str = ""
  244.         Else:
  245.             str = "s"
  246.         End If
  247.         str = "*     - " & pickups & " Pickup" & str & " " & Left(emptystr, 33-Len(pickups)-Len(str)) & "*"
  248.         wFile.WriteLine str
  249.         str = "*                                                *"
  250.         wFile.WriteLine str
  251.         str = "* Datum: " & Date() & " - " & Time() & "                   *"
  252.         wFile.WriteLine str
  253.         str = "* Konvertiert durch jTool - jMapKonverter.vbs    *"
  254.         wFile.WriteLine str
  255.         str = "*************************************************/"
  256.         wFile.WriteLine str
  257.         wFile.Close
  258.         allobjects = allobjects + objects
  259.         allvehicles = allvehicles + vehicles
  260.         allpickups = allpickups + pickups
  261.     End If
  262. Next
  263.  
  264. str = Chr(10) & "Die Konvertierung wurde erfolgreich abgeschlossen!" & Chr(10) & Chr(10) & "Es wurden folgende Items konvertiert:" & Chr(10)
  265. If allobjects = 1 Then
  266.     emptystr = ""
  267. Else:
  268.     emptystr = "e"
  269. End If
  270. str = str & "    - " & allobjects & " Objekt" & emptystr & Chr(10)
  271. If allvehicles = 1 Then
  272.     emptystr = ""
  273. Else:
  274.     emptystr = "e"
  275. End If
  276. str = str & "    - " & allvehicles & " Fahrzeug" & emptystr & Chr(10)
  277. If allpickups = 1 Then
  278.     emptystr = ""
  279. Else:
  280.     emptystr = "s"
  281. End If
  282. str = str & "    - " & allpickups & " Pickup" & emptystr & Chr(10) & Chr(10) & Chr(10)
  283. str = str & "Vielen Dank f" & Chr(252) & "r die Verwendung von jTool - jMapKonverter.vbs!" & Chr(10)
  284. str = str & Chr(169) & "Jeffry - April 2015"
  285. Msgbox str, vbInformation , "Konvertierung erfolgreich!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement