SkillZNT Posted January 25, 2020 Share Posted January 25, 2020 Eu quero colocar um time de 5 segundos pra pessoa poder reparar o veiculo dela novamente no freeroam com a mensagem Aguarde 5 segundos para reparar o seu veiculo... local Vermelho = 250 local Verde = 250 local Azul = 0 addEventHandler("onClientGUIClick",root, function () if ( source == getControl(wndCreateVehicle,"vehicles") ) then for row=0, guiGridListGetRowCount(getControl(wndCreateVehicle, "vehicles")) do guiGridListSetItemColor(getControl(wndCreateVehicle, "vehicles"),row,1,1,120,253) end end end ) CONTROL_MARGIN_RIGHT = 5 LINE_MARGIN = 5 LINE_HEIGHT = 16 g_Root = getRootElement() g_ResRoot = getResourceRootElement(getThisResource()) g_Me = getLocalPlayer() server = createServerCallInterface() guiSetInputMode("no_binds_when_editing") --------------------------- -- Set skin window --------------------------- function skinInit() setControlNumber(wndSkin, 'skinid', getElementModel(g_Me)) end function showSkinID(leaf) if leaf.id then setControlNumber(wndSkin, 'skinid', leaf.id) end end function applySkin() local skinID = getControlNumber(wndSkin, 'skinid') if skinID then server.setMySkin(skinID) fadeCamera(true) end end wndSkin = { 'wnd', text = 'Personagens', width = 250, x = -20, y = 0.3, controls = { { 'lst', id='skinlist', width=230, height=290, columns={ {text='Skin', attr='name'} }, rows={xml='skins.xml', attrs={'id', 'name'}}, onitemclick=showSkinID, onitemdoubleclick=applySkin }, {'txt', id='skinid', text='', width=0}, {'btn', id='set', onclick=applySkin}, {'btn', id='close', closeswindow=true} }, oncreate = skinInit } function setSkinCommand(cmd, skin) skin = skin and tonumber(skin) if skin then server.setMySkin(skin) fadeCamera(true) closeWindow(wndSpawnMap) closeWindow(wndSetPos) end end --------------------------- --- Set animation window --------------------------- function applyAnimation(leaf) if type(leaf) ~= 'table' then leaf = getSelectedGridListLeaf(wndAnim, 'animlist') if not leaf then return end end server.setPedAnimation(g_Me, leaf.parent.name, leaf.name, true, true) end function stopAnimation() server.setPedAnimation(g_Me, false) end wndAnim = { 'wnd', text = 'Animações', width = 250, x = -20, y = 0.3, controls = { { 'lst', id='animlist', width=230, height=290, columns={ {text='Animações', attr='name'} }, rows={xml='animations.xml', attrs={'name'}}, expandlastlevel=false, onitemdoubleclick=applyAnimation }, {'btn', id='Animar', onclick=applyAnimation}, {'btn', id='Parar', onclick=stopAnimation}, {'btn', id='Fechar', closeswindow=true} } } addCommandHandler('anim', function(command, lib, name) server.setPedAnimation(g_Me, lib, name, true, true) end ) --------------------------- -- Weapon window --------------------------- function addWeapon(leaf, amount) if type(leaf) ~= 'table' then leaf = getSelectedGridListLeaf(wndWeapon, 'weaplist') amount = getControlNumber(wndWeapon, 'amount') if not amount or not leaf then return end end server.giveMeWeapon(leaf.id, amount) end wndWeapon = { 'wnd', text = 'Armamento', width = 250, controls = { { 'lst', id='weaplist', width=230, height=280, columns={ {text='Arma', attr='name'} }, rows={xml='weapons.xml', attrs={'id', 'name'}}, onitemdoubleclick=function(leaf) addWeapon(leaf, 500) end }, {'br'}, {'txt', id='amount', text='500', width=60}, {'btn', id='Pegar', onclick=addWeapon}, {'btn', id='Fechar', closeswindow=true} } } function giveWeaponCommand(cmd, weapon, amount) weapon = tonumber(weapon) or getWeaponIDFromName(weapon) if not weapon then return end amount = amount and tonumber(amount) or 500 server.giveMeWeapon(math.floor(weapon), amount) end --------------------------- -- Fighting style --------------------------- addCommandHandler('luta', function(cmd, style) style = style and tonumber(style) if style then server.setPedFightingStyle(g_Me, style) end end ) --------------------------- -- Clothes window --------------------------- function clothesInit() if getElementModel(g_Me) ~= 0 then errMsg('Você precisa do CJ para trocar de roupas.') closeWindow(wndClothes) return end if not g_Clothes then triggerServerEvent('onClothesInit', g_Me) end end addEvent('onClientClothesInit', true) addEventHandler('onClientClothesInit', g_Root, function(clothes) g_Clothes = clothes.allClothes for i,typeGroup in ipairs(g_Clothes) do for j,cloth in ipairs(typeGroup.children) do if not cloth.name then cloth.name = cloth.model .. ' - ' .. cloth.texture end cloth.wearing = clothes.playerClothes[typeGroup.type] and clothes.playerClothes[typeGroup.type].texture == cloth.texture and clothes.playerClothes[typeGroup.type].model == cloth.model or false end table.sort(typeGroup.children, function(a, b) return a.name < b.name end) end bindGridListToTable(wndClothes, 'clothes', g_Clothes, false) end ) function clothListClick(cloth) setControlText(wndClothes, 'addremove', cloth.wearing and 'Remover' or 'Adicionar') end function applyClothes(cloth) if not cloth then cloth = getSelectedGridListLeaf(wndClothes, 'clothes') if not cloth then return end end if cloth.wearing then cloth.wearing = false setControlText(wndClothes, 'addremove', 'Adicionar') server.removePlayerClothes(g_Me, cloth.parent.type) else local prevClothIndex = table.find(cloth.siblings, 'wearing', true) if prevClothIndex then cloth.siblings[prevClothIndex].wearing = false end cloth.wearing = true setControlText(wndClothes, 'addremove', 'Remover') server.addPedClothes(g_Me, cloth.texture, cloth.model, cloth.parent.type) end end wndClothes = { 'wnd', text = 'Clothes', x = -20, y = 0.3, width = 350, controls = { { 'lst', id='clothes', width=330, height=390, columns={ {text='Roupas', attr='name', width=0.6}, {text='Wearing', attr='wearing', enablemodify=true, width=0.3} }, rows={ {name='Retrieving clothes list...'} }, onitemclick=clothListClick, onitemdoubleclick=applyClothes }, {'br'}, {'btn', text='Adicionar', id='addremove', width=60, onclick=applyClothes}, {'btn', id='Fechar', closeswindow=true} }, oncreate = clothesInit } function addClothesCommand(cmd, type, model, texture) type = type and tonumber(type) if type and model and texture then server.addPedClothes(g_Me, texture, model, type) end end addCommandHandler('addclothes', addClothesCommand) addCommandHandler('ac', addClothesCommand) function removeClothesCommand(cmd, type) type = type and tonumber(type) if type then server.removePlayerClothes(g_Me, type) end end addCommandHandler('removeclothes', removeClothesCommand) addCommandHandler('rc', removeClothesCommand) --------------------------- -- Stats window --------------------------- function initStats() applyToLeaves(getGridListCache(wndStats, 'statslist'), function(leaf) leaf.value = getPedStat(g_Me, leaf.id) end) end function selectStat(leaf) setControlNumber(wndStats, 'statval', leaf.value) end function maxStat(leaf) setControlNumber(wndStats, 'statval', 1000) applyStat() end function applyStat() local leaf = getSelectedGridListLeaf(wndStats, 'statslist') if not leaf then return end local value = getControlNumber(wndStats, 'statval') if not value then return end leaf.value = value server.setPedStat(g_Me, leaf.id, value) end wndStats = { 'wnd', text = 'Habilidade', width = 300, x = -20, y = 0.3, controls = { { 'lst', id='statslist', width=280, columns={ {text='Habilidade', attr='name', width=0.6}, {text='Quantidade', attr='value', width=0.3, enablemodify=true} }, rows={xml='stats.xml', attrs={'name', 'id'}}, onitemclick=selectStat, onitemdoubleclick=maxStat }, {'txt', id='statval', text='', width=60}, {'btn', id='Definir', onclick=applyStat}, {'btn', id='Fechar', closeswindow=true} }, oncreate = initStats } --------------------------- -- Fall off bike toggle --------------------------- function toggleFallOffBike() setPedCanBeKnockedOffBike(g_Me, guiCheckBoxGetSelected(getControl(wndMain, 'falloff'))) end --------------------------- -- Create vehicle window --------------------------- function createSelectedVehicle(leaf) if not leaf then leaf = getSelectedGridListLeaf(wndCreateVehicle, 'vehicles') if not leaf then return end end server.giveMeVehicles(leaf.id) end wndCreateVehicle = { 'wnd', text = 'Veículos', width = 300, controls = { { 'lst', id='vehicles', width=280, height=340, columns={ {text='Veiculos', attr='name'} }, rows={xml='vehicles.xml', attrs={'id', 'name'}}, onitemdoubleclick=createSelectedVehicle }, {'btn', id='Criar', onclick=createSelectedVehicle}, {'btn', id='Fechar', closeswindow=true} } } function createVehicleCommand(cmd, ...) local vehID local vehiclesToCreate = {} local args = { ... } for i,v in ipairs(args) do vehID = tonumber(v) if not vehID then vehID = getVehicleModelFromName(v) end if vehID then table.insert(vehiclesToCreate, math.floor(vehID)) end end server.giveMeVehicles(vehiclesToCreate) end --------------------------- -- Repair vehicle --------------------------- function repairVehicle() local vehicle = getPedOccupiedVehicle(g_Me) if vehicle then server.fixVehicle(vehicle) end end --------------------------- -- Flip vehicle --------------------------- function flipVehicle() local vehicle = getPedOccupiedVehicle(g_Me) if vehicle then local rX, rY, rZ = getElementRotation(vehicle) server['set' .. 'VehicleRotation'](vehicle, 0, 0, (rX > 90 and rX < 270) and (rZ + 180) or rZ) end end --------------------------- -- Vehicle upgrades --------------------------- function upgradesInit() local vehicle = getPedOccupiedVehicle(g_Me) if not vehicle then errMsg('Please enter a vehicle to change the upgrades of.') closeWindow(wndUpgrades) return end local installedUpgrades = getVehicleUpgrades(vehicle) local compatibleUpgrades = {} local slotName, group for i,upgrade in ipairs(getVehicleCompatibleUpgrades(vehicle)) do slotName = getVehicleUpgradeSlotName(upgrade) group = table.find(compatibleUpgrades, 'name', slotName) if not group then group = { 'group', name = slotName, children = {} } table.insert(compatibleUpgrades, group) else group = compatibleUpgrades[group] end table.insert(group.children, { id = upgrade, installed = table.find(installedUpgrades, upgrade) ~= false }) end table.sort(compatibleUpgrades, function(a, b) return a.name < b.name end) bindGridListToTable(wndUpgrades, 'upgradelist', compatibleUpgrades, true) end function selectUpgrade(leaf) setControlText(wndUpgrades, 'addremove', leaf.installed and 'remove' or 'add') end function addRemoveUpgrade(selUpgrade) -- Add or remove selected upgrade local vehicle = getPedOccupiedVehicle(g_Me) if not vehicle then return end if not selUpgrade then selUpgrade = getSelectedGridListLeaf(wndUpgrades, 'upgradelist') if not selUpgrade then return end end if selUpgrade.installed then -- remove upgrade selUpgrade.installed = false setControlText(wndUpgrades, 'addremove', 'Adicionar') server.removeVehicleUpgrade(vehicle, selUpgrade.id) else -- add upgrade local prevUpgradeIndex = table.find(selUpgrade.siblings, 'Instalado', true) if prevUpgradeIndex then selUpgrade.siblings[prevUpgradeIndex].installed = false end selUpgrade.installed = true setControlText(wndUpgrades, 'addremove', 'Remover') server.addVehicleUpgrade(vehicle, selUpgrade.id) end end wndUpgrades = { 'wnd', text = 'Atualizações no Veículo', width = 300, x = -20, y = 0.3, controls = { { 'lst', id='upgradelist', width=280, height=340, columns={ {text='Atualizar', attr='id', width=0.6}, {text='Instalado', attr='installed', width=0.3, enablemodify=true} }, onitemclick=selectUpgrade, onitemdoubleclick=addRemoveUpgrade }, {'btn', id='addremove', text='Adicionar', width=60, onclick=addRemoveUpgrade}, {'btn', id='ok', closeswindow=true} }, oncreate = upgradesInit } function addUpgradeCommand(cmd, upgrade) local vehicle = getPedOccupiedVehicle(g_Me) if vehicle and upgrade then server.addVehicleUpgrade(vehicle, tonumber(upgrade) or 0) end end function removeUpgradeCommand(cmd, upgrade) local vehicle = getPedOccupiedVehicle(g_Me) if vehicle and upgrade then server.removeVehicleUpgrade(vehicle, tonumber(upgrade) or 0) end end --------------------------- -- Toggle lights --------------------------- function forceLightsOn() local vehicle = getPedOccupiedVehicle(g_Me) if not vehicle then return end if guiCheckBoxGetSelected(getControl(wndMain, 'luzesligadas')) then server.setVehicleOverrideLights(vehicle, 2) guiCheckBoxSetSelected(getControl(wndMain, 'luzesdesligadas'), false) else server.setVehicleOverrideLights(vehicle, 0) end end function forceLightsOff() local vehicle = getPedOccupiedVehicle(g_Me) if not vehicle then return end if guiCheckBoxGetSelected(getControl(wndMain, 'luzesdesligadas')) then server.setVehicleOverrideLights(vehicle, 1) guiCheckBoxSetSelected(getControl(wndMain, 'luzesligadas'), false) else server.setVehicleOverrideLights(vehicle, 0) end end --------------------------- -- Color --------------------------- function setColorCommand(cmd, ...) local vehicle = getPedOccupiedVehicle(g_Me) if not vehicle then return end local colors = { getVehicleColor(vehicle) } local args = { ... } for i=1,6 do colors[i] = args[i] and tonumber(args[i]) or colors[i] end server.setVehicleColor(vehicle, unpack(colors)) end function openColorPicker() editingVehicle = getPedOccupiedVehicle(localPlayer) if (editingVehicle) then colorPicker.openSelect(colors) end end function closedColorPicker() local r1, g1, b1, r2, g2, b2 = getVehicleColor(editingVehicle, true) server.setVehicleColor(editingVehicle, r1, g1, b1, r2, g2, b2) local r, g, b = getVehicleHeadLightColor(editingVehicle) server.setVehicleHeadLightColor(editingVehicle, r, g, b) editingVehicle = nil end function updateColor() if (not colorPicker.isSelectOpen) then return end local r, g, b = colorPicker.updateTempColors() if (editingVehicle and isElement(editingVehicle)) then local r1, g1, b1, r2, g2, b2 = getVehicleColor(editingVehicle, true) if (guiCheckBoxGetSelected(checkColor1)) then r1, g1, b1 = r, g, b end if (guiCheckBoxGetSelected(checkColor2)) then r2, g2, b2 = r, g, b end if (guiCheckBoxGetSelected(checkColor3)) then setVehicleHeadLightColor(editingVehicle, r, g, b) end setVehicleColor(editingVehicle, r1, g1, b1, r2, g2, b2) end end addEventHandler("onClientRender", root, updateColor) --------------------------- -- Paintjob --------------------------- function paintjobInit() local vehicle = getPedOccupiedVehicle(g_Me) if not vehicle then errMsg('Você precisa de um carro que permite edições de pintura personalizada') closeWindow(wndPaintjob) return end local paint = getVehiclePaintjob(vehicle) if paint then guiGridListSetSelectedItem(getControl(wndPaintjob, 'paintjoblist'), paint+1) end end function applyPaintjob(paint) server.setVehiclePaintjob(getPedOccupiedVehicle(g_Me), paint.id) end wndPaintjob = { 'wnd', text = 'Pintura Personalizada', width = 220, x = -20, y = 0.3, controls = { { 'lst', id='paintjoblist', width=200, height=130, columns={ {text='Paintjob ID', attr='id'} }, rows={ {id=0}, {id=1}, {id=2}, {id=3} }, onitemclick=applyPaintjob, ondoubleclick=function() closeWindow(wndPaintjob) end }, {'btn', id='close', closeswindow=true}, }, oncreate = paintjobInit } function setPaintjobCommand(cmd, paint) local vehicle = getPedOccupiedVehicle(g_Me) paint = paint and tonumber(paint) if not paint or not vehicle then return end server.setVehiclePaintjob(vehicle, paint) end --------------------------- -- Main window --------------------------- function updateGUI(updateVehicle) -- update position local x, y, z = getElementPosition(g_Me) setControlNumbers(wndMain, {xpos=math.ceil(x), ypos=math.ceil(y), zpos=math.ceil(z)}) -- update jetpack toggle guiCheckBoxSetSelected( getControl(wndMain, 'jetpack'), doesPedHaveJetPack(g_Me) ) if updateVehicle then -- update current vehicle local vehicle = getPedOccupiedVehicle(g_Me) if vehicle and isElement(vehicle) then setControlText(wndMain, 'va', getVehicleName(vehicle)) else setControlText(wndMain, 'va', 'à pe.') end end end function mainWndShow() if not getPedOccupiedVehicle(g_Me) then hideControls(wndMain, 'Reparar', 'Virar', 'Tunar', 'Pintura', ' Pintura Personalizada ', 'luzesligadas', 'luzesdesligadas') end updateTimer = updateTimer or setTimer(updateGUI, 2000, 0) updateGUI(true) end function mainWndClose() killTimer(updateTimer) updateTimer = nil colorPicker.closeSelect() end function onEnterVehicle(vehicle) setControlText(wndMain, 'va', getVehicleName(vehicle)) showControls(wndMain, 'Reparar', 'Virar', 'Tunar', 'Pintura', ' Pintura Personalizada ', 'luzesligadas', 'luzesdesligadas') guiCheckBoxSetSelected(getControl(wndMain, 'luzesligadas'), getVehicleOverrideLights(vehicle) == 2) guiCheckBoxSetSelected(getControl(wndMain, 'luzesdesligadas'), getVehicleOverrideLights(vehicle) == 1) end function onExitVehicle(vehicle) setControlText(wndMain, 'va', 'à pe.') hideControls(wndMain, 'Reparar', 'Virar', 'Tunar', 'Pintura', ' Pintura Personalizada ', 'luzesligadas', 'luzesdesligadas') closeWindow(wndUpgrades) closeWindow(wndColor) end function killLocalPlayer() server.killPed(g_Me) end function alphaCommand(command, alpha) alpha = alpha and tonumber(alpha) if alpha then server.setElementAlpha(g_Me, alpha) end end addCommandHandler('xoraprint', alphaCommand) addCommandHandler('kill', killLocalPlayer) wndMain = { 'wnd', text = 'Painel do Jogador', x = 10, y = 150, width = 280, controls = { {'btn', id=' Morrer ', onclick=killLocalPlayer}, {'btn', id=' Personagens ', window=wndSkin}, {'btn', id=' Animações ', window=wndAnim}, {'btn', id=' Armamento ', window=wndWeapon}, {'btn', id=' Roupas ', window=wndClothes}, {'btn', id=' Habilidades ', window=wndStats}, {'chk', id='falloff', text='Cair ou não da Bike/Moto', onclick=toggleFallOffBike}, {'br'}, {'lbl', text='Pos:'}, {'lbl', id='xpos', text='x', width=45}, {'lbl', id='ypos', text='y', width=45}, {'lbl', id='zpos', text='z', width=45}, {'br'}, {'lbl', text='Veículos'}, {'btn', id='Criar Veículo', window=wndCreateVehicle, text=' Criar Veículo '}, {'br'}, {'btn', id='Reparar', onclick=repairVehicle}, {'btn', id='Virar', onclick=flipVehicle}, {'btn', id='Tunar', window=wndUpgrades}, {'btn', id='Pintura', onclick=openColorPicker}, {'btn', id=' Pintura Personalizada ', window=wndPaintjob}, {'chk', id='luzesligadas', text='Farol Ligado', onclick=forceLightsOn}, {'chk', id='luzesdesligadas', text='Farol Desligado', onclick=forceLightsOff}, }, oncreate = mainWndShow, onclose = mainWndClose } function errMsg(msg) outputChatBox(msg, 255, 0, 0) end addEventHandler('onClientResourceStart', g_ResRoot, function() fadeCamera(true) setTimer(getPlayers, 1000, 1) bindKey('f1', 'down', toggleFRWindow) createWindow(wndMain) hideAllWindows() guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), doesPedHaveJetPack(g_Me)) guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(g_Me)) setJetpackMaxHeight ( 9001 ) triggerServerEvent('onLoadedAtClient', g_ResRoot, g_Me) end ) function toggleFRWindow() if isWindowOpen(wndMain) then showCursor(false) hideAllWindows() colorPicker.closeSelect() else showCursor(true) showAllWindows() end end addCommandHandler('fr', toggleFRWindow) function getPlayers() g_PlayerData = {} table.each(getElementsByType('player'), joinHandler) end function joinHandler(player) if (not g_PlayerData) then return end g_PlayerData[player or source] = { name = getPlayerName(player or source), gui = {} } end addEventHandler('onClientPlayerJoin', g_Root, joinHandler) addEventHandler('onClientPlayerQuit', g_Root, function() if (not g_PlayerData) then return end table.each(g_PlayerData[source].gui, destroyElement) g_PlayerData[source] = nil end ) addEventHandler('onClientPlayerWasted', g_Me, function() onExitVehicle(g_Me) end ) addEventHandler('onClientPlayerVehicleEnter', g_Me, onEnterVehicle) addEventHandler('onClientPlayerVehicleExit', g_Me, onExitVehicle) addEventHandler('onClientResourceStop', g_ResRoot, function() showCursor(false) setPedAnimation(g_Me, false) end ) Se alguem poder ajudar Link to comment
Angelo Pereira Posted January 25, 2020 Share Posted January 25, 2020 Linha 417. function repairVehicle() local vehicle = getPedOccupiedVehicle(g_Me) if vehicle then if isTimer(timer) then outputChatBox("Aguarde 5 Segundos...") return end server.fixVehicle(vehicle) timer = setTimer(function() if isTimer(timer) then killTimer(timer) end end, 5000, 1) end end 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