Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.52 KB | None | 0 0
  1. function isVehicleUpgraded(theVehicle, upgrade) -- USEFULL FUNKCJA
  2.     if not (isElement(theVehicle) and getElementType(theVehicle) == "vehicle") then return end
  3.     if not (upgrade and type(upgrade) == "number") then return end
  4.     for slot=0, 16 do
  5.         local upgradeSlot = getVehicleUpgradeOnSlot(theVehicle, slot)
  6.         if (upgradeSlot) and (upgradeSlot == upgrade) then
  7.             return true
  8.         end
  9.     end
  10.     return false
  11. end
  12.  
  13.  
  14. local components = {
  15.  
  16.     [1] = { 1025, 5000, "Offroad"},
  17.     [2] = { 1073, 2100, "Shadow"},
  18.     [3] = { 1074, 2500, "Mega"},
  19.     [4] = { 1075, 1400, "Rimshine"},
  20.     [5] = { 1076, 3500, "Wires"},
  21.     [6] = { 1077, 2700, "Classic"},
  22.     [7] = { 1078, 4100, "Twist"},
  23.     [8] = { 1079, 1600, "Cutter"},
  24.     [9] = { 1080, 2000, "Switch"},
  25.     [10] = { 1081, 2200, "Grove"},
  26.     [11] = { 1082, 4500, "Import"},
  27.     [12] = { 1083, 5500, "Dolar"},
  28.     [13] = { 1085, 1200, "Atomic"},
  29.     [14] = { 1096, 3300, "Ahab"},
  30.     [15] = { 1097, 2900, "Virtual"},
  31.     [16] = { 1098, 3100, "Access"},
  32. }
  33.  
  34. local TuningMarker = createMarker( 1960.69, 2171.10, 10.26-1, "cylinder" , 7.0, 0,0, 255, 255 )
  35.  
  36. function showGui()
  37.     theVehicle = getPedOccupiedVehicle(localPlayer)
  38.     theDriver = getVehicleController(theVehicle)
  39.     if (theVehicle) or (theDriver) then
  40.         local vehID = getElementModel(theVehicle)
  41.         local vehName = getVehicleName(theVehicle)
  42.         showCursor(true, false)
  43.         window = guiCreateWindow(0.34, 0.21, 0.30, 0.40, "Tuning ", true)
  44.         guiWindowSetMovable(window, false)
  45.         guiWindowSetSizable(window, false)
  46.         gridlist = guiCreateGridList(0.02, 0.05, 0.49, 0.92, true, window)
  47.         colComponent = guiGridListAddColumn(gridlist, "Komponent", 0.33)
  48.         colPrice = guiGridListAddColumn(gridlist, "Cena Tuningu", 0.3)
  49.         colName = guiGridListAddColumn(gridlist, "Nazwa", 0.3)
  50.         for i = 1, #components do
  51.             local id, price, name = components[i][1], components[i][2], components[i][3]
  52.             local row = guiGridListAddRow ( gridlist, id, price, name )
  53.             local setComponent = guiGridListSetItemText(gridlist, row, colComponent, id, false, false)
  54.             local setPrice = guiGridListSetItemText(gridlist, row, colPrice, price, false, false)
  55.             local setName = guiGridListSetItemText(gridlist, row, colName, name, false, false)
  56.         end
  57.         label1 = guiCreateLabel(0.51, 0.12, 0.49, 0.08, "Model: "..vehID..", Nazwa: "..vehName.."", true, window)
  58.         guiLabelSetHorizontalAlign(label1, "center", false)
  59.         guiLabelSetVerticalAlign(label1, "center")
  60.  
  61.         label2 = guiCreateLabel(0.51, 0.04, 0.49, 0.08, "Informacje:", true, window)
  62.         guiLabelSetHorizontalAlign(label2, "center", false)
  63.         guiLabelSetVerticalAlign(label2, "center")
  64.  
  65.         label3 = guiCreateLabel(0.51, 0.19, 0.49, 0.08, "===============================", true, window)
  66.         guiLabelSetHorizontalAlign(label3, "center", false)
  67.         guiLabelSetVerticalAlign(label3, "center")
  68.  
  69.         button = guiCreateButton(0.52, 0.84, 0.46, 0.12, "MONTAŻ", true, window)
  70.         label4 = guiCreateLabel(0.51, 0.27, 0.49, 0.08, "ID KOMPONENTU:\nN/A", true, window) -- ID NP. 1025
  71.         guiLabelSetHorizontalAlign(label4, "center", false)
  72.         guiLabelSetVerticalAlign(label4, "center")
  73.  
  74.         label5 = guiCreateLabel(0.51, 0.34, 0.49, 0.08, "NAZWA KOMPONENTU:\nN/A", true, window) -- NAZWA NP. OFFROAD
  75.         guiLabelSetHorizontalAlign(label5, "center", false)
  76.         guiLabelSetVerticalAlign(label5, "center")
  77.  
  78.         label6 = guiCreateLabel(0.51, 0.50, 0.49, 0.08, "STATUS:\nN/A", true, window) -- ZAMONTUJ / DEMONTUJ
  79.         guiLabelSetHorizontalAlign(label6, "center", false)
  80.         guiLabelSetVerticalAlign(label6, "center")
  81.  
  82.         label7 = guiCreateLabel(0.51, 0.74, 0.49, 0.08, "DEMONTAŻ ZWRACA TYLKO 50%\nWARTOŚCI KOMPONENTU", true, window)
  83.         guiSetFont(label7, "default-bold-small")
  84.         guiLabelSetColor(label7, 255, 0, 0)
  85.         guiLabelSetHorizontalAlign(label7, "center", false)
  86.         guiLabelSetVerticalAlign(label7, "center")
  87.  
  88.         label8 = guiCreateLabel(0.51, 0.42, 0.49, 0.08, "CENA:\nN/A", true, window)
  89.         guiLabelSetHorizontalAlign(label8, "center", false)
  90.         guiLabelSetVerticalAlign(label8, "center")
  91.  
  92.         addEventHandler("onClientGUIClick", button, tuningItem)
  93.         addEventHandler("onClientGUIClick", gridlist, loadComponents)
  94.     end
  95. end
  96. addEventHandler( "onClientMarkerHit", root, showGui)
  97.  
  98. function loadComponents()
  99.     local itemName = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), 3 )
  100.     local idComponent = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), 1 )
  101.     local priceComponent = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), 2 )
  102.     guiSetText(label4, "ID KOMPONENTU:\n"..idComponent)
  103.     guiSetText(label5, "NAZWA KOMPONENTU:\n"..itemName)
  104.     guiSetText(label8, "CENA:\n"..priceComponent.."$")
  105.     guiSetText(button, "MONTAŻ")
  106.     local upgrades = getVehicleUpgrades ( getPedOccupiedVehicle( localPlayer ) )
  107.     for _, upgrade in ipairs ( upgrades ) do
  108.         if tonumber(upgrade) == tonumber(idComponent) then
  109.              guiSetText(button, "DEMONTAŻ")
  110.             break
  111.         end
  112.     end
  113. end
  114.  
  115. function tuningItem(button)
  116.     local theVehicle = getPedOccupiedVehicle(localPlayer)
  117.     local itemName = guiGridListGetItemText (gridlist, guiGridListGetSelectedItem ( gridlist ), 3 )
  118.     local idComponent = guiGridListGetItemText (gridlist, guiGridListGetSelectedItem ( gridlist ), 1 )
  119.     if guiGetText(source) == "MONTAŻ" and itemName ~= "" and tonumber(idComponent) then
  120.         addVehicleUpgrade(theVehicle, tonumber(idComponent))
  121.         outputChatBox("#00ff00✔#ffffff Pomyślnie zamontowałeś część ID: "..idComponent.." ("..itemName..")", 255, 255, 255, true)
  122.         guiSetText(label6, "STATUS:\nZAMONTOWANE")
  123.     elseif guiGetText(source) == "DEMONTAŻ" and itemName ~= "" and tonumber(idComponent) then
  124.         removeVehicleUpgrade(theVehicle, tonumber(idComponent) )
  125.         outputChatBox("#00ff00✔#ffffff Pomyślnie zdemontowałeś część ID: "..idComponent.." ("..itemName..")", 255, 255, 255, true)
  126.         guiSetText(label6, "STATUS:\nZDEMONTOWANE")
  127.     end
  128.     loadComponents()
  129. end
  130.  
  131. function deleteGui()
  132.     if ( guiGetVisible ( window ) == true ) then
  133.         guiSetVisible( window, false)
  134.         showCursor(false)
  135.     end
  136. end
  137. addEventHandler( "onClientMarkerLeave", getRootElement(), deleteGui)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement