swag_k_dog Posted October 29, 2017 Share Posted October 29, 2017 CLIENT: local Key = 'F5' vehiclesTable = { { 'Super GT', 506, 10000, {551.31152, -1285.07727, 18.87188, 560.67841, -1284.27649, 17.24824} }, { 'Windsor', 555, 66600, {551.31152, -1285.07727, 18.87188, 560.67841, -1284.27649, 17.24824} }, { 'Lamborghini', 415, 450000, {551.31152, -1285.07727, 18.87188, 560.67841, -1284.27649, 17.24824} }, }; local buyingMarker = createMarker( 551.51257, -1262.61926, 16.25465, 'cylinder', 1.2, 200, 150, 50, 255 ) local screenW, screenH = guiGetScreenSize() Cplayer = getLocalPlayer( ) setElementData( Cplayer, 'VehiclesSystem;WarpToVehicle', nil ) setElementData( root, 'vehiclesSystem;dimension', 1 ) GUIEditor = { checkbox = {}, label = {}, button = {}, window = {}, gridlist = {} } GUIEditor.window[1] = guiCreateWindow((screenW - 700) / 2, (screenH - 374) / 2, 700, 374, ". : Vehicles System : .", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) guiSetVisible(GUIEditor.window[1], false) GUIEditor.gridlist[1] = guiCreateGridList(10, 32, 511, 332, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "ID", 0.2) guiGridListAddColumn(GUIEditor.gridlist[1], "Vehicle", 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], "Price", 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], "Subscription", 0.3) GUIEditor.button[1] = guiCreateButton(531, 42, 156, 24, "Create Vehicle", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFEFB00") GUIEditor.button[2] = guiCreateButton(531, 76, 156, 24, "Destroy Vehicle", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFEFB00") GUIEditor.button[3] = guiCreateButton(531, 125, 156, 24, "Lock/Unlock Vehicle", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FF00ADFE") GUIEditor.button[4] = guiCreateButton(531, 159, 156, 24, "On/Off Engine", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FF00ADFE") GUIEditor.button[5] = guiCreateButton(532, 193, 155, 24, "On/Off Lights", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FF00ADFE") GUIEditor.button[6] = guiCreateButton(532, 242, 155, 24, "Warp To Buy Place", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[6], "NormalTextColour", "FFFE7100") GUIEditor.button[7] = guiCreateButton(533, 340, 154, 24, "X", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[7], "NormalTextColour", "FFFE0000") GUIEditor.button[8] = guiCreateButton(532, 276, 154, 24, "Sell Vehicle", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[8], "NormalTextColour", "FFFE7100") GUIEditor.label[1] = guiCreateLabel(531, 100, 156, 15, "ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") guiLabelSetColor(GUIEditor.label[1], 176, 176, 176) guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[1], "bottom") GUIEditor.label[2] = guiCreateLabel(531, 217, 156, 15, "ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") guiLabelSetColor(GUIEditor.label[2], 176, 176, 176) guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[2], "bottom") GUIEditor.checkbox[1] = guiCreateCheckBox(553, 309, 133, 21, "Warp To Vehicle", false, false, GUIEditor.window[1]) guiSetProperty(GUIEditor.checkbox[1], "NormalTextColour", "FFF9F000") ----------#Window2 buyplace = guiCreateWindow(screenW - 266 - 10, (screenH - 491) / 2, 266, 491, ". : Vehicles System : .", false) guiWindowSetSizable(buyplace, false) guiSetAlpha(buyplace, 1.00) guiSetVisible(buyplace, false) list_buyplace = guiCreateGridList(10, 29, 246, 313, false, buyplace) guiGridListSetSortingEnabled(list_buyplace, false) guiGridListAddColumn(list_buyplace, "#", 0.11) guiGridListAddColumn(list_buyplace, "Vehicle", 0.5) guiGridListAddColumn(list_buyplace, "Price", 0.5) buy_buyplace = guiCreateButton(46, 352, 172, 22, "Buy Vehicle", false, buyplace) guiSetProperty(buy_buyplace, "NormalTextColour", "FF00FE00") rent_buyplace = guiCreateButton(46, 423, 172, 22, "Rent Vehicle", false, buyplace) guiSetProperty(rent_buyplace, "NormalTextColour", "FFF5FD00") label_buyplace = guiCreateLabel(10, 384, 246, 29, "Note : You Can Also Rent Vehicle,\nRent Time : 5 Minutes, Price : 1,000$ .", false, buyplace) guiLabelSetColor(label_buyplace, 254, 84, 0) guiLabelSetHorizontalAlign(label_buyplace, "center", false) x_buyplace = guiCreateButton(46, 455, 172, 22, "X", false, buyplace) guiSetProperty(x_buyplace, "NormalTextColour", "FFFE0005") function addCarsToBuy( ) guiGridListClear( list_buyplace ) for _, vehicle in ipairs( vehiclesTable ) do local Price, value = string.gsub( vehicle[3], '^(-?%d+)(%d%d%d)', '%1,%2' ) local item = guiGridListAddRow( list_buyplace ) local cN = guiGridListSetItemText( list_buyplace, item, 2, vehicle[1], false, false ) local cP = guiGridListSetItemText( list_buyplace, item, 3, Price..'$', false, false ) local num = guiGridListSetItemText( list_buyplace, item, 1, _..'-', false, false ) local cD1 = guiGridListSetItemData( list_buyplace, item, 1, vehicle[4] ) local cD2 = guiGridListSetItemData( list_buyplace, item, 2, vehicle[2] ) local cD3 = guiGridListSetItemData( list_buyplace, item, 3, vehicle[3] ) guiGridListSetItemColor( list_buyplace, item, 2, 200, 200, 50 ) guiGridListSetItemColor( list_buyplace, item, 3, 50, 200, 200 ) guiGridListSetItemColor( list_buyplace, item, 1, 200, 100, 0 ) end end addCarsToBuy( ) function clickElements( ) if ( source == GUIEditor.button[7] ) then guiSetVisible( GUIEditor.window[1], false ) showCursor( false ) elseif ( source == GUIEditor.checkbox[1] ) then local Sel = guiCheckBoxGetSelected( GUIEditor.checkbox[1] ) if ( Sel == true ) then setElementData( Cplayer, 'VehiclesSystem;WarpToVehicle', 'Enabled' ) else setElementData( Cplayer, 'VehiclesSystem;WarpToVehicle', nil ) end elseif ( source == x_buyplace ) then fadeCamera( false ) setTimer( fadeCamera, 1500, 1, true ) guiSetVisible( buyplace, false ) showCursor( false ) setTimer( setCameraTarget, 1500, 1, Cplayer ) triggerServerEvent( 'VehiclesSystem;createViewVehicle', Cplayer, nil, nil, nil, nil, 'close' ) setElementDimension( Cplayer, 0 ) addCarsToBuy( ) elseif ( source == list_buyplace ) then local Sel = guiGridListGetSelectedItem( list_buyplace ) if ( Sel == -1 ) then return end local Data = guiGridListGetItemData( list_buyplace, Sel, 1 ) local x1, y1, z1, x2, y2, z2 = unpack( Data ) setCameraMatrix( x1, y1, z1, x2, y2, z2 ) if ( isElement( viewvehicle ) ) then if ( getElementModel( viewvehicle ) ) == guiGridListGetItemData( list_buyplace, Sel, 2 ) then return end destroyElement( viewvehicle ) end triggerServerEvent( 'VehiclesSystem;createViewVehicle', Cplayer, guiGridListGetItemData( list_buyplace, Sel, 2 ), x2, y2, z2, 'view' ) elseif ( source == rent_buyplace ) then local Sel = guiGridListGetSelectedItem( list_buyplace ) if ( Sel == -1 ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, Please select vehicle #FF0000!', 255, 255, 255, true ) return end local ID = guiGridListGetItemData( list_buyplace, Sel, 2 ) if ( getPlayerMoney( Cplayer ) < 1000 ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, You don\'t have enough money #FF0000!', 255, 255, 255, true ) return end guiSetVisible( buyplace, false ) showCursor( false ) setTimer( setCameraTarget, 1500, 1, Cplayer ) triggerServerEvent( 'VehiclesSystem;createRentVehicle', Cplayer, ID, guiGridListGetItemText( list_buyplace, Sel, 2 ) ) triggerServerEvent( 'VehiclesSystem;createViewVehicle', Cplayer, nil, nil, nil, nil, 'close' ) elseif ( source == buy_buyplace ) then local Sel = guiGridListGetSelectedItem( list_buyplace ) if ( Sel == -1 ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, Please select vehicle #FF0000!', 255, 255, 255, true ) return end local ID = guiGridListGetItemData( list_buyplace, Sel, 2 ) local vN = guiGridListGetItemText( list_buyplace, Sel, 2 ) local Pr = guiGridListGetItemData( list_buyplace, Sel, 3 ) if ( getPlayerMoney( Cplayer ) < Pr ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, You don\'t have enough money #FF0000!', 255, 255, 255, true ) return end triggerServerEvent( 'VehiclesSystem;buyCurrentCar', Cplayer, ID, vN, Pr ) elseif ( source == GUIEditor.button[1] ) then local Sel = guiGridListGetSelectedItem( GUIEditor.gridlist[1] ) if ( Sel == -1 ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, Please select vehicle #FF0000!', 255, 255, 255, true ) return end local ID = guiGridListGetItemText( GUIEditor.gridlist[1], Sel, 1 ) triggerServerEvent( 'VehiclesSystem;createPersonalVehicle', Cplayer, ID ) guiSetVisible( GUIEditor.window[1], false ) showCursor( false ) guiSetEnabled( GUIEditor.button[1], false ) setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[1], true ) elseif ( source == GUIEditor.button[2] ) then triggerServerEvent( 'VehiclesSystem;destroyPersonalVehicle', Cplayer ) guiSetEnabled( GUIEditor.button[2], false ) setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[2], true ) elseif ( source == GUIEditor.button[3] ) then triggerServerEvent( 'VehiclesSystem;lock/unlockPersonalVehicle', Cplayer ) guiSetEnabled( GUIEditor.button[3], false ) setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[3], true ) elseif ( source == GUIEditor.button[4] ) then triggerServerEvent( 'VehiclesSystem;off/onPersonalVehicle', Cplayer ) guiSetEnabled( GUIEditor.button[4], false ) setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[4], true ) elseif ( source == GUIEditor.button[5] ) then triggerServerEvent( 'VehiclesSystem;off/onLightsPersonalVehicle', Cplayer ) guiSetEnabled( GUIEditor.button[5], false ) setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[5], true ) elseif ( source == GUIEditor.button[8] ) then local Sel = guiGridListGetSelectedItem( GUIEditor.gridlist[1] ) if ( Sel == -1 ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, Please select vehicle #FF0000!', 255, 255, 255, true ) return end local ID = guiGridListGetItemText( GUIEditor.gridlist[1], Sel, 1 ) triggerServerEvent( 'VehiclesSystem;sellMyPersonalVehicle', Cplayer, tonumber(ID), guiGridListGetItemData( GUIEditor.gridlist[1], Sel, 3 ) ) guiSetEnabled( GUIEditor.button[8], false ) setTimer( guiSetEnabled, 2000, 1, GUIEditor.button[8], true ) elseif ( source == GUIEditor.button[6] ) then fadeCamera( false ) setTimer( fadeCamera, 1500, 1, true ) setTimer( setElementPosition, 1500, 1, Cplayer, 550.72430, -1247.76538, 17.83468 ) guiSetVisible( GUIEditor.window[1], false ) showCursor( false ) end end addEventHandler( 'onClientGUIClick', root, clickElements ) function refreshMyList( Table ) guiGridListClear( GUIEditor.gridlist[1] ) for i, _ in ipairs( Table ) do local Price, value = string.gsub( Table[i].vehPrice / 2, '^(-?%d+)(%d%d%d)', '%1,%2' ) local item = guiGridListAddRow( GUIEditor.gridlist[1] ) guiGridListSetItemText( GUIEditor.gridlist[1], item, 1, Table[i].vehID, false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], item, 2, Table[i].vehName, false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], item, 3, Price..'$', false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], item, 4, Table[i].Subscription, false, false ) guiGridListSetItemData( GUIEditor.gridlist[1], item, 3, Table[i].vehPrice / 2 ) end end addEvent( 'VehiclesSystem;putMyVehicles', true ) addEventHandler( 'VehiclesSystem;putMyVehicles', root, refreshMyList ) addEvent( 'VehiclesSystem;gridListAddRent', true ) addEventHandler( 'VehiclesSystem;gridListAddRent', root, function( ID, veh ) rentRow = guiGridListAddRow( GUIEditor.gridlist[1] ) guiGridListSetItemText( GUIEditor.gridlist[1], rentRow, 1, ID, false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], rentRow, 2, veh, false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], rentRow, 3, '1,000$', false, false ) guiGridListSetItemText( GUIEditor.gridlist[1], rentRow, 4, '5 Minutes', false, false ) guiSetEnabled( buy_buyplace, false ) guiSetEnabled( rent_buyplace, false ) guiSetEnabled( list_buyplace, false ) setTimer( function( ) guiGridListRemoveRow( GUIEditor.gridlist[1], rentRow ) guiSetEnabled( buy_buyplace, true ) guiSetEnabled( rent_buyplace, true ) guiSetEnabled( list_buyplace, true ) end, 300000, 1 ) end ) addEvent( 'VehiclesSystem;hideBuyWindow', true ) addEventHandler( 'VehiclesSystem;hideBuyWindow', root, function( ) guiSetVisible( buyplace, false ) showCursor( false ) end ) addEvent( 'VehiclesSystem;emptyMyList', true ) addEventHandler( 'VehiclesSystem;emptyMyList', root, function( ) guiGridListClear( GUIEditor.gridlist[1] ) end ) addEventHandler( 'onClientResourceStart', resourceRoot, function( ) triggerServerEvent( 'refreshMyListS', Cplayer ) end ) addEventHandler( 'onClientMarkerHit', buyingMarker, function( hitElement ) if ( hitElement == Cplayer and getElementDimension( hitElement ) == 0 ) then local x, y, z = getElementPosition( Cplayer ) if ( z <= 20.25465 ) then guiGridListSetSelectedItem( list_buyplace, 0, 1 ) local Sel = guiGridListGetSelectedItem( list_buyplace ) if ( Sel == -1 ) then return end local Data = guiGridListGetItemData( list_buyplace, Sel, 1 ) local x1, y1, z1, x2, y2, z2 = unpack( Data ) fadeCamera( false ) setTimer( fadeCamera, 1500, 1, true ) setTimer( setCameraMatrix, 1500, 1, x1, y1, z1, x2, y2, z2 ) if ( isElement( viewvehicle ) ) then if ( getElementModel( viewvehicle ) ) == guiGridListGetItemData( list_buyplace, Sel, 2 ) then return end destroyElement( viewvehicle ) end triggerServerEvent( 'VehiclesSystem;createViewVehicle', Cplayer, guiGridListGetItemData( list_buyplace, Sel, 2 ), x2, y2, z2, 'view' ) setTimer( guiSetVisible, 1500, 1, buyplace, not guiGetVisible( buyplace ) ) setTimer( showCursor, 1500, 1, not isCursorShowing( ) ) end end end, false ) bindKey( Key, 'down', function( ) guiSetVisible( GUIEditor.window[1], not guiGetVisible( GUIEditor.window[1] ) ) showCursor( not isCursorShowing( ) ) end ) SERVER: createBlip ( 551.51257, -1262.61926, 16.25465, 55, 2, 0, 0, 0, 255, 0, 400.0, getRootElement( ) ) local vehDB = dbConnect( 'sqlite', 'Vehicles System - Database.db' ) dbExec( vehDB, ' CREATE TABLE IF NOT EXISTS `VehiclesSystem_Players` (pSerial, vehID, vehName, vehPrice, Subscription) ' ) --dbExec( vehDB, ' DROP TABLE `VehiclesSystem_Players` ' ) vehPers = { }; vehview = { }; function refreshMyList( ) local check = dbQuery( vehDB, ' SELECT * FROM `VehiclesSystem_Players` ' ) local results = dbPoll( check, -1 ) if ( type( results ) == 'table' and #results == 0 or not results ) then triggerClientEvent( root, 'VehiclesSystem;emptyMyList', root ) return end triggerClientEvent( root, 'VehiclesSystem;putMyVehicles', root, results ) end addEvent( 'refreshMyListS', true ) addEventHandler( 'refreshMyListS', root, refreshMyList ) function viewVehiclex( ID, x, y, z, state ) if ( state == 'close' ) then if ( isElement( vehview[source] ) ) then destroyElement( vehview[source] ) end elseif ( state == 'view' ) then if ( isElement( vehview[source] ) ) then if ( getElementModel( vehview[source] ) ) == ID then return end destroyElement( vehview[source] ) end vehview[source] = createVehicle( ID, x, y, z + 0.2, 0, 0, 10 ) setElementDimension( vehview[source], getElementData( root, 'vehiclesSystem;dimension' ) or 1 ) setElementDimension( source, getElementData( root, 'vehiclesSystem;dimension' ) or 1 ) setElementData( root, 'vehiclesSystem;dimension', getElementData( root, 'vehiclesSystem;dimension' ) + 1 or 1 ) end end addEvent( 'VehiclesSystem;createViewVehicle', true ) addEventHandler( 'VehiclesSystem;createViewVehicle', root, viewVehiclex ) addEvent( 'VehiclesSystem;destroyPersonalVehicle', true ) addEventHandler( 'VehiclesSystem;destroyPersonalVehicle', root, function( ) if ( isElement( vehPers[source] ) ) then destroyElement( vehPers[source] ) end end ) addEvent( 'VehiclesSystem;createRentVehicle', true ) addEventHandler( 'VehiclesSystem;createRentVehicle', root, function( ID, vehName ) if ( isElement( vehPers[source] ) ) then destroyElement( vehPers[source] ) end vehPers[source] = createVehicle( ID, -1633.87439, 1208.09277, 7.03906 + 1, -0, 0, 224.5189666748 ) fadeCamera( source, false ) setTimer( fadeCamera, 1500, 1, source, true ) takePlayerMoney( source, 1000 ) setElementDimension( vehPers[source], 0 ) setElementDimension( source, 0 ) setTimer( warpPedIntoVehicle, 1500, 1, source, vehPers[source] ) setTimer( destroyElement, 300000, 1, vehPers[source] ) setTimer( function( ) outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFWarning, Your subscription has been ended #FF0000!', source, 255, 255, 255, true ) end, 300000, 1 ) triggerClientEvent( source, 'VehiclesSystem;gridListAddRent', source, ID, vehName ) end ) addEvent( 'VehiclesSystem;lock/unlockPersonalVehicle', true ) addEventHandler( 'VehiclesSystem;lock/unlockPersonalVehicle', root, function( ) if ( not isElement( vehPers[source] ) ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, You don\'t have vehicle #FF0000!', source, 255, 255, 255, true ) return end if ( isVehicleLocked( vehPers[source] ) == true ) then setVehicleLocked( vehPers[source], false ) outputChatBox( '#2BFF00*#FFFF00 Vehicles System #2BFF00 : #FFFFFFSuccess, Your vehicle has been unlocked #2BFF00!', source, 255, 255, 255, true ) else setVehicleLocked( vehPers[source], true ) outputChatBox( '#2BFF00*#FFFF00 Vehicles System #2BFF00 : #FFFFFFSuccess, Your vehicle has been locked #2BFF00!', source, 255, 255, 255, true ) end end ) addEvent( 'VehiclesSystem;off/onPersonalVehicle', true ) addEventHandler( 'VehiclesSystem;off/onPersonalVehicle', root, function( ) if ( not isElement( vehPers[source] ) ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, You don\'t have vehicle #FF0000!', source, 255, 255, 255, true ) return end if ( getVehicleEngineState( vehPers[source] ) == true ) then setVehicleEngineState( vehPers[source], false ) outputChatBox( '#2BFF00*#FFFF00 Vehicles System #2BFF00 : #FFFFFFSuccess, Your vehicle has been turned off #2BFF00!', source, 255, 255, 255, true ) else setVehicleEngineState( vehPers[source], true ) outputChatBox( '#2BFF00*#FFFF00 Vehicles System #2BFF00 : #FFFFFFSuccess, Your vehicle has been turned on #2BFF00!', source, 255, 255, 255, true ) end end ) addEvent( 'VehiclesSystem;off/onLightsPersonalVehicle', true ) addEventHandler( 'VehiclesSystem;off/onLightsPersonalVehicle', root, function( ) if ( not isElement( vehPers[source] ) ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, You don\'t have vehicle #FF0000!', source, 255, 255, 255, true ) return end if ( getVehicleLightState( vehPers[source], 0 ) == 0 and getVehicleLightState( vehPers[source], 1 ) == 0 ) then setVehicleLightState( vehPers[source], 0, 1 ) setVehicleLightState( vehPers[source], 1, 1 ) setVehicleLightState( vehPers[source], 2, 1 ) setVehicleLightState( vehPers[source], 3, 1 ) outputChatBox( '#2BFF00*#FFFF00 Vehicles System #2BFF00 : #FFFFFFSuccess, Your vehicle lights turned off #2BFF00!', source, 255, 255, 255, true ) else setVehicleLightState( vehPers[source], 0, 0 ) setVehicleLightState( vehPers[source], 1, 0 ) setVehicleLightState( vehPers[source], 2, 0 ) setVehicleLightState( vehPers[source], 3, 0 ) outputChatBox( '#2BFF00*#FFFF00 Vehicles System #2BFF00 : #FFFFFFSuccess, Your vehicle lights turned on #2BFF00!', source, 255, 255, 255, true ) end end ) addEvent( 'VehiclesSystem;sellMyPersonalVehicle', true ) addEventHandler( 'VehiclesSystem;sellMyPersonalVehicle', root, function( ID, price ) local check = dbQuery( vehDB, ' SELECT * FROM `VehiclesSystem_Players` WHERE pSerial = ? AND vehID = ? ', getPlayerSerial( source ), ID ) local results = dbPoll( check, -1 ) if ( type( results ) == 'table' and #results == 0 or not results ) then outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, This vehicle is not permanently for you, You cannot sell it #FF0000!', source, 255, 255, 255, true ) return end if ( isElement( vehPers[source] ) ) then destroyElement( vehPers[source] ) end dbExec( vehDB, ' DELETE FROM `VehiclesSystem_Players` WHERE pSerial = ? AND vehID = ? ', getPlayerSerial( source ), ID ) refreshMyList( ) givePlayerMoney( source, price ) outputChatBox( '#2BFF00*#FFFF00 Vehicles System #2BFF00 : #FFFFFFSuccess, Your vehicle has been sold successfully #2BFF00!', source, 255, 255, 255, true ) end ) addEvent( 'VehiclesSystem;createPersonalVehicle', true ) addEventHandler( 'VehiclesSystem;createPersonalVehicle', root, function( ID ) local x, y, z = getElementPosition( source ) if ( isElement( vehPers[source] ) ) then destroyElement( vehPers[source] ) end vehPers[source] = createVehicle( ID, x + 2, y + 2, z + 1 ) if ( getElementData( source, 'VehiclesSystem;WarpToVehicle' ) == 'Enabled' ) then warpPedIntoVehicle( source, vehPers[source] ) setElementData( vehPers[source], 'myPersVehicle', getPlayerName( source ) ) end end ) addEvent( 'VehiclesSystem;buyCurrentCar', true ) addEventHandler( 'VehiclesSystem;buyCurrentCar', root, function( ID, Name, Price ) local check = dbQuery( vehDB, ' SELECT * FROM `VehiclesSystem_Players` WHERE pSerial = ? AND vehID = ? ', getPlayerSerial( source ), ID ) local results = dbPoll( check, -1 ) if ( type( results ) == 'table' and #results == 0 or not results ) then dbExec( vehDB, ' INSERT INTO `VehiclesSystem_Players` VALUES(?,?,?,?,?) ', getPlayerSerial( source ), tonumber(ID), Name, Price, 'Permanent Subscription' ) vehPers[source] = createVehicle( ID, 550.72430, -1247.76538, 18.13468 + 1, -0, 0, 224.5189666748 ) warpPedIntoVehicle( source, vehPers[source] ) takePlayerMoney( source, Price ) setTimer(setCameraTarget, 1500, 1, source ) setElementDimension( vehPers[source], 0 ) setElementDimension( source, 0 ) fadeCamera( source, false ) setTimer( fadeCamera, 1500, 1, source, true ) triggerClientEvent( source, 'VehiclesSystem;hideBuyWindow', source ) viewVehiclex( nil, nil, nil, nil, 'close' ) refreshMyList( ) else outputChatBox( '#FF0000*#FFFF00 Vehicles System #FF0000 : #FFFFFFError, This vehicle is already exists in your list #FF0000!', source, 255, 255, 255, true ) return end end ) the script is from the comunity. I want it the script to save the upgrades and customization applied to the car, and when you press button GUIEditor.button[1], the car will spawn with the modifications you made Link to comment
Moderators IIYAMA Posted October 30, 2017 Moderators Share Posted October 30, 2017 Why don't you start with making the component to retrieve the upgrades first? 1 Link to comment
Slim Posted November 13, 2017 Share Posted November 13, 2017 You need to learn to mod vehicles. Add special components to your mod under specified names, and you refer back to the specified names with script. Also the script you have here isn't even close to what you would need. Learn to navigate the MTA wiki bro https://wiki.multitheftauto.com/wiki/Main_Page 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