Ja[B]er[X]Pro Posted January 29, 2016 Share Posted January 29, 2016 السلام عليكم ورحمة الله وبركاته انا جبت مود سيارات وعدلته وطورته المشكلة الان اللوحة ما تفتح عند الضغط على زر الاكواد setTimer ( function () local theCol = getElementData(root, "BlockExportCol") function isInColExport () if isElement(theCol) and isElementWithinColShape(localPlayer,theCol) then return true else return false end end function ClientExplosionCFunction() if isInColExport () then cancelEvent () end end addEventHandler("onClientExplosion", root, ClientExplosionCFunction) end , 1000, 1 ) local screX, screY = guiGetScreenSize() Window_VS = guiCreateWindow(205, 51, 417, 465, "Car Panel | لوحة السيارات", false) guiWindowSetSizable(Window_VS, false) guiSetAlpha(Window_VS, 1.00) guiSetVisible(Window_VS,false) Grid_VS = guiCreateGridList(10, 55, 388, 166, false, Window_VS) guiGridListAddColumn(Grid_VS, "Vehicle", 0.5) guiGridListAddColumn(Grid_VS, "Hp", 0.5) label1 = guiCreateLabel(141, 30, 128, 15, " سياراتك الخاصة بك :", false, Window_VS) Button_VS_sn = guiCreateButton(10, 231, 93, 45, "Crate", false, Window_VS) guiSetProperty(Button_VS_sn, "NormalTextColour", "FFFFFEFE") Button_VS_dy = guiCreateButton(113, 231, 93, 45, "Destroyer", false, Window_VS) guiSetProperty(Button_VS_dy, "NormalTextColour", "FFFFFEFE") Button_VS_Fix = guiCreateButton(216, 231, 93, 45, "reapir", false, Window_VS) guiSetProperty(Button_VS_Fix, "NormalTextColour", "FFFFFEFE") Button_VS_Warp = guiCreateButton(314, 231, 93, 45, "Spawn", false, Window_VS) guiSetProperty(Button_VS_Warp, "NormalTextColour", "FFFFFEFE") Button_VS_lk = guiCreateButton(146, 287, 119, 44, "Lock\open Car", false, Window_VS) guiSetProperty(Button_VS_lk, "NormalTextColour", "FFFFFEFE") label2 = guiCreateLabel(1, 331, 413, 21, "_______________________________________________________________", false, GUIEditor.window[1]) label3 = guiCreateLabel(146, 362, 142, 17, "سيارات السيرفر :", false, Window_VS) GUIEditor.button[b1] = guiCreateButton(9, 387, 112, 49, "NRG-500", false, Window_VS) guiSetProperty(GUIEditor.button[b1], "NormalTextColour", "FFC3E830") GUIEditor.button[b2] = guiCreateButton(151, 387, 112, 49, "Maverick", false, Window_VS) guiSetProperty(GUIEditor.button[b2], "NormalTextColour", "FFFF0000") GUIEditor.button[b3] = guiCreateButton(294, 387, 112, 49, "Polcie Ranger", false, Window_VS) guiSetProperty(GUIEditor.button[b3], "NormalTextColour", "FF30E01E") label4 = guiCreateLabel(210, 493, 135, 15, "Edit By : Ja[b]er[X]Pro", false, Window_VS) function updateGridList() local data = getElementData(localPlayer, "VehicleInfo") if data then local rw, cl = guiGridListGetSelectedItem(Grid_VS) guiGridListClear(Grid_VS) for i, data in ipairs (data) do local carName = getVehicleNameFromModel(data["Model"]) local ID = data["ID"] local Cost = data["Cost"] local HP = math.floor(data["HP"]) local PreCost = math.ceil(Cost*.9*HP/100/10) local row = guiGridListAddRow(Grid_VS) guiGridListSetItemText(Grid_VS, row, 1, carName, false, true) guiGridListSetItemData(Grid_VS, row, 1, ID) guiGridListSetItemText(Grid_VS, row, 2, HP.." HP", false, true) end guiGridListSetSelectedItem(Grid_VS, rw, cl) end end outputChatBox("Vehicle System Edit By Jaber&Hmo-Goda", 255, 125, 0) bindKey("F1", "down", function() guiSetVisible(Window_VS,true) guiSetVisible (Window_CHK, false) showCursor(guiGetVisible(Window_VS)) end) triggerServerEvent("onOpenGui", localPlayer) addEventHandler("onClientElementDataChange", root, function(dd) if getElementType(source) == "player" and source == localPlayer and dd == "VehicleInfo" then local data = getElementData(source, dd) if data then updateGridList() end end end) function WINDOW_CLICK_VEHICLE (button, state, absoluteX, absoluteY) local id = guiGridListGetSelectedItem(Grid_VS) local ID = guiGridListGetItemData(Grid_VS, id, 1) if source == Button_VS_close then guiSetVisible(Window_VS, false) showCursor(false) end if (source == Grid_VS) then if id == -1 and idd then guiGridListSetSelectedItem(Grid_VS, idd, 1) return false else idd = guiGridListGetSelectedItem(Grid_VS) end elseif id == -1 then elseif (source == Button_VS_sn) then if not isInColExport () then triggerServerEvent("SpawnMyVehicle", localPlayer, ID) end elseif (source == Button_VS_dy) then triggerServerEvent("DestroyMyVehicle", localPlayer, ID) elseif (source == Button_VS_lt) then triggerServerEvent("LightsMyVehicle", localPlayer, ID) elseif (source == Button_VS_bp) then triggerServerEvent("BlipMyVehicle", localPlayer, ID) elseif (source == Button_VS_lk) then triggerServerEvent("LockMyVehicle", localPlayer, ID) elseif (source == Button_VS_sl) then guiSetVisible(Window_CHK, true) local carName = guiGridListGetItemText(Grid_VS, guiGridListGetSelectedItem(Grid_VS), 1) local carprice = guiGridListGetItemText(Grid_VS, guiGridListGetSelectedItem(Grid_VS), 2) guiSetText(Label_CHK, 'Are you sure you want to sell this Vehicle "'..carName..'" for $'..carprice) elseif source == Button_VS_Spc then if getElementInterior(localPlayer) == 0 then if getElementData(localPlayer,"Stats") < 0 then SpecVehicle(ID) end end elseif source == Button_VS_Fix then triggerServerEvent("FixMyVehicle", localPlayer, ID) elseif source == Button_VS_Warp then if not isInColExport () then triggerServerEvent("WarpMyVehicle", localPlayer, ID) end end end addEventHandler("onClientGUIClick", resourceRoot, WINDOW_CLICK_VEHICLE) function SpecVehicle(id) if spc then removeEventHandler("onClientPreRender", root, Sp) setCameraTarget(localPlayer) if isTimer(freezTimer) then killTimer(freezTimer) end freezTimer = setTimer(function() setElementFrozen(localPlayer, false) end, 2500, 1) spc = false return end for i, vehicle in ipairs(getElementsByType("vehicle")) do if getElementData(vehicle, "Owner") == localPlayer and getElementData(vehicle, "ID") == id then cVeh = vehicle spc = true addEventHandler("onClientPreRender", root, Sp) guiSetVisible(Window_VS, false) showCursor(false) break end end end function Sp() if isElement(cVeh) then local x, y, z = getElementPosition(cVeh) setElementFrozen(localPlayer, true) setCameraMatrix(x, y-1, z+15, x, y, z) else removeEventHandler("onClientPreRender", root, Sp) setCameraTarget(localPlayer) if isTimer(freezTimer) then killTimer(freezTimer) end freezTimer = setTimer(function() setElementFrozen(localPlayer, false) end, 2500, 1) spc = false end end ShopMarkersTable = {} local ShopTable = { [1] = {ID = {{491, 1441400} ,{540, 1436800} ,{401, 1430000} ,{546, 1527700} ,{505, 1414000} ,{500, 1402600} ,{463, 1659300} ,{492, 1459300} ,{547, 1429600} ,{586, 1629600} ,{467, 1354300} ,{479, 1244800} ,{404, 1059900} ,{410, 946200} ,{471, 593600} ,{418, 300000} }, vPosX = 2134, vPosY = -1170, vPosZ = 28.15, PosX = 2133, PosY = -1149, PosZ = 23.4, CamX = 2134.1, CamY = -1160, CamZ = 35, lookAtX = 2133.3, lookAtY = -1168, lookAtZ = 28}, [2] = {ID = {{516, 1819800} ,{458, 1815300} ,{580, 1801600} ,{421, 1801600} ,{527, 1667300} ,{581, 2151400} ,{409, 1744500} ,{585, 1696600} ,{474, 1573800} ,{419, 1539500} ,{436, 1539500} ,{545, 1530400} ,{466, 1616700} ,{529, 1580200} ,{550, 1473400} ,{468, 1966500} }, vPosX = 552, vPosY = -1288, vPosZ = 18, PosX = 562, PosY = -1270, PosZ = 16, CamX = 552, CamY = -1275.82, CamZ = 21.61, lookAtX = 552, lookAtY = -1276.77, lookAtZ = 21.29}, [3] = {ID = {{533, 1973100} ,{555, 1943400} ,{507, 2041200} ,{521, 2427500} ,{461, 2427500} ,{566, 1995500} ,{551, 1972700} ,{400, 1970400} ,{558, 1863600} ,{549, 1824800} ,{579, 1902000} ,{576, 1797400} ,{526, 1781400} ,{517, 1772300} ,{575, 1763200} ,{561, 1822100} }, vPosX = 1942.5, vPosY = 2052, vPosZ = 11, PosX = 1946, PosY = 2068, PosZ = 10, CamX = 1930.36, CamY = 2052.78, CamZ = 14.71, lookAtX = 1931.36, lookAtY = 2052.78, lookAtZ = 14.43}, [4] = {ID = {{536, 2201300} ,{567, 2258000} ,{602, 2135100} ,{534, 2128300} ,{426, 2214600} ,{439, 2114600} ,{412, 2114600} ,{587, 2087200} ,{565, 2084900} ,{589, 2082600} ,{542, 2071200} ,{496, 2043900} ,{535, 2043900} ,{405, 2127900} ,{445, 2107300} ,{518, 1980000} }, vPosX = -1950, vPosY = 266, vPosZ = 36.2, PosX = -1954, PosY = 299, PosZ = 34, CamX = -1960.18, CamY = 266.06, CamZ = 37.94, lookAtX = -1959.2, lookAtY = 266.06, lookAtZ = 37.73}, [5] = {ID = {{411, 3000000} ,{429, 2765000} ,{541, 2746700} ,{451, 2739900} , Link to comment
Ahmed Ly Posted January 29, 2016 Share Posted January 29, 2016 السلام عليكم ورحمة الله وبركاتهانا جبت مود سيارات وعدلته وطورته المشكلة الان اللوحة ما تفتح عند الضغط على زر الاكواد setTimer ( function () local theCol = getElementData(root, "BlockExportCol") function isInColExport () if isElement(theCol) and isElementWithinColShape(localPlayer,theCol) then return true else return false end end function ClientExplosionCFunction() if isInColExport () then cancelEvent () end end addEventHandler("onClientExplosion", root, ClientExplosionCFunction) end , 1000, 1 ) local screX, screY = guiGetScreenSize() Window_VS = guiCreateWindow(205, 51, 417, 465, "Car Panel | لوحة السيارات", false) guiWindowSetSizable(Window_VS, false) guiSetAlpha(Window_VS, 1.00) guiSetVisible(Window_VS,false) Grid_VS = guiCreateGridList(10, 55, 388, 166, false, Window_VS) guiGridListAddColumn(Grid_VS, "Vehicle", 0.5) guiGridListAddColumn(Grid_VS, "Hp", 0.5) label1 = guiCreateLabel(141, 30, 128, 15, " سياراتك الخاصة بك :", false, Window_VS) Button_VS_sn = guiCreateButton(10, 231, 93, 45, "Crate", false, Window_VS) guiSetProperty(Button_VS_sn, "NormalTextColour", "FFFFFEFE") Button_VS_dy = guiCreateButton(113, 231, 93, 45, "Destroyer", false, Window_VS) guiSetProperty(Button_VS_dy, "NormalTextColour", "FFFFFEFE") Button_VS_Fix = guiCreateButton(216, 231, 93, 45, "reapir", false, Window_VS) guiSetProperty(Button_VS_Fix, "NormalTextColour", "FFFFFEFE") Button_VS_Warp = guiCreateButton(314, 231, 93, 45, "Spawn", false, Window_VS) guiSetProperty(Button_VS_Warp, "NormalTextColour", "FFFFFEFE") Button_VS_lk = guiCreateButton(146, 287, 119, 44, "Lock\open Car", false, Window_VS) guiSetProperty(Button_VS_lk, "NormalTextColour", "FFFFFEFE") label2 = guiCreateLabel(1, 331, 413, 21, "_______________________________________________________________", false, GUIEditor.window[1]) label3 = guiCreateLabel(146, 362, 142, 17, "سيارات السيرفر :", false, Window_VS) GUIEditor.button[b1] = guiCreateButton(9, 387, 112, 49, "NRG-500", false, Window_VS) guiSetProperty(GUIEditor.button[b1], "NormalTextColour", "FFC3E830") GUIEditor.button[b2] = guiCreateButton(151, 387, 112, 49, "Maverick", false, Window_VS) guiSetProperty(GUIEditor.button[b2], "NormalTextColour", "FFFF0000") GUIEditor.button[b3] = guiCreateButton(294, 387, 112, 49, "Polcie Ranger", false, Window_VS) guiSetProperty(GUIEditor.button[b3], "NormalTextColour", "FF30E01E") label4 = guiCreateLabel(210, 493, 135, 15, "Edit By : Ja[b]er[X]Pro", false, Window_VS) function updateGridList() local data = getElementData(localPlayer, "VehicleInfo") if data then local rw, cl = guiGridListGetSelectedItem(Grid_VS) guiGridListClear(Grid_VS) for i, data in ipairs (data) do local carName = getVehicleNameFromModel(data["Model"]) local ID = data["ID"] local Cost = data["Cost"] local HP = math.floor(data["HP"]) local PreCost = math.ceil(Cost*.9*HP/100/10) local row = guiGridListAddRow(Grid_VS) guiGridListSetItemText(Grid_VS, row, 1, carName, false, true) guiGridListSetItemData(Grid_VS, row, 1, ID) guiGridListSetItemText(Grid_VS, row, 2, HP.." HP", false, true) end guiGridListSetSelectedItem(Grid_VS, rw, cl) end end outputChatBox("Vehicle System Edit By Jaber&Hmo-Goda", 255, 125, 0) bindKey("F1", "down", function() guiSetVisible(Window_VS,true) guiSetVisible (Window_CHK, false) showCursor(guiGetVisible(Window_VS)) end) triggerServerEvent("onOpenGui", localPlayer) addEventHandler("onClientElementDataChange", root, function(dd) if getElementType(source) == "player" and source == localPlayer and dd == "VehicleInfo" then local data = getElementData(source, dd) if data then updateGridList() end end end) function WINDOW_CLICK_VEHICLE (button, state, absoluteX, absoluteY) local id = guiGridListGetSelectedItem(Grid_VS) local ID = guiGridListGetItemData(Grid_VS, id, 1) if source == Button_VS_close then guiSetVisible(Window_VS, false) showCursor(false) end if (source == Grid_VS) then if id == -1 and idd then guiGridListSetSelectedItem(Grid_VS, idd, 1) return false else idd = guiGridListGetSelectedItem(Grid_VS) end elseif id == -1 then elseif (source == Button_VS_sn) then if not isInColExport () then triggerServerEvent("SpawnMyVehicle", localPlayer, ID) end elseif (source == Button_VS_dy) then triggerServerEvent("DestroyMyVehicle", localPlayer, ID) elseif (source == Button_VS_lt) then triggerServerEvent("LightsMyVehicle", localPlayer, ID) elseif (source == Button_VS_bp) then triggerServerEvent("BlipMyVehicle", localPlayer, ID) elseif (source == Button_VS_lk) then triggerServerEvent("LockMyVehicle", localPlayer, ID) elseif (source == Button_VS_sl) then guiSetVisible(Window_CHK, true) local carName = guiGridListGetItemText(Grid_VS, guiGridListGetSelectedItem(Grid_VS), 1) local carprice = guiGridListGetItemText(Grid_VS, guiGridListGetSelectedItem(Grid_VS), 2) guiSetText(Label_CHK, 'Are you sure you want to sell this Vehicle "'..carName..'" for $'..carprice) elseif source == Button_VS_Spc then if getElementInterior(localPlayer) == 0 then if getElementData(localPlayer,"Stats") < 0 then SpecVehicle(ID) end end elseif source == Button_VS_Fix then triggerServerEvent("FixMyVehicle", localPlayer, ID) elseif source == Button_VS_Warp then if not isInColExport () then triggerServerEvent("WarpMyVehicle", localPlayer, ID) end end end addEventHandler("onClientGUIClick", resourceRoot, WINDOW_CLICK_VEHICLE) function SpecVehicle(id) if spc then removeEventHandler("onClientPreRender", root, Sp) setCameraTarget(localPlayer) if isTimer(freezTimer) then killTimer(freezTimer) end freezTimer = setTimer(function() setElementFrozen(localPlayer, false) end, 2500, 1) spc = false return end for i, vehicle in ipairs(getElementsByType("vehicle")) do if getElementData(vehicle, "Owner") == localPlayer and getElementData(vehicle, "ID") == id then cVeh = vehicle spc = true addEventHandler("onClientPreRender", root, Sp) guiSetVisible(Window_VS, false) showCursor(false) break end end end function Sp() if isElement(cVeh) then local x, y, z = getElementPosition(cVeh) setElementFrozen(localPlayer, true) setCameraMatrix(x, y-1, z+15, x, y, z) else removeEventHandler("onClientPreRender", root, Sp) setCameraTarget(localPlayer) if isTimer(freezTimer) then killTimer(freezTimer) end freezTimer = setTimer(function() setElementFrozen(localPlayer, false) end, 2500, 1) spc = false end end ShopMarkersTable = {} local ShopTable = { [1] = {ID = {{491, 1441400} ,{540, 1436800} ,{401, 1430000} ,{546, 1527700} ,{505, 1414000} ,{500, 1402600} ,{463, 1659300} ,{492, 1459300} ,{547, 1429600} ,{586, 1629600} ,{467, 1354300} ,{479, 1244800} ,{404, 1059900} ,{410, 946200} ,{471, 593600} ,{418, 300000} }, vPosX = 2134, vPosY = -1170, vPosZ = 28.15, PosX = 2133, PosY = -1149, PosZ = 23.4, CamX = 2134.1, CamY = -1160, CamZ = 35, lookAtX = 2133.3, lookAtY = -1168, lookAtZ = 28}, [2] = {ID = {{516, 1819800} ,{458, 1815300} ,{580, 1801600} ,{421, 1801600} ,{527, 1667300} ,{581, 2151400} ,{409, 1744500} ,{585, 1696600} ,{474, 1573800} ,{419, 1539500} ,{436, 1539500} ,{545, 1530400} ,{466, 1616700} ,{529, 1580200} ,{550, 1473400} ,{468, 1966500} }, vPosX = 552, vPosY = -1288, vPosZ = 18, PosX = 562, PosY = -1270, PosZ = 16, CamX = 552, CamY = -1275.82, CamZ = 21.61, lookAtX = 552, lookAtY = -1276.77, lookAtZ = 21.29}, [3] = {ID = {{533, 1973100} ,{555, 1943400} ,{507, 2041200} ,{521, 2427500} ,{461, 2427500} ,{566, 1995500} ,{551, 1972700} ,{400, 1970400} ,{558, 1863600} ,{549, 1824800} ,{579, 1902000} ,{576, 1797400} ,{526, 1781400} ,{517, 1772300} ,{575, 1763200} ,{561, 1822100} }, vPosX = 1942.5, vPosY = 2052, vPosZ = 11, PosX = 1946, PosY = 2068, PosZ = 10, CamX = 1930.36, CamY = 2052.78, CamZ = 14.71, lookAtX = 1931.36, lookAtY = 2052.78, lookAtZ = 14.43}, [4] = {ID = {{536, 2201300} ,{567, 2258000} ,{602, 2135100} ,{534, 2128300} ,{426, 2214600} ,{439, 2114600} ,{412, 2114600} ,{587, 2087200} ,{565, 2084900} ,{589, 2082600} ,{542, 2071200} ,{496, 2043900} ,{535, 2043900} ,{405, 2127900} ,{445, 2107300} ,{518, 1980000} }, vPosX = -1950, vPosY = 266, vPosZ = 36.2, PosX = -1954, PosY = 299, PosZ = 34, CamX = -1960.18, CamY = 266.06, CamZ = 37.94, lookAtX = -1959.2, lookAtY = 266.06, lookAtZ = 37.73}, [5] = {ID = {{411, 3000000} ,{429, 2765000} , Link to comment
Ja[B]er[X]Pro Posted January 29, 2016 Author Share Posted January 29, 2016 السلام عليكم ورحمة الله وبركاتهانا جبت مود سيارات وعدلته وطورته المشكلة الان اللوحة ما تفتح عند الضغط على زر الاكواد setTimer ( function () local theCol = getElementData(root, "BlockExportCol") function isInColExport () if isElement(theCol) and isElementWithinColShape(localPlayer,theCol) then return true else return false end end function ClientExplosionCFunction() if isInColExport () then cancelEvent () end end addEventHandler("onClientExplosion", root, ClientExplosionCFunction) end , 1000, 1 ) local screX, screY = guiGetScreenSize() Window_VS = guiCreateWindow(205, 51, 417, 465, "Car Panel | لوحة السيارات", false) guiWindowSetSizable(Window_VS, false) guiSetAlpha(Window_VS, 1.00) guiSetVisible(Window_VS,false) Grid_VS = guiCreateGridList(10, 55, 388, 166, false, Window_VS) guiGridListAddColumn(Grid_VS, "Vehicle", 0.5) guiGridListAddColumn(Grid_VS, "Hp", 0.5) label1 = guiCreateLabel(141, 30, 128, 15, " سياراتك الخاصة بك :", false, Window_VS) Button_VS_sn = guiCreateButton(10, 231, 93, 45, "Crate", false, Window_VS) guiSetProperty(Button_VS_sn, "NormalTextColour", "FFFFFEFE") Button_VS_dy = guiCreateButton(113, 231, 93, 45, "Destroyer", false, Window_VS) guiSetProperty(Button_VS_dy, "NormalTextColour", "FFFFFEFE") Button_VS_Fix = guiCreateButton(216, 231, 93, 45, "reapir", false, Window_VS) guiSetProperty(Button_VS_Fix, "NormalTextColour", "FFFFFEFE") Button_VS_Warp = guiCreateButton(314, 231, 93, 45, "Spawn", false, Window_VS) guiSetProperty(Button_VS_Warp, "NormalTextColour", "FFFFFEFE") Button_VS_lk = guiCreateButton(146, 287, 119, 44, "Lock\open Car", false, Window_VS) guiSetProperty(Button_VS_lk, "NormalTextColour", "FFFFFEFE") label2 = guiCreateLabel(1, 331, 413, 21, "_______________________________________________________________", false, GUIEditor.window[1]) label3 = guiCreateLabel(146, 362, 142, 17, "سيارات السيرفر :", false, Window_VS) GUIEditor.button[b1] = guiCreateButton(9, 387, 112, 49, "NRG-500", false, Window_VS) guiSetProperty(GUIEditor.button[b1], "NormalTextColour", "FFC3E830") GUIEditor.button[b2] = guiCreateButton(151, 387, 112, 49, "Maverick", false, Window_VS) guiSetProperty(GUIEditor.button[b2], "NormalTextColour", "FFFF0000") GUIEditor.button[b3] = guiCreateButton(294, 387, 112, 49, "Polcie Ranger", false, Window_VS) guiSetProperty(GUIEditor.button[b3], "NormalTextColour", "FF30E01E") label4 = guiCreateLabel(210, 493, 135, 15, "Edit By : Ja[b]er[X]Pro", false, Window_VS) function updateGridList() local data = getElementData(localPlayer, "VehicleInfo") if data then local rw, cl = guiGridListGetSelectedItem(Grid_VS) guiGridListClear(Grid_VS) for i, data in ipairs (data) do local carName = getVehicleNameFromModel(data["Model"]) local ID = data["ID"] local Cost = data["Cost"] local HP = math.floor(data["HP"]) local PreCost = math.ceil(Cost*.9*HP/100/10) local row = guiGridListAddRow(Grid_VS) guiGridListSetItemText(Grid_VS, row, 1, carName, false, true) guiGridListSetItemData(Grid_VS, row, 1, ID) guiGridListSetItemText(Grid_VS, row, 2, HP.." HP", false, true) end guiGridListSetSelectedItem(Grid_VS, rw, cl) end end outputChatBox("Vehicle System Edit By Jaber&Hmo-Goda", 255, 125, 0) bindKey("F1", "down", function() guiSetVisible(Window_VS,true) guiSetVisible (Window_CHK, false) showCursor(guiGetVisible(Window_VS)) end) triggerServerEvent("onOpenGui", localPlayer) addEventHandler("onClientElementDataChange", root, function(dd) if getElementType(source) == "player" and source == localPlayer and dd == "VehicleInfo" then local data = getElementData(source, dd) if data then updateGridList() end end end) function WINDOW_CLICK_VEHICLE (button, state, absoluteX, absoluteY) local id = guiGridListGetSelectedItem(Grid_VS) local ID = guiGridListGetItemData(Grid_VS, id, 1) if source == Button_VS_close then guiSetVisible(Window_VS, false) showCursor(false) end if (source == Grid_VS) then if id == -1 and idd then guiGridListSetSelectedItem(Grid_VS, idd, 1) return false else idd = guiGridListGetSelectedItem(Grid_VS) end elseif id == -1 then elseif (source == Button_VS_sn) then if not isInColExport () then triggerServerEvent("SpawnMyVehicle", localPlayer, ID) end elseif (source == Button_VS_dy) then triggerServerEvent("DestroyMyVehicle", localPlayer, ID) elseif (source == Button_VS_lt) then triggerServerEvent("LightsMyVehicle", localPlayer, ID) elseif (source == Button_VS_bp) then triggerServerEvent("BlipMyVehicle", localPlayer, ID) elseif (source == Button_VS_lk) then triggerServerEvent("LockMyVehicle", localPlayer, ID) elseif (source == Button_VS_sl) then guiSetVisible(Window_CHK, true) local carName = guiGridListGetItemText(Grid_VS, guiGridListGetSelectedItem(Grid_VS), 1) local carprice = guiGridListGetItemText(Grid_VS, guiGridListGetSelectedItem(Grid_VS), 2) guiSetText(Label_CHK, 'Are you sure you want to sell this Vehicle "'..carName..'" for $'..carprice) elseif source == Button_VS_Spc then if getElementInterior(localPlayer) == 0 then if getElementData(localPlayer,"Stats") < 0 then SpecVehicle(ID) end end elseif source == Button_VS_Fix then triggerServerEvent("FixMyVehicle", localPlayer, ID) elseif source == Button_VS_Warp then if not isInColExport () then triggerServerEvent("WarpMyVehicle", localPlayer, ID) end end end addEventHandler("onClientGUIClick", resourceRoot, WINDOW_CLICK_VEHICLE) function SpecVehicle(id) if spc then removeEventHandler("onClientPreRender", root, Sp) setCameraTarget(localPlayer) if isTimer(freezTimer) then killTimer(freezTimer) end freezTimer = setTimer(function() setElementFrozen(localPlayer, false) end, 2500, 1) spc = false return end for i, vehicle in ipairs(getElementsByType("vehicle")) do if getElementData(vehicle, "Owner") == localPlayer and getElementData(vehicle, "ID") == id then cVeh = vehicle spc = true addEventHandler("onClientPreRender", root, Sp) guiSetVisible(Window_VS, false) showCursor(false) break end end end function Sp() if isElement(cVeh) then local x, y, z = getElementPosition(cVeh) setElementFrozen(localPlayer, true) setCameraMatrix(x, y-1, z+15, x, y, z) else removeEventHandler("onClientPreRender", root, Sp) setCameraTarget(localPlayer) if isTimer(freezTimer) then killTimer(freezTimer) end freezTimer = setTimer(function() setElementFrozen(localPlayer, false) end, 2500, 1) spc = false end end ShopMarkersTable = {} local ShopTable = { [1] = {ID = {{491, 1441400} ,{540, 1436800} ,{401, 1430000} ,{546, 1527700} ,{505, 1414000} ,{500, 1402600} ,{463, 1659300} ,{492, 1459300} ,{547, 1429600} ,{586, 1629600} ,{467, 1354300} ,{479, 1244800} ,{404, 1059900} ,{410, 946200} ,{471, 593600} ,{418, 300000} }, vPosX = 2134, vPosY = -1170, vPosZ = 28.15, PosX = 2133, PosY = -1149, PosZ = 23.4, CamX = 2134.1, CamY = -1160, CamZ = 35, lookAtX = 2133.3, lookAtY = -1168, lookAtZ = 28}, [2] = {ID = {{516, 1819800} ,{458, 1815300} ,{580, 1801600} ,{421, 1801600} ,{527, 1667300} ,{581, 2151400} ,{409, 1744500} ,{585, 1696600} ,{474, 1573800} ,{419, 1539500} ,{436, 1539500} ,{545, 1530400} ,{466, 1616700} ,{529, 1580200} ,{550, 1473400} ,{468, 1966500} }, vPosX = 552, vPosY = -1288, vPosZ = 18, PosX = 562, PosY = -1270, PosZ = 16, CamX = 552, CamY = -1275.82, CamZ = 21.61, lookAtX = 552, lookAtY = -1276.77, lookAtZ = 21.29}, [3] = {ID = {{533, 1973100} ,{555, 1943400} ,{507, 2041200} ,{521, 2427500} ,{461, 2427500} ,{566, 1995500} ,{551, 1972700} ,{400, 1970400} ,{558, 1863600} ,{549, 1824800} ,{579, 1902000} ,{576, 1797400} ,{526, 1781400} ,{517, 1772300} ,{575, 1763200} ,{561, 1822100} }, vPosX = 1942.5, vPosY = 2052, vPosZ = 11, PosX = 1946, PosY = 2068, PosZ = 10, CamX = 1930.36, CamY = 2052.78, CamZ = 14.71, lookAtX = 1931.36, lookAtY = 2052.78, lookAtZ = 14.43}, [4] = {ID = {{536, 2201300} ,{567, 2258000} ,{602, 2135100} ,{534, 2128300} ,{426, 2214600} ,{439, 2114600} ,{412, 2114600} ,{587, 2087200} ,{565, 2084900} ,{589, 2082600} ,{542, 2071200} ,{496, 2043900} ,{535, 2043900} ,{405, 2127900} ,{445, 2107300} ,{518, 1980000} }, vPosX = -1950, vPosY = 266, vPosZ = 36.2, PosX = -1954, PosY = 299, PosZ = 34, CamX = -1960.18, CamY = 266.06, CamZ = 37.94, lookAtX = -1959.2, lookAtY = 266.06, lookAtZ = 37.73}, Link to comment
Ahmed Ly Posted January 29, 2016 Share Posted January 29, 2016 السلام عليكم ورحمة الله وبركاتهانا جبت مود سيارات وعدلته وطورته المشكلة الان اللوحة ما تفتح عند الضغط على زر الاكواد setTimer ( function () local theCol = getElementData(root, "BlockExportCol") function isInColExport () if isElement(theCol) and isElementWithinColShape(localPlayer,theCol) then return true else return false end end function ClientExplosionCFunction() if isInColExport () then cancelEvent () end end addEventHandler("onClientExplosion", root, ClientExplosionCFunction) end , 1000, 1 ) local screX, screY = guiGetScreenSize() Window_VS = guiCreateWindow(205, 51, 417, 465, "Car Panel | لوحة السيارات", false) guiWindowSetSizable(Window_VS, false) guiSetAlpha(Window_VS, 1.00) guiSetVisible(Window_VS,false) Grid_VS = guiCreateGridList(10, 55, 388, 166, false, Window_VS) guiGridListAddColumn(Grid_VS, "Vehicle", 0.5) guiGridListAddColumn(Grid_VS, "Hp", 0.5) label1 = guiCreateLabel(141, 30, 128, 15, " سياراتك الخاصة بك :", false, Window_VS) Button_VS_sn = guiCreateButton(10, 231, 93, 45, "Crate", false, Window_VS) guiSetProperty(Button_VS_sn, "NormalTextColour", "FFFFFEFE") Button_VS_dy = guiCreateButton(113, 231, 93, 45, "Destroyer", false, Window_VS) guiSetProperty(Button_VS_dy, "NormalTextColour", "FFFFFEFE") Button_VS_Fix = guiCreateButton(216, 231, 93, 45, "reapir", false, Window_VS) guiSetProperty(Button_VS_Fix, "NormalTextColour", "FFFFFEFE") Button_VS_Warp = guiCreateButton(314, 231, 93, 45, "Spawn", false, Window_VS) guiSetProperty(Button_VS_Warp, "NormalTextColour", "FFFFFEFE") Button_VS_lk = guiCreateButton(146, 287, 119, 44, "Lock\open Car", false, Window_VS) guiSetProperty(Button_VS_lk, "NormalTextColour", "FFFFFEFE") label2 = guiCreateLabel(1, 331, 413, 21, "_______________________________________________________________", false, GUIEditor.window[1]) label3 = guiCreateLabel(146, 362, 142, 17, "سيارات السيرفر :", false, Window_VS) GUIEditor.button[b1] = guiCreateButton(9, 387, 112, 49, "NRG-500", false, Window_VS) guiSetProperty(GUIEditor.button[b1], "NormalTextColour", "FFC3E830") GUIEditor.button[b2] = guiCreateButton(151, 387, 112, 49, "Maverick", false, Window_VS) guiSetProperty(GUIEditor.button[b2], "NormalTextColour", "FFFF0000") GUIEditor.button[b3] = guiCreateButton(294, 387, 112, 49, "Polcie Ranger", false, Window_VS) guiSetProperty(GUIEditor.button[b3], "NormalTextColour", "FF30E01E") label4 = guiCreateLabel(210, 493, 135, 15, "Edit By : Ja[b]er[X]Pro", false, Window_VS) function updateGridList() local data = getElementData(localPlayer, "VehicleInfo") if data then local rw, cl = guiGridListGetSelectedItem(Grid_VS) guiGridListClear(Grid_VS) for i, data in ipairs (data) do local carName = getVehicleNameFromModel(data["Model"]) local ID = data["ID"] local Cost = data["Cost"] local HP = math.floor(data["HP"]) local PreCost = math.ceil(Cost*.9*HP/100/10) local row = guiGridListAddRow(Grid_VS) guiGridListSetItemText(Grid_VS, row, 1, carName, false, true) guiGridListSetItemData(Grid_VS, row, 1, ID) guiGridListSetItemText(Grid_VS, row, 2, HP.." HP", false, true) end guiGridListSetSelectedItem(Grid_VS, rw, cl) end end outputChatBox("Vehicle System Edit By Jaber&Hmo-Goda", 255, 125, 0) bindKey("F1", "down", function() guiSetVisible(Window_VS,true) guiSetVisible (Window_CHK, false) showCursor(guiGetVisible(Window_VS)) end) triggerServerEvent("onOpenGui", localPlayer) addEventHandler("onClientElementDataChange", root, function(dd) if getElementType(source) == "player" and source == localPlayer and dd == "VehicleInfo" then local data = getElementData(source, dd) if data then updateGridList() end end end) function WINDOW_CLICK_VEHICLE (button, state, absoluteX, absoluteY) local id = guiGridListGetSelectedItem(Grid_VS) local ID = guiGridListGetItemData(Grid_VS, id, 1) if source == Button_VS_close then guiSetVisible(Window_VS, false) showCursor(false) end if (source == Grid_VS) then if id == -1 and idd then guiGridListSetSelectedItem(Grid_VS, idd, 1) return false else idd = guiGridListGetSelectedItem(Grid_VS) end elseif id == -1 then elseif (source == Button_VS_sn) then if not isInColExport () then triggerServerEvent("SpawnMyVehicle", localPlayer, ID) end elseif (source == Button_VS_dy) then triggerServerEvent("DestroyMyVehicle", localPlayer, ID) elseif (source == Button_VS_lt) then triggerServerEvent("LightsMyVehicle", localPlayer, ID) elseif (source == Button_VS_bp) then triggerServerEvent("BlipMyVehicle", localPlayer, ID) elseif (source == Button_VS_lk) then triggerServerEvent("LockMyVehicle", localPlayer, ID) elseif (source == Button_VS_sl) then guiSetVisible(Window_CHK, true) local carName = guiGridListGetItemText(Grid_VS, guiGridListGetSelectedItem(Grid_VS), 1) local carprice = guiGridListGetItemText(Grid_VS, guiGridListGetSelectedItem(Grid_VS), 2) guiSetText(Label_CHK, 'Are you sure you want to sell this Vehicle "'..carName..'" for $'..carprice) elseif source == Button_VS_Spc then if getElementInterior(localPlayer) == 0 then if getElementData(localPlayer,"Stats") < 0 then SpecVehicle(ID) end end elseif source == Button_VS_Fix then triggerServerEvent("FixMyVehicle", localPlayer, ID) elseif source == Button_VS_Warp then if not isInColExport () then triggerServerEvent("WarpMyVehicle", localPlayer, ID) end end end addEventHandler("onClientGUIClick", resourceRoot, WINDOW_CLICK_VEHICLE) function SpecVehicle(id) if spc then removeEventHandler("onClientPreRender", root, Sp) setCameraTarget(localPlayer) if isTimer(freezTimer) then killTimer(freezTimer) end freezTimer = setTimer(function() setElementFrozen(localPlayer, false) end, 2500, 1) spc = false return end for i, vehicle in ipairs(getElementsByType("vehicle")) do if getElementData(vehicle, "Owner") == localPlayer and getElementData(vehicle, "ID") == id then cVeh = vehicle spc = true addEventHandler("onClientPreRender", root, Sp) guiSetVisible(Window_VS, false) showCursor(false) break end end end function Sp() if isElement(cVeh) then local x, y, z = getElementPosition(cVeh) setElementFrozen(localPlayer, true) setCameraMatrix(x, y-1, z+15, x, y, z) else removeEventHandler("onClientPreRender", root, Sp) setCameraTarget(localPlayer) if isTimer(freezTimer) then killTimer(freezTimer) end freezTimer = setTimer(function() setElementFrozen(localPlayer, false) end, 2500, 1) spc = false end end ShopMarkersTable = {} local ShopTable = { [1] = {ID = {{491, 1441400} ,{540, 1436800} ,{401, 1430000} ,{546, 1527700} ,{505, 1414000} ,{500, 1402600} ,{463, 1659300} ,{492, 1459300} ,{547, 1429600} ,{586, 1629600} ,{467, 1354300} ,{479, 1244800} ,{404, 1059900} ,{410, 946200} ,{471, 593600} ,{418, 300000} }, vPosX = 2134, vPosY = -1170, vPosZ = 28.15, PosX = 2133, PosY = -1149, PosZ = 23.4, CamX = 2134.1, CamY = -1160, CamZ = 35, lookAtX = 2133.3, lookAtY = -1168, lookAtZ = 28}, [2] = {ID = {{516, 1819800} ,{458, 1815300} ,{580, 1801600} ,{421, 1801600} ,{527, 1667300} ,{581, 2151400} ,{409, 1744500} ,{585, 1696600} ,{474, 1573800} ,{419, 1539500} ,{436, 1539500} ,{545, 1530400} ,{466, 1616700} ,{529, 1580200} ,{550, 1473400} ,{468, 1966500} }, vPosX = 552, vPosY = -1288, vPosZ = 18, PosX = 562, PosY = -1270, PosZ = 16, CamX = 552, CamY = -1275.82, CamZ = 21.61, lookAtX = 552, lookAtY = -1276.77, lookAtZ = 21.29}, [3] = {ID = {{533, 1973100} ,{555, 1943400} ,{507, 2041200} ,{521, 2427500} ,{461, 2427500} ,{566, 1995500} ,{551, 1972700} ,{400, 1970400} ,{558, 1863600} ,{549, 1824800} ,{579, 1902000} ,{576, 1797400} ,{526, 1781400} ,{517, 1772300} ,{575, 1763200} ,{561, 1822100} }, vPosX = 1942.5, vPosY = 2052, vPosZ = 11, PosX = 1946, PosY = 2068, PosZ = 10, CamX = 1930.36, CamY = 2052.78, CamZ = 14.71, lookAtX = 1931.36, lookAtY = 2052.78, lookAtZ = 14.43}, [4] = {ID = {{536, 2201300} ,{567, 2258000} ,{602, 2135100} ,{534, 2128300} ,{426, 2214600} ,{439, 2114600} ,{412, 2114600} ,{587, 2087200} ,{565, 2084900} ,{589, 2082600} ,{542, 2071200} ,{496, 2043900} ,{535, 2043900} ,{405, 2127900} ,{445, 2107300} , Link to comment
Ja[B]er[X]Pro Posted January 29, 2016 Author Share Posted January 29, 2016 شكراً لك اضفت كود عند اخد سيارة ياخد من الاعب 1000 لكن المشكلة عندما لاعب ياخد وفلوسه 0 تصير فلوسه -1000 function getFreeID() local result = dbPoll(dbQuery(db, "SELECT ID FROM VehicleList ORDER BY ID ASC"), -1) newID = false for i, id in pairs (result) do if id["ID"] ~= i then newID = i break end end if newID then return newID else return #result + 1 end end function getVehicleByID(id) v = false for i, veh in ipairs (getElementsByType("vehicle")) do if getElementData(veh, "ID") == id then v = veh break end end return v end function updateVehicleInfo(player) if isElement(player) then local result = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(player))), -1) if type(result) == "table" then setElementData(player, "VehicleInfo", result) end end end addEventHandler("onResourceStart", resourceRoot, function() db = dbConnect("sqlite", "database.db") dbExec(db, "CREATE TABLE IF NOT EXISTS VehicleList (ID, Account, Model, X, Y, Z, RotZ, Colors, Upgrades, Paintjob, Cost, HP)") for i, player in ipairs(getElementsByType("player")) do updateVehicleInfo(player) end end) addEvent("onOpenGui", true) addEventHandler("onOpenGui", root, function() updateVehicleInfo(source) end) function destroyVehicle(theVehicle) if isElement(theVehicle) then local Owner = getElementData(theVehicle, "Owner") if Owner then local x, y, z = getElementPosition(theVehicle) local _, _, rz = getElementRotation(theVehicle) local r1, g1, b1, r2, g2, b2 = getVehicleColor(theVehicle, true) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 upgrade = "" for _, upgradee in ipairs (getVehicleUpgrades(theVehicle)) do if upgrade == "" then upgrade = upgradee else upgrade = upgrade..","..upgradee end end local Paintjob = getVehiclePaintjob(theVehicle) or 3 local id = getElementData(theVehicle, "ID") dbExec(db, "UPDATE VehicleList SET X = ?, Y = ?, Z = ?, RotZ = ?, HP = ?, Colors = ?, Upgrades = ?, Paintjob = ? WHERE Account = ? AND ID = ?", x, y, z, rz, getElementHealth(theVehicle), color, upgrade, Paintjob, getAccountName(getPlayerAccount(Owner)), id) updateVehicleInfo(Owner) local attached = getAttachedElements(theVehicle) if (attached) then for k,element in ipairs(attached) do if getElementType(element) == "blip" then destroyElement(element) end end end end destroyElement(theVehicle) end end addEvent("onBuyNewVehicle", true) addEventHandler("onBuyNewVehicle", root, function(Model, cost, r1, g1, b1, r2, g2, b2) abc = false local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1) for i, data in ipairs (data) do if data["Model"] == Model then abc = true break end end if #data >= 5 then outputChatBox("[Vehicle System] #FF0000Sorry, but Max vehicles is 5 only.", source, 255, 85, 0, true) return end if abc then outputChatBox("[Vehicle System] #FF0000You already bought this vehicle before.", source, 255, 85, 0, true) return end if (getElementData(source, "Money") or 0) >= tonumber(cost) then setElementData(source, "Money", getElementData(source, "Money") - cost) local x, y, z = getElementPosition(source) local _, _, rz = getElementRotation(source) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 vehicle = createVehicle(Model, x-5, y+5, z, 0, 0, rz) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) setElementData(vehicle, "Owner", source) local NewID = getFreeID() setElementData(vehicle, "ID", NewID) dbExec(db, "INSERT INTO VehicleList VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", NewID, getAccountName(getPlayerAccount(source)), Model, x-5, y+5, z, rz, color, "", 3, cost, 1000) outputChatBox("[Vehicle System] #FFFF00You Bought: #00FFFF"..getVehicleNameFromModel(Model), source, 255, 85, 0, true) outputChatBox("[Vehicle System] #FFFF00Cost: #00FF00$"..cost, source, 255, 85, 0, true) updateVehicleInfo(source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) else outputChatBox("[Vehicle System] #FF0000You don't have enough money.", source, 255, 85, 0, true) end end) vv = {} addEvent("SpawnMyVehicle", true) addEventHandler("SpawnMyVehicle", root, function(id) local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then if getVehicleByID(id) then outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #58FAF4is already spawned.", source, 255, 85, 0, true) else local color = split(data[1]["Colors"], ',') r1 = color[1] or 255 g1 = color[2] or 255 b1 = color[3] or 255 r2 = color[4] or 255 g2 = color[5] or 255 b2 = color[6] or 255 vehicle = createVehicle(data[1]["Model"], data[1]["X"], data[1]["Y"], data[1]["Z"], 0, 0, data[1]["RotZ"]) setElementData(vehicle, "ID", id) local upd = split(tostring(data[1]["Upgrades"]), ',') for i, upgrade in ipairs(upd) do addVehicleUpgrade(vehicle, upgrade) end local Paintjob = data[1]["Paintjob"] or 3 setVehiclePaintjob(vehicle, Paintjob) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) if data[1]["HP"] <= 255.5 then data[1]["HP"] = 255 end setElementHealth(vehicle, data[1]["HP"]) setElementData(vehicle, "Owner", source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #00FF00has been spawned.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #FF0000There might be problem with this vehicle, please call an admin.", source, 255, 85, 0, true) end end) addEvent("DestroyMyVehicle", true) addEventHandler("DestroyMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then destroyVehicle(vehicle) outputChatBox ("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #FF0000has been destroyed.", source, 255, 85, 0, true) else outputChatBox("[Vehicle System] #FF0000Select the Vehicle that you want to destroy.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FF0000is not spawned.", source, 255, 85, 0, true) end end) addEvent("LightsMyVehicle", true) addEventHandler("LightsMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local Vehicle = getPedOccupiedVehicle(source) if Vehicle == vehicle then if getVehicleOverrideLights(vehicle) ~= 2 then setVehicleOverrideLights(vehicle, 2) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #00FF00lights turned on.", source, 255, 85, 0, true) elseif getVehicleOverrideLights(vehicle) ~= 1 then setVehicleOverrideLights(vehicle, 1) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #FF0000lights turned off.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #FF0000You aren't in the vehicle!", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FF0000is not spawned.", source, 255, 85, 0, true) end end) addEvent("LockMyVehicle", true) addEventHandler("LockMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then if not isVehicleLocked(vehicle) then setVehicleLocked(vehicle, true) setVehicleDoorsUndamageable(vehicle, true) setVehicleDoorState(vehicle, 0, 0) setVehicleDoorState(vehicle, 1, 0) setVehicleDoorState(vehicle, 2, 0) setVehicleDoorState(vehicle, 3, 0) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #FF0000locked.", source, 255, 85, 0, true) elseif isVehicleLocked(vehicle) then setVehicleLocked(vehicle, false) setVehicleDoorsUndamageable(vehicle, false) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #00FF00unlocked.", source, 255, 85, 0, true) end Link to comment
MR.GRAND Posted January 29, 2016 Share Posted January 29, 2016 function getFreeID() local result = dbPoll(dbQuery(db, "SELECT ID FROM VehicleList ORDER BY ID ASC"), -1) newID = false for i, id in pairs (result) do if id["ID"] ~= i then newID = i break end end if newID then return newID else return #result + 1 end end function getVehicleByID(id) v = false for i, veh in ipairs (getElementsByType("vehicle")) do if getElementData(veh, "ID") == id then v = veh break end end return v end function updateVehicleInfo(player) if isElement(player) then local result = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(player))), -1) if type(result) == "table" then setElementData(player, "VehicleInfo", result) end end end addEventHandler("onResourceStart", resourceRoot, function() db = dbConnect("sqlite", "database.db") dbExec(db, "CREATE TABLE IF NOT EXISTS VehicleList (ID, Account, Model, X, Y, Z, RotZ, Colors, Upgrades, Paintjob, Cost, HP)") for i, player in ipairs(getElementsByType("player")) do updateVehicleInfo(player) end end) addEvent("onOpenGui", true) addEventHandler("onOpenGui", root, function() updateVehicleInfo(source) end) function destroyVehicle(theVehicle) if isElement(theVehicle) then local Owner = getElementData(theVehicle, "Owner") if Owner then local x, y, z = getElementPosition(theVehicle) local _, _, rz = getElementRotation(theVehicle) local r1, g1, b1, r2, g2, b2 = getVehicleColor(theVehicle, true) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 upgrade = "" for _, upgradee in ipairs (getVehicleUpgrades(theVehicle)) do if upgrade == "" then upgrade = upgradee else upgrade = upgrade..","..upgradee end end local Paintjob = getVehiclePaintjob(theVehicle) or 3 local id = getElementData(theVehicle, "ID") dbExec(db, "UPDATE VehicleList SET X = ?, Y = ?, Z = ?, RotZ = ?, HP = ?, Colors = ?, Upgrades = ?, Paintjob = ? WHERE Account = ? AND ID = ?", x, y, z, rz, getElementHealth(theVehicle), color, upgrade, Paintjob, getAccountName(getPlayerAccount(Owner)), id) updateVehicleInfo(Owner) local attached = getAttachedElements(theVehicle) if (attached) then for k,element in ipairs(attached) do if getElementType(element) == "blip" then destroyElement(element) end end end end destroyElement(theVehicle) end end addEvent("onBuyNewVehicle", true) addEventHandler("onBuyNewVehicle", root, function(Model, cost, r1, g1, b1, r2, g2, b2) abc = false local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1) for i, data in ipairs (data) do if data["Model"] == Model then abc = true break end end if #data >= 5 then outputChatBox("[Vehicle System] #FF0000Sorry, but Max vehicles is 5 only.", source, 255, 85, 0, true) return end if abc then outputChatBox("[Vehicle System] #FF0000You already bought this vehicle before.", source, 255, 85, 0, true) return end if (getElementData(source, "Money") or 0) >= tonumber(cost) then setElementData(source, "Money", getElementData(source, "Money") - cost) local x, y, z = getElementPosition(source) local _, _, rz = getElementRotation(source) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 vehicle = createVehicle(Model, x-5, y+5, z, 0, 0, rz) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) setElementData(vehicle, "Owner", source) local NewID = getFreeID() setElementData(vehicle, "ID", NewID) dbExec(db, "INSERT INTO VehicleList VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", NewID, getAccountName(getPlayerAccount(source)), Model, x-5, y+5, z, rz, color, "", 3, cost, 1000) outputChatBox("[Vehicle System] #FFFF00You Bought: #00FFFF"..getVehicleNameFromModel(Model), source, 255, 85, 0, true) outputChatBox("[Vehicle System] #FFFF00Cost: #00FF00$"..cost, source, 255, 85, 0, true) updateVehicleInfo(source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) else outputChatBox("[Vehicle System] #FF0000You don't have enough money.", source, 255, 85, 0, true) end end) vv = {} addEvent("SpawnMyVehicle", true) addEventHandler("SpawnMyVehicle", root, function(id) local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then if getVehicleByID(id) then outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #58FAF4is already spawned.", source, 255, 85, 0, true) else local color = split(data[1]["Colors"], ',') r1 = color[1] or 255 g1 = color[2] or 255 b1 = color[3] or 255 r2 = color[4] or 255 g2 = color[5] or 255 b2 = color[6] or 255 vehicle = createVehicle(data[1]["Model"], data[1]["X"], data[1]["Y"], data[1]["Z"], 0, 0, data[1]["RotZ"]) setElementData(vehicle, "ID", id) local upd = split(tostring(data[1]["Upgrades"]), ',') for i, upgrade in ipairs(upd) do addVehicleUpgrade(vehicle, upgrade) end local Paintjob = data[1]["Paintjob"] or 3 setVehiclePaintjob(vehicle, Paintjob) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) if data[1]["HP"] <= 255.5 then data[1]["HP"] = 255 end setElementHealth(vehicle, data[1]["HP"]) setElementData(vehicle, "Owner", source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #00FF00has been spawned.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #FF0000There might be problem with this vehicle, please call an admin.", source, 255, 85, 0, true) end end) addEvent("DestroyMyVehicle", true) addEventHandler("DestroyMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then destroyVehicle(vehicle) outputChatBox ("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #FF0000has been destroyed.", source, 255, 85, 0, true) else outputChatBox("[Vehicle System] #FF0000Select the Vehicle that you want to destroy.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FF0000is not spawned.", source, 255, 85, 0, true) end end) addEvent("LightsMyVehicle", true) addEventHandler("LightsMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local Vehicle = getPedOccupiedVehicle(source) if Vehicle == vehicle then if getVehicleOverrideLights(vehicle) ~= 2 then setVehicleOverrideLights(vehicle, 2) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #00FF00lights turned on.", source, 255, 85, 0, true) elseif getVehicleOverrideLights(vehicle) ~= 1 then setVehicleOverrideLights(vehicle, 1) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #FF0000lights turned off.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #FF0000You aren't in the vehicle!", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FF0000is not spawned.", source, 255, 85, 0, true) end end) addEvent("LockMyVehicle", true) addEventHandler("LockMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then if not isVehicleLocked(vehicle) then setVehicleLocked(vehicle, true) setVehicleDoorsUndamageable(vehicle, true) setVehicleDoorState(vehicle, 0, 0) setVehicleDoorState(vehicle, 1, 0) setVehicleDoorState(vehicle, 2, 0) setVehicleDoorState(vehicle, 3, 0) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #FF0000locked.", source, 255, 85, 0, true) elseif isVehicleLocked(vehicle) then setVehicleLocked(vehicle, false) setVehicleDoorsUndamageable(vehicle, false) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #00FF00unlocked.", source, 255, 85, 0, true) end Link to comment
Ahmed Ly Posted January 29, 2016 Share Posted January 29, 2016 شكراً لكاضفت كود عند اخد سيارة ياخد من الاعب 1000 لكن المشكلة عندما لاعب ياخد وفلوسه 0 تصير فلوسه -1000 function getFreeID() local result = dbPoll(dbQuery(db, "SELECT ID FROM VehicleList ORDER BY ID ASC"), -1) newID = false for i, id in pairs (result) do if id["ID"] ~= i then newID = i break end end if newID then return newID else return #result + 1 end end function getVehicleByID(id) v = false for i, veh in ipairs (getElementsByType("vehicle")) do if getElementData(veh, "ID") == id then v = veh break end end return v end function updateVehicleInfo(player) if isElement(player) then local result = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(player))), -1) if type(result) == "table" then setElementData(player, "VehicleInfo", result) end end end addEventHandler("onResourceStart", resourceRoot, function() db = dbConnect("sqlite", "database.db") dbExec(db, "CREATE TABLE IF NOT EXISTS VehicleList (ID, Account, Model, X, Y, Z, RotZ, Colors, Upgrades, Paintjob, Cost, HP)") for i, player in ipairs(getElementsByType("player")) do updateVehicleInfo(player) end end) addEvent("onOpenGui", true) addEventHandler("onOpenGui", root, function() updateVehicleInfo(source) end) function destroyVehicle(theVehicle) if isElement(theVehicle) then local Owner = getElementData(theVehicle, "Owner") if Owner then local x, y, z = getElementPosition(theVehicle) local _, _, rz = getElementRotation(theVehicle) local r1, g1, b1, r2, g2, b2 = getVehicleColor(theVehicle, true) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 upgrade = "" for _, upgradee in ipairs (getVehicleUpgrades(theVehicle)) do if upgrade == "" then upgrade = upgradee else upgrade = upgrade..","..upgradee end end local Paintjob = getVehiclePaintjob(theVehicle) or 3 local id = getElementData(theVehicle, "ID") dbExec(db, "UPDATE VehicleList SET X = ?, Y = ?, Z = ?, RotZ = ?, HP = ?, Colors = ?, Upgrades = ?, Paintjob = ? WHERE Account = ? AND ID = ?", x, y, z, rz, getElementHealth(theVehicle), color, upgrade, Paintjob, getAccountName(getPlayerAccount(Owner)), id) updateVehicleInfo(Owner) local attached = getAttachedElements(theVehicle) if (attached) then for k,element in ipairs(attached) do if getElementType(element) == "blip" then destroyElement(element) end end end end destroyElement(theVehicle) end end addEvent("onBuyNewVehicle", true) addEventHandler("onBuyNewVehicle", root, function(Model, cost, r1, g1, b1, r2, g2, b2) abc = false local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1) for i, data in ipairs (data) do if data["Model"] == Model then abc = true break end end if #data >= 5 then outputChatBox("[Vehicle System] #FF0000Sorry, but Max vehicles is 5 only.", source, 255, 85, 0, true) return end if abc then outputChatBox("[Vehicle System] #FF0000You already bought this vehicle before.", source, 255, 85, 0, true) return end if (getElementData(source, "Money") or 0) >= tonumber(cost) then setElementData(source, "Money", getElementData(source, "Money") - cost) local x, y, z = getElementPosition(source) local _, _, rz = getElementRotation(source) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 vehicle = createVehicle(Model, x-5, y+5, z, 0, 0, rz) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) setElementData(vehicle, "Owner", source) local NewID = getFreeID() setElementData(vehicle, "ID", NewID) dbExec(db, "INSERT INTO VehicleList VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", NewID, getAccountName(getPlayerAccount(source)), Model, x-5, y+5, z, rz, color, "", 3, cost, 1000) outputChatBox("[Vehicle System] #FFFF00You Bought: #00FFFF"..getVehicleNameFromModel(Model), source, 255, 85, 0, true) outputChatBox("[Vehicle System] #FFFF00Cost: #00FF00$"..cost, source, 255, 85, 0, true) updateVehicleInfo(source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) else outputChatBox("[Vehicle System] #FF0000You don't have enough money.", source, 255, 85, 0, true) end end) vv = {} addEvent("SpawnMyVehicle", true) addEventHandler("SpawnMyVehicle", root, function(id) local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then if getVehicleByID(id) then outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #58FAF4is already spawned.", source, 255, 85, 0, true) else local color = split(data[1]["Colors"], ',') r1 = color[1] or 255 g1 = color[2] or 255 b1 = color[3] or 255 r2 = color[4] or 255 g2 = color[5] or 255 b2 = color[6] or 255 vehicle = createVehicle(data[1]["Model"], data[1]["X"], data[1]["Y"], data[1]["Z"], 0, 0, data[1]["RotZ"]) setElementData(vehicle, "ID", id) local upd = split(tostring(data[1]["Upgrades"]), ',') for i, upgrade in ipairs(upd) do addVehicleUpgrade(vehicle, upgrade) end local Paintjob = data[1]["Paintjob"] or 3 setVehiclePaintjob(vehicle, Paintjob) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) if data[1]["HP"] <= 255.5 then data[1]["HP"] = 255 end setElementHealth(vehicle, data[1]["HP"]) setElementData(vehicle, "Owner", source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #00FF00has been spawned.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #FF0000There might be problem with this vehicle, please call an admin.", source, 255, 85, 0, true) end end) addEvent("DestroyMyVehicle", true) addEventHandler("DestroyMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then destroyVehicle(vehicle) outputChatBox ("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #FF0000has been destroyed.", source, 255, 85, 0, true) else outputChatBox("[Vehicle System] #FF0000Select the Vehicle that you want to destroy.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FF0000is not spawned.", source, 255, 85, 0, true) end end) addEvent("LightsMyVehicle", true) addEventHandler("LightsMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local Vehicle = getPedOccupiedVehicle(source) if Vehicle == vehicle then if getVehicleOverrideLights(vehicle) ~= 2 then setVehicleOverrideLights(vehicle, 2) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #00FF00lights turned on.", source, 255, 85, 0, true) elseif getVehicleOverrideLights(vehicle) ~= 1 then setVehicleOverrideLights(vehicle, 1) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #FF0000lights turned off.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #FF0000You aren't in the vehicle!", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FF0000is not spawned.", source, 255, 85, 0, true) end end) addEvent("LockMyVehicle", true) addEventHandler("LockMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then if not isVehicleLocked(vehicle) then setVehicleLocked(vehicle, true) setVehicleDoorsUndamageable(vehicle, true) setVehicleDoorState(vehicle, 0, 0) setVehicleDoorState(vehicle, 1, 0) setVehicleDoorState(vehicle, 2, 0) setVehicleDoorState(vehicle, 3, 0) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #FF0000locked.", source, 255, 85, 0, true) elseif isVehicleLocked(vehicle) then setVehicleLocked(vehicle, false) Link to comment
MR.GRAND Posted January 29, 2016 Share Posted January 29, 2016 ممكن اعرف ليش زيادة الردود اللي مالها معنى ؟ خلص عطيته اللي يبغاه ض1 Link to comment
Ja[B]er[X]Pro Posted January 30, 2016 Author Share Posted January 30, 2016 function getFreeID() local result = dbPoll(dbQuery(db, "SELECT ID FROM VehicleList ORDER BY ID ASC"), -1) newID = false for i, id in pairs (result) do if id["ID"] ~= i then newID = i break end end if newID then return newID else return #result + 1 end end function getVehicleByID(id) v = false for i, veh in ipairs (getElementsByType("vehicle")) do if getElementData(veh, "ID") == id then v = veh break end end return v end function updateVehicleInfo(player) if isElement(player) then local result = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(player))), -1) if type(result) == "table" then setElementData(player, "VehicleInfo", result) end end end addEventHandler("onResourceStart", resourceRoot, function() db = dbConnect("sqlite", "database.db") dbExec(db, "CREATE TABLE IF NOT EXISTS VehicleList (ID, Account, Model, X, Y, Z, RotZ, Colors, Upgrades, Paintjob, Cost, HP)") for i, player in ipairs(getElementsByType("player")) do updateVehicleInfo(player) end end) addEvent("onOpenGui", true) addEventHandler("onOpenGui", root, function() updateVehicleInfo(source) end) function destroyVehicle(theVehicle) if isElement(theVehicle) then local Owner = getElementData(theVehicle, "Owner") if Owner then local x, y, z = getElementPosition(theVehicle) local _, _, rz = getElementRotation(theVehicle) local r1, g1, b1, r2, g2, b2 = getVehicleColor(theVehicle, true) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 upgrade = "" for _, upgradee in ipairs (getVehicleUpgrades(theVehicle)) do if upgrade == "" then upgrade = upgradee else upgrade = upgrade..","..upgradee end end local Paintjob = getVehiclePaintjob(theVehicle) or 3 local id = getElementData(theVehicle, "ID") dbExec(db, "UPDATE VehicleList SET X = ?, Y = ?, Z = ?, RotZ = ?, HP = ?, Colors = ?, Upgrades = ?, Paintjob = ? WHERE Account = ? AND ID = ?", x, y, z, rz, getElementHealth(theVehicle), color, upgrade, Paintjob, getAccountName(getPlayerAccount(Owner)), id) updateVehicleInfo(Owner) local attached = getAttachedElements(theVehicle) if (attached) then for k,element in ipairs(attached) do if getElementType(element) == "blip" then destroyElement(element) end end end end destroyElement(theVehicle) end end addEvent("onBuyNewVehicle", true) addEventHandler("onBuyNewVehicle", root, function(Model, cost, r1, g1, b1, r2, g2, b2) abc = false local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1) for i, data in ipairs (data) do if data["Model"] == Model then abc = true break end end if #data >= 5 then outputChatBox("[Vehicle System] #FF0000Sorry, but Max vehicles is 5 only.", source, 255, 85, 0, true) return end if abc then outputChatBox("[Vehicle System] #FF0000You already bought this vehicle before.", source, 255, 85, 0, true) return end if (getElementData(source, "Money") or 0) >= tonumber(cost) then setElementData(source, "Money", getElementData(source, "Money") - cost) local x, y, z = getElementPosition(source) local _, _, rz = getElementRotation(source) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 vehicle = createVehicle(Model, x-5, y+5, z, 0, 0, rz) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) setElementData(vehicle, "Owner", source) local NewID = getFreeID() setElementData(vehicle, "ID", NewID) dbExec(db, "INSERT INTO VehicleList VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", NewID, getAccountName(getPlayerAccount(source)), Model, x-5, y+5, z, rz, color, "", 3, cost, 1000) outputChatBox("[Vehicle System] #FFFF00You Bought: #00FFFF"..getVehicleNameFromModel(Model), source, 255, 85, 0, true) outputChatBox("[Vehicle System] #FFFF00Cost: #00FF00$"..cost, source, 255, 85, 0, true) updateVehicleInfo(source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) else outputChatBox("[Vehicle System] #FF0000You don't have enough money.", source, 255, 85, 0, true) end end) vv = {} addEvent("SpawnMyVehicle", true) addEventHandler("SpawnMyVehicle", root, function(id) local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then if getVehicleByID(id) then outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #58FAF4is already spawned.", source, 255, 85, 0, true) else local color = split(data[1]["Colors"], ',') r1 = color[1] or 255 g1 = color[2] or 255 b1 = color[3] or 255 r2 = color[4] or 255 g2 = color[5] or 255 b2 = color[6] or 255 vehicle = createVehicle(data[1]["Model"], data[1]["X"], data[1]["Y"], data[1]["Z"], 0, 0, data[1]["RotZ"]) setElementData(vehicle, "ID", id) local upd = split(tostring(data[1]["Upgrades"]), ',') for i, upgrade in ipairs(upd) do addVehicleUpgrade(vehicle, upgrade) end local Paintjob = data[1]["Paintjob"] or 3 setVehiclePaintjob(vehicle, Paintjob) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) if data[1]["HP"] <= 255.5 then data[1]["HP"] = 255 end setElementHealth(vehicle, data[1]["HP"]) setElementData(vehicle, "Owner", source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #00FF00has been spawned.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #FF0000There might be problem with this vehicle, please call an admin.", source, 255, 85, 0, true) end end) addEvent("DestroyMyVehicle", true) addEventHandler("DestroyMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then destroyVehicle(vehicle) outputChatBox ("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(data[1]["Model"]).." #FF0000has been destroyed.", source, 255, 85, 0, true) else outputChatBox("[Vehicle System] #FF0000Select the Vehicle that you want to destroy.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FF0000is not spawned.", source, 255, 85, 0, true) end end) addEvent("LightsMyVehicle", true) addEventHandler("LightsMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local Vehicle = getPedOccupiedVehicle(source) if Vehicle == vehicle then if getVehicleOverrideLights(vehicle) ~= 2 then setVehicleOverrideLights(vehicle, 2) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #00FF00lights turned on.", source, 255, 85, 0, true) elseif getVehicleOverrideLights(vehicle) ~= 1 then setVehicleOverrideLights(vehicle, 1) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #FF0000lights turned off.", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #FF0000You aren't in the vehicle!", source, 255, 85, 0, true) end else outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FF0000is not spawned.", source, 255, 85, 0, true) end end) addEvent("LockMyVehicle", true) addEventHandler("LockMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then if not isVehicleLocked(vehicle) then setVehicleLocked(vehicle, true) setVehicleDoorsUndamageable(vehicle, true) setVehicleDoorState(vehicle, 0, 0) setVehicleDoorState(vehicle, 1, 0) setVehicleDoorState(vehicle, 2, 0) setVehicleDoorState(vehicle, 3, 0) outputChatBox("[Vehicle System] #58FAF4Your Vehicle #FFFF00"..getVehicleNameFromModel(getElementModel(vehicle)).." #FF0000locked.", source, 255, 85, 0, true) elseif isVehicleLocked(vehicle) then setVehicleLocked(vehicle, false) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now