Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- notAllowedTypes = {'Plane', 'Train', 'Trailer'}
- GUIEditor = {
- button = {},
- edit = {},
- window = {},
- gridlist = {},
- checkbox = {},
- label = {},
- radiobutton = {},
- }
- local screenW, screenH = guiGetScreenSize()
- GUIEditor.window[2] = guiCreateWindow((screenW - 294) / 2, (screenH - 192) / 2, 294, 192, "[+] NEW SAVE", false)
- guiWindowSetSizable(GUIEditor.window[2], false)
- guiSetVisible(GUIEditor.window[2], false)
- GUIEditor.edit[2] = guiCreateEdit(86, 28, 197, 25, "", false, GUIEditor.window[2])
- GUIEditor.label[2] = guiCreateLabel(10, 28, 64, 24, "Name:", false, GUIEditor.window[2])
- guiLabelSetVerticalAlign(GUIEditor.label[2], "center")
- GUIEditor.label[3] = guiCreateLabel(10, 57, 64, 24, "Vehicle:", false, GUIEditor.window[2])
- guiLabelSetVerticalAlign(GUIEditor.label[3], "center")
- GUIEditor.edit[3] = guiCreateEdit(85, 56, 199, 25, "Infernus", false, GUIEditor.window[2])
- guiEditSetReadOnly(GUIEditor.edit[3], true)
- GUIEditor.checkbox[1] = guiCreateCheckBox(85, 91, 99, 27, "Vehicle Color", true, false, GUIEditor.window[2])
- GUIEditor.label[5] = guiCreateLabel(10, 89, 64, 24, "Save:", false, GUIEditor.window[2])
- guiLabelSetVerticalAlign(GUIEditor.label[5], "center")
- GUIEditor.checkbox[2] = guiCreateCheckBox(188, 91, 91, 27, "Lights Color", true, false, GUIEditor.window[2])
- GUIEditor.checkbox[3] = guiCreateCheckBox(85, 123, 98, 27, "Upgrades", true, false, GUIEditor.window[2])
- GUIEditor.checkbox[4] = guiCreateCheckBox(187, 123, 89, 27, "Paintjob", true, false, GUIEditor.window[2])
- GUIEditor.button[5] = guiCreateButton(207, 155, 72, 27, "[+] ADD", false, GUIEditor.window[2])
- guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FFAAAAAA")
- GUIEditor.button[6] = guiCreateButton(130, 155, 77, 27, "[x] CANCEL", false, GUIEditor.window[2])
- guiSetProperty(GUIEditor.button[6], "NormalTextColour", "FFAAAAAA")
- GUIEditor.window[1] = guiCreateWindow((screenW - 323) / 2, (screenH - 395) / 2, 323, 395, "F5 - Car Manager", false)
- guiWindowSetSizable(GUIEditor.window[1], false)
- guiSetVisible(GUIEditor.window[1], false)
- GUIEditor.gridlist[1] = guiCreateGridList(10, 22, 304, 304, false, GUIEditor.window[1])
- name = guiGridListAddColumn(GUIEditor.gridlist[1], "Name", 0.3)
- vehicle = guiGridListAddColumn(GUIEditor.gridlist[1], "Vehicle", 0.3)
- date = guiGridListAddColumn(GUIEditor.gridlist[1], "Date", 0.3)
- guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "-", false, false)
- guiGridListSetItemText(GUIEditor.gridlist[1], 0, 2, "Blista Compact", false, false)
- guiGridListSetItemText(GUIEditor.gridlist[1], 0, 3, "12/12/2222", false, false)
- GUIEditor.button[1] = guiCreateButton(234, 331, 79, 28, "Spawn", false, GUIEditor.window[1])
- guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
- GUIEditor.button[2] = guiCreateButton(10, 331, 79, 28, "[+] NEW", false, GUIEditor.window[1])
- guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA")
- GUIEditor.button[3] = guiCreateButton(89, 331, 79, 28, "[-] DELETE", false, GUIEditor.window[1])
- guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFAAAAAA")
- GUIEditor.radiobutton[1] = guiCreateRadioButton(20, 362, 72, 28, "English", false, GUIEditor.window[1])
- guiSetProperty(GUIEditor.radiobutton[1], "NormalTextColour", "C8FFFFFF")
- GUIEditor.radiobutton[2] = guiCreateRadioButton(101, 362, 71, 28, "Español", false, GUIEditor.window[1])
- guiSetProperty(GUIEditor.radiobutton[2], "NormalTextColour", "C8FFFFFF")
- guiRadioButtonSetSelected(GUIEditor.radiobutton[2], true)
- xmlMain = xmlLoadFile('vehicles.xml') or xmlCreateFile('vehicles.xml', 'vehicles')
- function activate()
- if notAllowedTypes[getVehicleType(getPedOccupiedVehicle(localPlayer))] then outputChatBox('That vehicle is in the banlist!', 255, 0, 0) return end
- for i, v in ipairs(xmlNodeGetChildren(xmlMain)) do
- row = guiGridListAddRow(GUIEditor.gridlist[1])
- guiGridListSetItemText(GUIEditor.gridlist[1], row, name, xmlNodeGetAttribute(v, 'name'), false, false)
- guiGridListSetItemText(GUIEditor.gridlist[1], row, vehicle, getVehicleNameFromModel(xmlNodeGetAttribute(v, 'id')), false, false)
- guiGridListSetItemText(GUIEditor.gridlist[1], row, date, xmlNodeGetAttribute(v, 'date'), false, false)
- end
- guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1]))
- showCursor(guiGetVisible(GUIEditor.window[1]))
- end
- bindKey('F5', 'down', activate)
- addEventHandler('onClientGUIClick', getRootElement(),
- function()
- if source == GUIEditor.button[2] then -- NEW VEHICLE
- guiSetText(GUIEditor.edit[3], getVehicleName(getPedOccupiedVehicle(localPlayer)))
- guiSetVisible(GUIEditor.window[2], true)
- guiSetInputEnabled(true)
- elseif source == GUIEditor.button[5] then -- NEW WINDOW - ADD BUTTON
- if guiGetText(GUIEditor.edit[2]) == '' then outputChatBox('Fill in the NAME field correctly!', 255, 0, 0) return end
- local vehicle = getPedOccupiedVehicle(localPlayer)
- local vehColor = guiCheckBoxGetSelected(GUIEditor.checkbox[1])
- local vehLights = guiCheckBoxGetSelected(GUIEditor.checkbox[2])
- local vehUpgrades = guiCheckBoxGetSelected(GUIEditor.checkbox[3])
- local vehPaintjob = guiCheckBoxGetSelected(GUIEditor.checkbox[4])
- xmlVehicleNode = xmlCreateChild(xmlMain, 'vehicle')
- xmlNodeSetAttribute(xmlVehicleNode, 'name', guiGetText(GUIEditor.edit[2]))
- xmlNodeSetAttribute(xmlVehicleNode, 'id', getElementModel(vehicle))
- if vehColor then
- local r, g, b = getVehicleColor(vehicle, true)
- xmlNodeSetAttribute(xmlVehicleNode, 'vehred', r)
- xmlNodeSetAttribute(xmlVehicleNode, 'vehgreen', g)
- xmlNodeSetAttribute(xmlVehicleNode, 'vehblue', b)
- end
- if vehLights then
- local r, g, b = getVehicleHeadLightColor(vehicle)
- xmlNodeSetAttribute(xmlVehicleNode, 'lightsred', r)
- xmlNodeSetAttribute(xmlVehicleNode, 'lightsgreen', g)
- xmlNodeSetAttribute(xmlVehicleNode, 'lightsblue', b)
- end
- if vehUpgrades then
- xmlUpgradesNode = xmlCreateChild(xmlVehicleNode, 'upgrades')
- for i, v in ipairs(getVehicleUpgrades(vehicle)) do
- xmlNodeSetAttribute(xmlUpgradesNode, getVehicleUpgradeSlotName(v), v)
- end
- end
- if vehPaintjob then
- xmlNodeSetAttribute(xmlVehicleNode, 'paintjob', getVehiclePaintjob(vehicle))
- end
- xmlNodeSetAttribute(xmlVehicleNode, 'date', getRealTime()['monthday']..'/'..(getRealTime()['month'] + 1)..'/'..(getRealTime()['year'] + 1900))
- xmlSaveFile(xmlMain)
- guiSetVisible(GUIEditor.window[2], false)
- guiSetInputEnabled(false)
- elseif source == GUIEditor.button[6] then -- NEW WINDOW - CANCEL BUTTON
- guiSetVisible(GUIEditor.window[2], false)
- guiSetInputEnabled(false)
- elseif source == GUIEditor.button[3] then -- DELETE VEHICLE
- end
- end )
- addEventHandler('onClientPlayerQuit', getRootElement(),
- function()
- if source == localPlayer then
- xmlUnloadFile(xmlMain)
- end
- end )
- addEventHandler('onClientResourceStart', getRootElement(),
- function(res)
- if res == this then
- xmlUnloadFile(xmlMain)
- end
- end )
Advertisement
Add Comment
Please, Sign In to add comment