Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isVehicleUpgraded(theVehicle, upgrade) -- USEFULL FUNKCJA
- if not (isElement(theVehicle) and getElementType(theVehicle) == "vehicle") then return end
- if not (upgrade and type(upgrade) == "number") then return end
- for slot=0, 16 do
- local upgradeSlot = getVehicleUpgradeOnSlot(theVehicle, slot)
- if (upgradeSlot) and (upgradeSlot == upgrade) then
- return true
- end
- end
- return false
- end
- local components = {
- [1] = { 1025, 5000, "Offroad"},
- [2] = { 1073, 2100, "Shadow"},
- [3] = { 1074, 2500, "Mega"},
- [4] = { 1075, 1400, "Rimshine"},
- [5] = { 1076, 3500, "Wires"},
- [6] = { 1077, 2700, "Classic"},
- [7] = { 1078, 4100, "Twist"},
- [8] = { 1079, 1600, "Cutter"},
- [9] = { 1080, 2000, "Switch"},
- [10] = { 1081, 2200, "Grove"},
- [11] = { 1082, 4500, "Import"},
- [12] = { 1083, 5500, "Dolar"},
- [13] = { 1085, 1200, "Atomic"},
- [14] = { 1096, 3300, "Ahab"},
- [15] = { 1097, 2900, "Virtual"},
- [16] = { 1098, 3100, "Access"},
- }
- local TuningMarker = createMarker( 1960.69, 2171.10, 10.26-1, "cylinder" , 7.0, 0,0, 255, 255 )
- function showGui()
- theVehicle = getPedOccupiedVehicle(localPlayer)
- theDriver = getVehicleController(theVehicle)
- if (theVehicle) or (theDriver) then
- local vehID = getElementModel(theVehicle)
- local vehName = getVehicleName(theVehicle)
- showCursor(true, false)
- window = guiCreateWindow(0.34, 0.21, 0.30, 0.40, "Tuning ", true)
- guiWindowSetMovable(window, false)
- guiWindowSetSizable(window, false)
- gridlist = guiCreateGridList(0.02, 0.05, 0.49, 0.92, true, window)
- colComponent = guiGridListAddColumn(gridlist, "Komponent", 0.33)
- colPrice = guiGridListAddColumn(gridlist, "Cena Tuningu", 0.3)
- colName = guiGridListAddColumn(gridlist, "Nazwa", 0.3)
- for i = 1, #components do
- local id, price, name = components[i][1], components[i][2], components[i][3]
- local row = guiGridListAddRow ( gridlist, id, price, name )
- local setComponent = guiGridListSetItemText(gridlist, row, colComponent, id, false, false)
- local setPrice = guiGridListSetItemText(gridlist, row, colPrice, price, false, false)
- local setName = guiGridListSetItemText(gridlist, row, colName, name, false, false)
- end
- label1 = guiCreateLabel(0.51, 0.12, 0.49, 0.08, "Model: "..vehID..", Nazwa: "..vehName.."", true, window)
- guiLabelSetHorizontalAlign(label1, "center", false)
- guiLabelSetVerticalAlign(label1, "center")
- label2 = guiCreateLabel(0.51, 0.04, 0.49, 0.08, "Informacje:", true, window)
- guiLabelSetHorizontalAlign(label2, "center", false)
- guiLabelSetVerticalAlign(label2, "center")
- label3 = guiCreateLabel(0.51, 0.19, 0.49, 0.08, "===============================", true, window)
- guiLabelSetHorizontalAlign(label3, "center", false)
- guiLabelSetVerticalAlign(label3, "center")
- button = guiCreateButton(0.52, 0.84, 0.46, 0.12, "MONTAŻ", true, window)
- label4 = guiCreateLabel(0.51, 0.27, 0.49, 0.08, "ID KOMPONENTU:\nN/A", true, window) -- ID NP. 1025
- guiLabelSetHorizontalAlign(label4, "center", false)
- guiLabelSetVerticalAlign(label4, "center")
- label5 = guiCreateLabel(0.51, 0.34, 0.49, 0.08, "NAZWA KOMPONENTU:\nN/A", true, window) -- NAZWA NP. OFFROAD
- guiLabelSetHorizontalAlign(label5, "center", false)
- guiLabelSetVerticalAlign(label5, "center")
- label6 = guiCreateLabel(0.51, 0.50, 0.49, 0.08, "STATUS:\nN/A", true, window) -- ZAMONTUJ / DEMONTUJ
- guiLabelSetHorizontalAlign(label6, "center", false)
- guiLabelSetVerticalAlign(label6, "center")
- label7 = guiCreateLabel(0.51, 0.74, 0.49, 0.08, "DEMONTAŻ ZWRACA TYLKO 50%\nWARTOŚCI KOMPONENTU", true, window)
- guiSetFont(label7, "default-bold-small")
- guiLabelSetColor(label7, 255, 0, 0)
- guiLabelSetHorizontalAlign(label7, "center", false)
- guiLabelSetVerticalAlign(label7, "center")
- label8 = guiCreateLabel(0.51, 0.42, 0.49, 0.08, "CENA:\nN/A", true, window)
- guiLabelSetHorizontalAlign(label8, "center", false)
- guiLabelSetVerticalAlign(label8, "center")
- addEventHandler("onClientGUIClick", button, tuningItem)
- addEventHandler("onClientGUIClick", gridlist, loadComponents)
- end
- end
- addEventHandler( "onClientMarkerHit", root, showGui)
- function loadComponents()
- local itemName = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), 3 )
- local idComponent = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), 1 )
- local priceComponent = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), 2 )
- guiSetText(label4, "ID KOMPONENTU:\n"..idComponent)
- guiSetText(label5, "NAZWA KOMPONENTU:\n"..itemName)
- guiSetText(label8, "CENA:\n"..priceComponent.."$")
- guiSetText(button, "MONTAŻ")
- local upgrades = getVehicleUpgrades ( getPedOccupiedVehicle( localPlayer ) )
- for _, upgrade in ipairs ( upgrades ) do
- if tonumber(upgrade) == tonumber(idComponent) then
- guiSetText(button, "DEMONTAŻ")
- break
- end
- end
- end
- function tuningItem(button)
- local theVehicle = getPedOccupiedVehicle(localPlayer)
- local itemName = guiGridListGetItemText (gridlist, guiGridListGetSelectedItem ( gridlist ), 3 )
- local idComponent = guiGridListGetItemText (gridlist, guiGridListGetSelectedItem ( gridlist ), 1 )
- if guiGetText(source) == "MONTAŻ" and itemName ~= "" and tonumber(idComponent) then
- addVehicleUpgrade(theVehicle, tonumber(idComponent))
- outputChatBox("#00ff00✔#ffffff Pomyślnie zamontowałeś część ID: "..idComponent.." ("..itemName..")", 255, 255, 255, true)
- guiSetText(label6, "STATUS:\nZAMONTOWANE")
- elseif guiGetText(source) == "DEMONTAŻ" and itemName ~= "" and tonumber(idComponent) then
- removeVehicleUpgrade(theVehicle, tonumber(idComponent) )
- outputChatBox("#00ff00✔#ffffff Pomyślnie zdemontowałeś część ID: "..idComponent.." ("..itemName..")", 255, 255, 255, true)
- guiSetText(label6, "STATUS:\nZDEMONTOWANE")
- end
- loadComponents()
- end
- function deleteGui()
- if ( guiGetVisible ( window ) == true ) then
- guiSetVisible( window, false)
- showCursor(false)
- end
- end
- addEventHandler( "onClientMarkerLeave", getRootElement(), deleteGui)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement