Jump to content

I want to help in Vehicle Shop


Itachi

Recommended Posts

Hi All

I Want To Help

The Vehicle Do Not Save To Window

Please Help Me

Client Side

function addVehicle (model, Health, x, y, z, serialPlayer) 
    local file = xmlLoadFile("MyVehicle.xml")
    if not (file) then
        file = xmlCreateFile("MyVehicle.xml","file")
    end
    local vehs = xmlCreateChild(file, "vehicle")
    if (vehs) then
        xmlNodeSetAttribute(vehs, "NameCar", model)
        xmlNodeSetAttribute(vehs, "HealthCar", Health)
        xmlNodeSetAttribute(vehs, "x", x)
        xmlNodeSetAttribute(vehs, "y", y)
        xmlNodeSetAttribute(vehs, "z", z)
        xmlNodeSetAttribute(vehs, "MySerial", serialPlayer)
    end
    xmlSaveFile(file)
    xmlUnloadFile(file)
end
-----------------------
GUIEditor = {
    gridlist = {},
    window = {},
    button = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        GUIEditor.window[1] = guiCreateWindow(147, 90, 540, 441, "Control MyCar Panel", false)
        guiWindowSetSizable(GUIEditor.window[1], false)
        guiSetAlpha(GUIEditor.window[1], 1.00)
        GUIEditor.gridlist[1] = guiCreateGridList(13, 22, 393, 286, false, GUIEditor.window[1])
        guiGridListAddColumn(GUIEditor.gridlist[1], "Name Car", 0.5)
        guiGridListAddColumn(GUIEditor.gridlist[1], "Health Car", 0.5)
        GUIEditor.button[1] = guiCreateButton(430, 37, 100, 30, "Reapair Car 1500$", false, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
        GUIEditor.button[2] = guiCreateButton(430, 77, 100, 30, "Warp Car To Me 700$", false, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA")
        GUIEditor.button[3] = guiCreateButton(430, 122, 100, 30, "Set Blip To Car", false, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFAAAAAA")
        GUIEditor.button[4] = guiCreateButton(430, 167, 100, 30, "Destory Car", false, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FFAAAAAA")
        GUIEditor.button[5] = guiCreateButton(430, 215, 100, 30, "setAlpha Car", false, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FFAAAAAA")
        GUIEditor.button[6] = guiCreateButton(13, 333, 100, 30, "UnClock", false, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[6], "NormalTextColour", "FFAAAAAA")
        GUIEditor.button[7] = guiCreateButton(153, 333, 100, 30, "Selling car", false, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[7], "NormalTextColour", "FFAAAAAA")    
        guiSetVisible(GUIEditor.window[1],false)
    end
)
----------------------
addEvent('XMLCar',true)
addEventHandler('XMLCar',getRootElement(),
function ()
local file = xmlLoadFile('MyVehicle.xml')
if not (file) then return end
local getCar = xmlNodeGetAttributes ( file )
    for g,v in pairs ( getCar ) do
          row = guiGridListAddRow ( GUIEditor.gridlist[1] )
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, v[1], false, false)
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 2, v[2], false, false)
xmlSaveFile(file)
xmlUnLoadFile(file)
end
end
)
-----------------------
show = function()
if ( guiGetVisible ( GUIEditor.window[1] ) == true ) then
 guiSetVisible ( GUIEditor.window[1] ,false )
 showCursor (false )
 guiSetInputEnabled(false)
elseif ( guiGetVisible ( GUIEditor.window[1] ) == false ) then
 guiSetVisible ( GUIEditor.window[1] ,true )
 showCursor (true)
end
end
bindKey ( "F2" , "down" , show )
----------------- Save Gui
maFen = nil
local colorButton = {}
local cColor = {}
local colorButtonA = {}
local colorEx = {}
local player = getLocalPlayer()
function guiStart (atList)
    if maFen == nil then
        local x, y = guiGetScreenSize()
        maFen = guiCreateWindow( x / 2 - 200, y / 2 - 175, 400, 350, "Vehicles Shop", false )
        guiSetText ( maFen, "Vehicles Shop")
        maTab = guiCreateTabPanel( 180, 30, 230, 100, false, maFen )
        carPic = guiCreateStaticImage( 5, 5, 200, 85, "Png\\rien.png", false, maTab )
        local cBNum = 0
        local cBx = 0.46
        while cBNum ~= 4 do
            cBNum = cBNum + 1
            colorButtonA[cBNum] = guiCreateButton ( cBx, 0.39, 0.10, 0.06, "color"..cBNum.."", true , maFen )
            cBx = cBx + 0.13
        end
        guiWindowSetSizable (maFen, false )
        guiWindowSetMovable (maFen, true )
        showList(atList)
        buyButton = guiCreateButton( 0.03, 0.89, 0.33, 0.10, "Buy", true, maFen )
        closeButton = guiCreateButton( 0.66, 0.89, 0.33, 0.10, "Close", true, maFen )
        addEventHandler( "onClientGUIClick", maFen, aClickGui )
        showCursor ( true )
        guiSetVisible ( maFen, true )
        --guiCreateStaticImage( 5, 5, 200, 85, "colors\\2.png", false, maTab )
       
        colorFen = guiCreateWindow( x / 2 - 260, y / 2 - 40, 520, 210, "COLORS", false )
        local colorNum = 0
        local colorNum1 = 0
        local colorX = 10
        local colorY = 25
        while colorNum ~= 127 do
            colorButton = guiCreateStaticImage( colorX, colorY, 23, 23, "colors\\"..colorNum..".png", false, colorFen )
            setElementData ( colorButton , "colorNum1", ""..colorNum.."" )
            addEventHandler( "onClientGUIClick", colorButton, aClickGuiColor )
            colorNum = colorNum + 1
            colorX = colorX + 25
            if colorNum1 == 19 then
                colorY = colorY + 25
                colorNum1 = 0
                colorX = 10
            else
                colorNum1 = colorNum1 + 1
            end        
        end
        colorCloseButton = guiCreateButton( 0.76, 0.85, 0.23, 0.1, "Close", true, colorFen )
        addEventHandler( "onClientGUIClick", colorFen, aClickGui )
        guiWindowSetSizable ( colorFen, false )
        guiSetVisible ( colorFen, false )
       
    else
        guiSetVisible ( maFen, true )
        showCursor ( true )
        guiBringToFront ( maFen )
        showList(atList)
    end
end
addEvent( "guiStart", true  )
addEventHandler( "guiStart", getRootElement(), guiStart )
Timer1 = {}
function addlist( model, Health, serialPlayer, x, y, z)
        local row = guiGridListAddRow(GUIEditor.gridlist[1])
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, tostring(model), false, false)
        Timer1[localPlayer] = setTimer(guiGridListSetItemText,300,0,GUIEditor.gridlist[1], row, 2, tonumber(Health), false, false)
        addVehicle (model, Health, x, y, z, serialPlayer)
end
addEvent('addMyCarToList',true)
addEventHandler('addMyCarToList',root,addlist)
function destroyvehicles ( vehicle )
    destroyElement ( vehicle )
end
addEvent( "destroyvehicles", true  )
addEventHandler( "destroyvehicles", getRootElement(), destroyvehicles )
function showList(atList)
    local table = {}
--    outputChatBox ( ""..atList.."" )
    vehicleList   = guiCreateGridList ( 0.03 , 0.07, 0.4, 0.8, true, maFen )
    vehicleList1  = guiGridListAddColumn( vehicleList, "Vehicle", 0.5 )
    priceList = guiGridListAddColumn( vehicleList, "Price", 0.3 )
    node = xmlLoadFile("data\\vehicles.xml")
    if ( node ) then
        local vNum = 0
        while ( xmlFindSubNode ( node, "group", vNum ) ~= false ) do
            local group = xmlFindSubNode ( node, "group", vNum )
            if xmlNodeGetAttribute ( group, "type" ) == atList then
                local gName = xmlNodeGetAttribute ( group, "id" )
--                guiGridListSetItemText( vehicleList, guiGridListAddRow ( vehicleList ), 1, ""..gName.."", false, false )
                local vNum1 = 0
                while ( xmlFindSubNode ( group, "vehicle", vNum1 ) ~= false ) do
                    local aVehicle = xmlFindSubNode ( group, "vehicle", vNum1 )
                    local vId = xmlNodeGetAttribute ( aVehicle, "id" )
                    local vName = getVehicleNameFromID ( vId )
                    local vPrice = xmlNodeGetAttribute ( aVehicle, "price" )
                    local row = guiGridListAddRow ( vehicleList )
                    guiGridListSetItemText( vehicleList, row, 1, ""..vName.."", false, false )
                    guiGridListSetItemText( vehicleList, row, 2, ""..vPrice.."", false, false )
                    vNum1 = vNum1 + 1
                end
            end
            vNum = vNum + 1
        end
        addEventHandler( "onClientGUIClick", vehicleList, aClickGuiCar )
        addEventHandler( "onClientGUIDoubleClick", vehicleList, aClickDoubleGui )
        bindKey ( "arrow_u", "down", navList )
        bindKey ( "arrow_d", "down", navList )
        xmlUnloadFile ( node )
    end
    return table
end
function navList ( key, keyState)
    local rowSel = guiGridListGetSelectedItem ( vehicleList )
    if key == "arrow_u" then
        guiGridListSetSelectedItem ( vehicleList, tonumber(rowSel)-1, 1 )
    elseif key == "arrow_d" then
        guiGridListSetSelectedItem ( vehicleList, tonumber(rowSel)+1, 1 )
    end
    local aCurrentVehicle = guiGridListGetItemText ( vehicleList, guiGridListGetSelectedItem ( vehicleList ), 1 )
    guiStaticImageLoadImage ( carPic, "Png\\"..aCurrentVehicle..".png" )
end
   
function aClickGui (button)
    if ( button == "left") then
        if ( source == closeButton ) then
            guiSetVisible ( maFen, false )
            guiSetVisible ( colorFen, false )
            showCursor ( false )
            destroyElement ( vehicleList )
            unbindKey ( "arrow_u", "down", navList )
            unbindKey ( "arrow_d", "down", navList )
            local num = 0
            while num ~= 4 do
                num = num + 1
                if ( colorEx[num] ) then
                    guiStaticImageLoadImage ( colorEx[num], "colors\\rien.png" )
                end
            end
            guiStaticImageLoadImage ( carPic, "Png\\rien.png" )
        elseif ( source == buyButton ) then
            if ( aCurrentVehicle ) ~= "" then
                local cNum = 0
                while cNum ~=4 do
                    cNum = cNum + 1
                    cColor[cNum] = getElementData ( colorButtonA[cNum], "apColor" )
                    if cColor[cNum] == false then
                        cColor[cNum] = "1"
                    end
                end
                applyVehicle ( cColor[1], cColor[2], cColor[3], cColor[4] )
                guiSetVisible ( maFen, false )
                guiSetVisible ( colorFen, false )
                showCursor ( false )
                unbindKey ( "arrow_u", "down", navList )
                unbindKey ( "arrow_d", "down", navList )
                destroyElement ( vehicleList )
                guiStaticImageLoadImage ( carPic, "Png\\rien.png" )
            else
                outputChatBox ( "no vehicle selected" )
            end
       
        elseif ( source == colorCloseButton ) then
            guiSetVisible ( colorFen, false )
       
        elseif ( source == colorButtonA[4] ) then
            guiSetVisible ( colorFen, true )
            guiBringToFront ( colorFen )
            setElementData ( colorFen, "typColor", "4" )
       
        elseif ( source == colorButtonA[3] ) then
            guiSetVisible ( colorFen, true )
           
Link to comment

Saving vehicles client-side is a very bad idea. Also, try to be more specific about your issue, like, does it output any errors (/debugscript 3)? It's hard to look at a 300+ lines of code trying to figure out the problem for you.

Link to comment

The problem is that if I bought a car from the shop comes in the list of F2, and if it gets out of the car saves a list of F2, but if the income does not keep this server side

vShopCol = {} 
spawnAnnul = {} 
markerVehic = {} 
afText = {} 
myTextItem = {} 
function guiStart () 
    local node = xmlLoadFile("data\\carshops.xml") 
    local vNum2 = 0 
    while ( xmlFindSubNode ( node, "carshop", vNum2 ) ~= false ) do 
        local vNum3 = 0 
        local shop = xmlFindSubNode ( node, "carshop", vNum2 ) 
        while ( xmlFindSubNode ( shop, "carshopcol", vNum3 ) ~= false ) do 
            local shopCol = xmlFindSubNode ( shop, "carshopcol", vNum3 ) 
            local shopName = xmlNodeGetAttribute ( shopCol, "name" ) 
            local pX = xmlNodeGetAttribute ( shopCol, "posX" ) 
            local pY = xmlNodeGetAttribute ( shopCol, "posY" ) 
            local pZ = xmlNodeGetAttribute ( shopCol, "posZ" ) 
            local m1 = xmlNodeGetAttribute ( shopCol, "M1" ) 
            local spawnPX = xmlNodeGetAttribute ( shopCol, "spawnPX" ) 
            local spawnPY = xmlNodeGetAttribute ( shopCol, "spawnPY" ) 
            local spawnPZ = xmlNodeGetAttribute ( shopCol, "spawnPZ" ) 
            local spawnRZ = xmlNodeGetAttribute ( shopCol, "spawnRZ" ) 
            IspawnCol = createColSphere ( spawnPX, spawnPY, spawnPZ, 2.4 ) 
            vShopCol1 = createColSphere ( pX, pY, pZ, 1 ) 
            setElementData ( IspawnCol, "SpawnPointName", ""..shopName.."" ) 
            setElementData ( IspawnCol, "sRz", ""..spawnRZ.."" ) 
            setElementData ( vShopCol1, "tList", ""..m1.."" ) 
            setElementData ( vShopCol1, "SpawnShopName", ""..shopName.."" ) 
            createMarker ( pX, pY, pZ, "cylinder", 1, 0, 0, 255, 200 ) 
            addEventHandler( "onColShapeHit", IspawnCol, spawnColCol ) 
            addEventHandler( "onColShapeHit", vShopCol1, conCol ) 
            addEventHandler( "onColShapeLeave", IspawnCol, setDataCol1 ) 
            local vNum4 = 0 
            while ( xmlFindSubNode ( shopCol, "model", vNum4 ) ~= false ) do 
                local modelE = xmlFindSubNode ( shopCol, "model", vNum4 ) 
                local pX1 = xmlNodeGetAttribute ( modelE, "posX" ) 
                local pY1 = xmlNodeGetAttribute ( modelE, "posY" ) 
                local pZ1 = xmlNodeGetAttribute ( modelE, "posZ" ) 
                local rZ = xmlNodeGetAttribute ( modelE, "rot" ) 
                local id = xmlNodeGetAttribute ( modelE, "name" ) 
                local vehicle = createVehicle ( id, pX1, pY1, pZ1, 0, 0, rZ ) 
                setTimer ( setVehicleFrozen , 1000, 1, vehicle, true  ) 
                setVehicleLocked ( vehicle, true ) 
                setVehicleDamageProof ( vehicle, true ) 
                vNum4 = vNum4 + 1 
            end 
            vNum3 = vNum3 + 1     
        end 
        vNum2 = vNum2 + 1 
    end 
end 
addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()), guiStart ) 
function spawnColCol (element) 
    if getElementType ( element ) == "vehicle" then 
--        outputChatBox ( " eaaaaaaaa " ) 
        setElementData ( source, "etatPlace", "OQP" ) 
    end 
end 
function setDataCol1 (element) 
    if getElementType ( element ) == "vehicle" then 
        local player = getVehicleOccupant ( element, 0 ) 
        setElementData ( source, "etatPlace", "libre" ) 
        if ( spawnAnnul[player] ) ~= nil then 
            killTimer ( spawnAnnul[player] ) 
            spawnAnnul[player] = nil 
        end 
    end 
end 
function conCol (element) 
    if getElementType ( element ) == "player" then 
--        local player = getVehicleOccupant ( element, 0 ) 
        atList, atList1 = getElementData ( source, "tList" ) 
        local shopName = getElementData ( source, "SpawnShopName" ) 
        setElementData ( element, "shopName", ""..shopName.."" ) 
        triggerClientEvent (element, "guiStart" , getRootElement(), atList, atList1 ) 
    --else 
    --    local player = element 
    end 
     
end 
function vehicleCreat( player, cost, vId, x, y, z, nPlayer, sRz, cColor1, cColor2, cColor3, cColor4 ) 
--    outputChatBox ( ""..cColor1.."" ) 
    removeElementData ( player, "shopName" ) 
    if getPlayerMoney ( player ) >= math.abs(cost) then 
        vehicle = createVehicle ( vId, x, y, z, 0, 0, sRz ) 
        markerVehic[player] = createMarker ( x, y, z+3, "arrow", 1.5, 255, 255, 0, 170, player ) 
        setVehicleColor ( vehicle, cColor1, cColor2, cColor3, cColor4 ) 
        setElementData ( vehicle, "consVehicleOwner", ""..nPlayer.."" ) 
        setVehicleDamageProof ( vehicle, true ) 
        setVehicleLocked ( vehicle, true ) 
        takePlayerMoney ( player, math.abs(cost) ) 
    local model = getVehicleNameFromModel(tonumber(vId)) 
    local Health = math.floor(getElementHealth(vehicle)) 
    local serialPlayer = getPlayerSerial(player) 
    local x, y, z = getElementPosition(vehicle) 
    local playerName = getPlayerName(player) 
 triggerClientEvent(player,'addMyCarToList', player, model, Health, serialPlayer, x, y, z) 
        if ( vehicle ) then 
            toggleVehicleRespawn ( vehicle, false ) 
        end 
        spawnAnnul[player] = setTimer ( delayedSpawn, 5000, 1, "15", vehicle, player, cost ) 
        warnText ( "15 seconds to take your vehicle", player) 
    else 
        warnText ( "You cannot afford to fit this Vehicle!", player ) 
    end 
end 
addEvent( "but_applyVehicle", true  ) 
addEventHandler( "but_applyVehicle", getRootElement(), vehicleCreat ) 
function delayedSpawn ( curTime, vehicle, player, cost ) 
    if curTime ~= 0 then 
        curTime = curTime -1 
        spawnAnnul[player] = setTimer ( delayedSpawn, 1000, 1, curTime, vehicle, player, cost ) 
        warnText ( ""..curTime.."", player ) 
    else 
        warnText ( "Vehicule repaid !", player ) 
        givePlayerMoney ( player, math.abs(cost) ) 
        triggerClientEvent ( getRootElement(), "destroyvehicles", getRootElement(), vehicle ) 
        if ( markerVehic[player] ) then 
            destroyElement ( markerVehic[player] ) 
        end 
        setTimer ( destroyElement , 100, 1, vehicle ) 
    end 
end 
     
function vExplode () 
    if getElementData ( source , "consVehicleOwner" ) ~= false then 
        toggleVehicleRespawn ( source, false ) 
        setTimer(destroyElement, 5000, 1, source) 
    end 
end 
addEventHandler ( "onVehicleExplode", getResourceRootElement(getThisResource()), vExplode ) 
function consVehicleEnter (player, seat, jacked) 
    vProp = getElementData ( source, "consVehicleOwner" ) 
    if vProp == getPlayerNametagText(player)  then 
        setVehicleLocked ( source, false ) 
        setVehicleDamageProof ( source, false ) 
        if ( markerVehic[player] ) then 
            destroyElement ( markerVehic[player] ) 
            markerVehic[player] = nil 
        end 
--    else 
--        local vType = getVehicleType ( source ) 
--        if vType == "boat" or vType == "bike" then ------------------------------------<<<<<<<<< POUR LA VERSION 1.0 
--            cancelEvent() 
--        end 
    end 
end 
addEventHandler ( "onVehicleStartEnter" , getResourceRootElement(getThisResource()), consVehicleEnter ) 
function warnText ( aWText, player ) 
    if ( myTextItem[player] ) then 
        textDestroyTextItem ( myTextItem[player]) 
    end 
    afText[player] = textCreateDisplay () 
    textDisplayAddObserver( afText[player], player ) 
    myTextItem[player] = textCreateTextItem ( aWText, 0.22, 0.8, 2 , 255, 0, 0, 255, 3 ) 
    textDisplayAddText ( afText[player], myTextItem[player] ) 
--    outputChatBox ( textA, player ) 
    setTimer ( textDestroyTextItem, 5000, 1, myTextItem[player], player ) 
end 
addEventHandler('onPlayerJoin',root, 
function () 
triggerClientEvent(source,'XMLCar',source) 
end 
) 

Link to comment

This is an attempt in SQLite

But did not succeed

client-side

GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(147, 90, 540, 441, "Control MyCar Panel", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
        GUIEditor.gridlist[1] = guiCreateGridList(13, 22, 393, 286, false, GUIEditor.window[1]) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "Name Car", 0.5) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "Health Car", 0.5) 
        GUIEditor.button[1] = guiCreateButton(430, 37, 100, 30, "Reapair Car 1500$", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") 
        GUIEditor.button[2] = guiCreateButton(430, 77, 100, 30, "Warp Car To Me 700$", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") 
        GUIEditor.button[3] = guiCreateButton(430, 122, 100, 30, "Set Blip To Car", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFAAAAAA") 
        GUIEditor.button[4] = guiCreateButton(430, 167, 100, 30, "Destory Car", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FFAAAAAA") 
        GUIEditor.button[5] = guiCreateButton(430, 215, 100, 30, "setAlpha Car", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FFAAAAAA") 
        GUIEditor.button[6] = guiCreateButton(13, 333, 100, 30, "UnClock", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[6], "NormalTextColour", "FFAAAAAA") 
        GUIEditor.button[7] = guiCreateButton(153, 333, 100, 30, "Selling car", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[7], "NormalTextColour", "FFAAAAAA")     
        guiSetVisible(GUIEditor.window[1],false) 
    end 
) 
---------------------- 
addEvent('Get1Car',true) 
addEventHandler('Get1Car',getRootElement(), 
function (getCar,getCarH) 
          row = guiGridListAddRow ( GUIEditor.gridlist[1] ) 
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, getCar, false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 2, getCarH, false, false) 
end 
) 
------------- 
function addlist( model, Health ) 
        local row = guiGridListAddRow(GUIEditor.gridlist[1]) 
        guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, tostring(model), false, false) 
        Timer1[localPlayer] = setTimer(guiGridListSetItemText,300,0,GUIEditor.gridlist[1], row, 2, tonumber(Health), false, false) 
end 
addEvent('addMyCarToList',true) 
addEventHandler('addMyCarToList',root,addlist) 
  

server-side

addEventHandler('onResourceStart',resourceRoot, 
    function (      ) 
        local CreateNewTable = executeSQLQuery ('CREATE TABLE IF NOT EXISTS  `Save Car System` ( PlayerSerial,CarName,HealthCar,x,y,z ) ') 
            if ( CreateNewTable ) then 
                outputDebugString('Create Table Save Car System Done') 
        end 
    end 
) 
function vehicleCreat( player, cost, vId, x, y, z, nPlayer, sRz, cColor1, cColor2, cColor3, cColor4 ) 
--    outputChatBox ( ""..cColor1.."" ) 
    removeElementData ( player, "shopName" ) 
    if getPlayerMoney ( player ) >= math.abs(cost) then 
        vehicle = createVehicle ( vId, x, y, z, 0, 0, sRz ) 
        markerVehic[player] = createMarker ( x, y, z+3, "arrow", 1.5, 255, 255, 0, 170, player ) 
        setVehicleColor ( vehicle, cColor1, cColor2, cColor3, cColor4 ) 
        setElementData ( vehicle, "consVehicleOwner", ""..nPlayer.."" ) 
        setVehicleDamageProof ( vehicle, true ) 
        setVehicleLocked ( vehicle, true ) 
        takePlayerMoney ( player, math.abs(cost) ) 
    local model = getVehicleNameFromModel(tonumber(vId)) 
    local Health = math.floor(getElementHealth(vehicle)) 
    local serialPlayer = getPlayerSerial(player) 
    local x,y,z = getElementPosition(vehicle) 
 triggerClientEvent(player,'addMyCarToList', player, model, Health) 
     local Results = executeSQLQuery("SELECT * FROM `Save Car System` WHERE PlayerSerial=?",getPlayerSerial ( source ) ) 
     if ( type ( Results ) == "table" and #Results == 0 or not Results ) then 
        executeSQLQuery ( "INSERT INTO `Save Car System` ( PlayerSerial,CarName,HealthCar,x,y,z ) VALUES(?,?,?,?)",serialPlayer,model,Health,x,y,z ) 
    else 
        executeSQLQuery('UPDATE `Save Car System` SET x =?, y =?, z =?, CarName =?, HealthCar =?, WHERE PlayerSerial =?',x,y,z,serialPlayer ) 
    end 
        if ( vehicle ) then 
            toggleVehicleRespawn ( vehicle, false ) 
        end 
        spawnAnnul[player] = setTimer ( delayedSpawn, 5000, 1, "15", vehicle, player, cost ) 
        warnText ( "15 seconds to take your vehicle", player) 
    else 
        warnText ( "You cannot afford to fit this Vehicle!", player ) 
  
    end 
end 
addEventHandler('onPlayerLogin',root, 
    function (  ) 
        local Results = executeSQLQuery("SELECT * FROM `Save Car System` WHERE PlayerSerial=?",getPlayerSerial ( source ) ) 
        if ( type ( Results ) == "table" and #Results == 0 or not Results ) then return end 
            triggerClientEvent(source,'Get1Car',source,Results[1]['CarName'],Results[1]['HealthCar']) 
    end 
) 

Please, I want to correct for My Code

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...