Jump to content

Preciso de ajuda em um painel de garagem


Recommended Posts


addEventHandler("onClientResourceStart", resourceRoot,
    function()
local screenW, screenH = guiGetScreenSize()
        Garagem = guiCreateWindow((screenW - 676) / 2, (screenH - 319) / 2, 676, 319, "Garagem BSV", false)
        guiWindowSetSizable(Garagem, false)
        guiSetAlpha(Garagem, 0.79)
        guiSetProperty(Garagem, "CaptionColour", "FF000BFE")

        retira = guiCreateButton(0.73, 0.17, 0.23, 0.14, "Retirar", true, Garagem)
        estac = guiCreateButton(0.73, 0.38, 0.23, 0.13, "Estacionar", true, Garagem)
        fechar = guiCreateButton(0.73, 0.62, 0.23, 0.12, "Fechar", true, Garagem)
        vehlist = guiCreateGridList(0.05, 0.13, 0.62, 0.67, true, Garagem)
        guiGridListAddColumn(vehlist, "Nome", 0.3)
        guiGridListAddColumn(vehlist, "Preço", 0.3)
        guiGridListAddColumn(vehlist, "Vida", 0.3)    
    end
)

addEventHandler("onClientRender", root,
    function()
        dxDrawText("", 536, 506, 536, 506, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
        dxDrawText("", 527, 518, 753, 518, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
    end
)

client

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
			outputMessage("#c1c1c1O seu veiculo #00FF66"..(customCarNames[data[1]["Model"]] or getVehicleNameFromModel(data[1]["Model"])).." #c1c1c1já está spawnado.", source, 38, 122, 216, 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 tonumber(data[1]["HP"]) <= 255.5 then data[1]["HP"] = 255 end
			if data[1]["new_hydr"] and data[1]["new_hydr"] == 1 then
				setElementData(vehicle, "NewHydr", true)
			else
				setElementData(vehicle, "NewHydr", false)
			end
			setElementData(vehicle, "ownercar", getAccountName(getPlayerAccount(source)))
			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)
			outputMessage("#c1c1c1O seu veiculo #00FF66"..(customCarNames[data[1]["Model"]] or getVehicleNameFromModel(data[1]["Model"])).." #c1c1c1foi spawnado.", source, 38, 122, 216, true)
		end
	else
		outputMessage("#c1c1c1Há um problema com o veiculo, notifique o administrador.", source, 38, 122, 216, true)
	end
end)

Server

Tipo, eu queria sincronizar a lista de veh, o spawn do meu veh, o distroyer, e o fechar painel

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...