csmit195

Untitled

Jan 24th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.79 KB | None | 0 0
  1. if not fileExists('myVehicles.xml') then
  2.     xmlMain = xmlCreateFile('myVehicles.xml', 'Vehicles')
  3.     xmlSaveFile(xmlMain)
  4.     xmlUnloadFile(xmlMain)
  5. end
  6.  
  7. notAllowedTypes = {'Plane', 'Train', 'Trailer'}
  8.  
  9. GUIEditor = {
  10.     button = {},
  11.     edit = {},
  12.     window = {},
  13.     gridlist = {},
  14.     checkbox = {},
  15.     label = {},
  16.     radiobutton = {},
  17. }
  18. local screenW, screenH = guiGetScreenSize()
  19.  
  20. GUIEditor.window[2] = guiCreateWindow((screenW - 294) / 2, (screenH - 192) / 2, 294, 192, "[+] NEW SAVE", false)
  21. guiWindowSetSizable(GUIEditor.window[2], false)
  22. guiSetVisible(GUIEditor.window[2], false)
  23.  
  24. GUIEditor.edit[2] = guiCreateEdit(86, 28, 197, 25, "", false, GUIEditor.window[2])
  25. GUIEditor.label[2] = guiCreateLabel(10, 28, 64, 24, "Name:", false, GUIEditor.window[2])
  26. guiLabelSetVerticalAlign(GUIEditor.label[2], "center")
  27. GUIEditor.label[3] = guiCreateLabel(10, 57, 64, 24, "Vehicle:", false, GUIEditor.window[2])
  28. guiLabelSetVerticalAlign(GUIEditor.label[3], "center")
  29. GUIEditor.edit[3] = guiCreateEdit(85, 56, 199, 25, "Infernus", false, GUIEditor.window[2])
  30. guiEditSetReadOnly(GUIEditor.edit[3], true)
  31. GUIEditor.checkbox[1] = guiCreateCheckBox(85, 91, 99, 27, "Vehicle Color", true, false, GUIEditor.window[2])
  32. GUIEditor.label[5] = guiCreateLabel(10, 89, 64, 24, "Save:", false, GUIEditor.window[2])
  33. guiLabelSetVerticalAlign(GUIEditor.label[5], "center")
  34. GUIEditor.checkbox[2] = guiCreateCheckBox(188, 91, 91, 27, "Lights Color", true, false, GUIEditor.window[2])
  35. GUIEditor.checkbox[3] = guiCreateCheckBox(85, 123, 98, 27, "Upgrades", true, false, GUIEditor.window[2])
  36. GUIEditor.checkbox[4] = guiCreateCheckBox(187, 123, 89, 27, "Paintjob", true, false, GUIEditor.window[2])
  37. GUIEditor.button[5] = guiCreateButton(207, 155, 72, 27, "[+] ADD", false, GUIEditor.window[2])
  38. guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FFAAAAAA")
  39. GUIEditor.button[6] = guiCreateButton(130, 155, 77, 27, "[x] CANCEL", false, GUIEditor.window[2])
  40. guiSetProperty(GUIEditor.button[6], "NormalTextColour", "FFAAAAAA")
  41.  
  42.  
  43. GUIEditor.window[1] = guiCreateWindow((screenW - 323) / 2, (screenH - 395) / 2, 323, 395, "F5 - Car Manager", false)
  44. guiWindowSetSizable(GUIEditor.window[1], false)
  45. guiSetVisible(GUIEditor.window[1], false)
  46.  
  47. GUIEditor.gridlist[1] = guiCreateGridList(10, 22, 304, 304, false, GUIEditor.window[1])
  48. name = guiGridListAddColumn(GUIEditor.gridlist[1], "Name", 0.3)
  49. vehicle = guiGridListAddColumn(GUIEditor.gridlist[1], "Vehicle", 0.3)
  50. date = guiGridListAddColumn(GUIEditor.gridlist[1], "Date", 0.3)
  51. guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "-", false, false)
  52. guiGridListSetItemText(GUIEditor.gridlist[1], 0, 2, "Blista Compact", false, false)
  53. guiGridListSetItemText(GUIEditor.gridlist[1], 0, 3, "12/12/2222", false, false)
  54. GUIEditor.button[1] = guiCreateButton(234, 331, 79, 28, "Spawn", false, GUIEditor.window[1])
  55. guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
  56. GUIEditor.button[2] = guiCreateButton(10, 331, 79, 28, "[+] NEW", false, GUIEditor.window[1])
  57. guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA")
  58. GUIEditor.button[3] = guiCreateButton(89, 331, 79, 28, "[-] DELETE", false, GUIEditor.window[1])
  59. guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFAAAAAA")
  60. GUIEditor.radiobutton[1] = guiCreateRadioButton(20, 362, 72, 28, "English", false, GUIEditor.window[1])
  61. guiSetProperty(GUIEditor.radiobutton[1], "NormalTextColour", "C8FFFFFF")
  62. GUIEditor.radiobutton[2] = guiCreateRadioButton(101, 362, 71, 28, "Español", false, GUIEditor.window[1])
  63. guiSetProperty(GUIEditor.radiobutton[2], "NormalTextColour", "C8FFFFFF")
  64. guiRadioButtonSetSelected(GUIEditor.radiobutton[2], true)
  65.  
  66. xmlMain = xmlLoadFile('myVehicles.xml')
  67.  
  68. bindKey('F5', 'down', function()
  69.     if not isPedInVehicle(localPlayer) then outputChatBox('You cannot use this command when out of a vehicle! Please enter one.', 255, 0, 0) return end
  70.     if notAllowedTypes[getVehicleType(getPedOccupiedVehicle(localPlayer))] then outputChatBox('That vehicle is in the banlist!', 255, 0, 0) return end
  71.     if not guiGetVisible(GUIEditor.window[1]) then
  72.         for i, v in ipairs(xmlNodeGetChildren(xmlMain)) do
  73.             row = guiGridListAddRow()
  74.             guiGridListSetItemText(GUIEditor.gridlist[1], row, name, xmlNodeGetValue(v))
  75.             guiGridListSetItemText(GUIEditor.gridlist[1], row, vehicle, getVehicleNameFromModel(xmlNodeGetAttribute(v, 'ID')))
  76.             guiGridListSetItemText(GUIEditor.gridlist[1], row, date, xmlNodeGetAttribute(v, 'date'))
  77.         end
  78.     end
  79.    
  80.     guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1]))
  81.     showCursor(guiGetVisible(GUIEditor.window[1]))
  82. end )
  83.  
  84. addEventHandler('onClientGUIClick', getRootElement(),
  85. function()
  86.     if source == GUIEditor.button[2] then -- NEW VEHICLE
  87.         guiSetText(GUIEditor.edit[3], getVehicleName(getPedOccupiedVehicle(localPlayer)))
  88.         guiSetVisible(GUIEditor.window[2], true)
  89.         guiSetInputEnabled(true)
  90.     elseif source == GUIEditor.button[5] then -- NEW WINDOW - ADD BUTTON
  91.         if guiGetText(GUIEditor.edit[2]) == '' then outputChatBox('Fill in the NAME field correctly!', 255, 0, 0) return end
  92.         local vehicle = getPedOccupiedVehicle(localPlayer)
  93.         local vehColor = guiCheckBoxGetSelected(GUIEditor.checkbox[1])
  94.         local vehLights = guiCheckBoxGetSelected(GUIEditor.checkbox[2])
  95.         local vehUpgrades = guiCheckBoxGetSelected(GUIEditor.checkbox[3])
  96.         local vehPaintjob = guiCheckBoxGetSelected(GUIEditor.checkbox[4])
  97.        
  98.         xmlVehicleNode = xmlCreateChild(xmlMain, 'vehicle')
  99.         xmlNodeSetValue(xmlVehicleNode, guiGetText(GUIEditor.edit[2]))
  100.         xmlNodeSetAttribute(xmlVehicleNode, 'ID', getElementModel(vehicle))
  101.        
  102.         if vehColor then
  103.             local r, g, b = getVehicleColor(vehicle, true)
  104.             xmlNodeSetAttribute(xmlVehicleNode, 'vehRed', r)
  105.             xmlNodeSetAttribute(xmlVehicleNode, 'vehGreen', g)
  106.             xmlNodeSetAttribute(xmlVehicleNode, 'vehBlue', b)
  107.         end
  108.         if vehLights then
  109.             local r, g, b = getVehicleHeadLightColor(vehicle)
  110.             xmlNodeSetAttribute(xmlVehicleNode, 'lightsRed', r)
  111.             xmlNodeSetAttribute(xmlVehicleNode, 'lightsGreen', g)
  112.             xmlNodeSetAttribute(xmlVehicleNode, 'lightsBlue', b)
  113.         end
  114.         if vehUpgrades then
  115.             xmlUpgradesNode = xmlCreateChild(xmlVehicleNode, 'Upgrades')
  116.             for i, v in ipairs(getVehicleUpgrades(vehicle)) do
  117.                 xmlNodeSetAttribute(xmlUpgradesNode, getVehicleUpgradeSlotName(v), v)
  118.             end
  119.         end
  120.         if vehPaintjob then
  121.             xmlNodeSetAttribute(xmlVehicleNode, 'paintJob', getVehiclePaintjob(vehicle))
  122.         end
  123.         xmlNodeSetAttribute(xmlVehicleNode, 'date', getRealTime()['monthday']..'/'..(getRealTime()['month'] + 1)..'/'..(getRealTime()['year'] + 1900))
  124.         xmlSaveFile(xmlMain)
  125.         guiSetVisible(GUIEditor.window[2], false)
  126.         guiSetInputEnabled(false)
  127.     elseif source == GUIEditor.button[6] then -- NEW WINDOW - CANCEL BUTTON
  128.         guiSetVisible(GUIEditor.window[2], false)
  129.         guiSetInputEnabled(false)
  130.     elseif source == GUIEditor.button[3] then -- DELETE VEHICLE
  131.        
  132.     end
  133. end )
Advertisement
Add Comment
Please, Sign In to add comment