Jump to content

Gw8

Members
  • Posts

    95
  • Joined

  • Last visited

Posts posted by Gw8

  1. legal, isso acontece porque você está calculando um texto que é tamanho fixo com tamanho o da tela que não é fixo kkk enfim tente isto

    local textW = dxGetTextWidth ( " MTA:SA 1.5.9*", 1, "default", false )
    
    local sx_, sy_ = guiGetScreenSize()
    --local sx, sy = sx_/1440, sy_/900
    
    addEventHandler("onClientRender", root,
        function()
    		local a = string.format("FPS: %d  PING: %d", fps, getPlayerPing(localPlayer))
    		dxDrawText(a, 0, 0, sx - textW, sy, tocolor(255, 255, 255, 255), 1.00, "default", "right", "bottom", true, false, false, false, false)
    	end
    )

     

  2. Eu trabalhei com muitos sistemas desse modelo, para Multi GameMode especificamente o melhor resultado é você criar o gerenciador de arquivos(mapas) fora mta, em um webservice php por exemplo, já para as arenas a melhor opção é utilizar eventos com base em resourceRoot, vai precisar tbm fazer tudo que o mta já faz nativamente porém fazendo alguns override em funções para conseguir carregar mapas e scripts com êxito, resumindo baixar mapas e script utilizando fetchremote e controlar o sistema utilizando eventos com resourceRoot, caso deseja comprar um sistema pode entrar em contato comigo, tenho um pronto, tmj.

    • Thanks 1
  3. ItensNaoRemoviveis = {
      ["identidade"] = true,
      ["porte"] = true,
      ["cnh"] = true,
      ["ak47natal"] = true,
    }
    
    inventario = {
      {"hamburguer", 2},
      {"suco", 3},
      {"glock", 5},
      {"kit_reparo", 2}
    }
    
    function teste()
        for i=#inventario,1,-1 do
            local item = inventario[i][1]
            if not ItensNaoRemoviveis[item] then
                table.remove(inventario,i)
            end
        end
    end
    addCommandHandler("test", teste)

    testa ae!

    • Thanks 1
  4. Na verdade vocês estão interpretando o sistema errado.

    Para voce criar um sistema onde pode aparecer uma lista de mensagens, primeiramente voce deve salvar estas mensagens em uma lista. Depois disso para voce deve montar um o dx das mensagens dentro de um FOR para que consiga atualizar as posicoes do dx confome à lista.

    Com isso voces conseguem fazer a lista de um tamanho infinito e garantir que o usuario veja todas as mensagens, da forma que voces pensaram pode ocorrer de sobre a mensagem ou até nao formar uma lista.

    local sx,sy = guiGetScreenSize()
    notify = {
    	cache = {},
    	tick = getTickCount(),
    	create = function(type,img,title,msg)
    				if type and img and title and msg then
    					notify.tick = getTickCount(),
    					table.insert(notify.cache,1,{type=type,img=img,title=title,msg=msg,posX=sx,posY=-resY(60),alpha=1,tick=getTickCount()})
    				end
    			end,
    	render = function()
    				for i,info in ipairs(notify.cache) do
    					local progress = math.min((getTickCount()-notify.tick)/1500,1)
    					local pg2 = 0
    					if progress >= 1 then
    						pg2 = math.min((getTickCount()-(notify.tick+1500))/1500,1)
    					end
    					local check = getTickCount()-info.tick
    					local posY = resY(61)*i-resY(61)+resY(5)
    					local w = dxGetTextWidth(info.msg:gsub("#%x%x%x%x%x%x",""),1,createFont("default",12),false)+resX(25)
    					local _w = resX(180)
    					local h = resY(52)
    					if w < _w then
    						w = _w
    					end
    					info.posX,info.posY = interpolateBetween(info.posX,info.posY,0,sx-w-resY(5),posY,0,progress,"Linear")
    					if progress == 1 and check >= 7000 then
    						local progress = math.min((check-7000)/1500,1)
    						info.alpha = interpolateBetween(info.alpha,0,0,0,0,0,progress,"Linear")
    						if info.alpha <= 0.1 then
    							table.remove(notify.cache,i)
    						end
    					end
    					if info.type == "error" then
    						r,g,b = 255,0,0
    						--playSound("files/error_notification.mp3")
    					elseif info.type == "info" then
    						r,g,b = 255,255,255
    						--playSound("files/notification.mp3")
    					elseif info.type == "success" then
    						r,g,b = 0,255,0
    						--playSound("files/success_notification.mp3")
    					elseif info.type == "warning" then
    						r,g,b = 255,190,0
    						--playSound("files/warning_notification.mp3")
    					else
    						r,g,b = 255,255,255
    						--playSound("files/error_notification.mp3")
    					end
    					-- background
    					dxDrawImageSection(info.posX,info.posY,w,h,10,10,1,1,"img/border.png",0,0,0,tocolor(0,0,0,220*info.alpha),true) -- backgroud
    					-- img bell
    					dxDrawImage(info.posX+resY(5)-resX(7)*pg2,info.posY+resY(5)-resY(7)*pg2,resX(13)+resX(13)*pg2,resY(13)+resX(13)*pg2,"img/bell.png",0,0,0,tocolor(255,255,255,(220-220*pg2)*info.alpha),true)
    					dxDrawImage(info.posX+resY(5),info.posY+resY(5),resX(13),resY(13),"img/bell.png",0,0,0,tocolor(255,255,255,220*info.alpha),true)
    					-- title
    					dxDrawText(info.title:upper(),info.posX+resX(25)+1,info.posY+resY(5)+1,info.posX+resX(1)+w-resX(3)+1,info.posY+resY(61)+1,tocolor(0,0,0,220*info.alpha),1,createFont("default",14),"left","top",true,false,true,true)
    					dxDrawText(info.title:upper(),info.posX+resX(25),info.posY+resY(5),info.posX+resX(1)+w-resX(3),info.posY+resY(61),tocolor(240,240,240,220*info.alpha),1,createFont("default",14),"left","top",true,false,true,true)
    					-- msg
    					dxDrawText(info.msg:gsub("#%x%x%x%x%x%x","#000000"),info.posX+resX(25)+1,info.posY+resY(30)+1,info.posX+resX(1)+w-resX(3)+1,info.posY+resY(61)+1,tocolor(0,0,0,220*info.alpha),1,createFont("default",12),"left","top",true,false,true,true)
    					dxDrawText(info.msg,info.posX+resX(25),info.posY+resY(30),info.posX+resX(1)+w-resX(3),info.posY+resY(61),tocolor(255,255,255,220*info.alpha),1,createFont("default",12),"left","top",true,false,true,true)
    					--border
    					dxRectangleLine(info.posX,info.posY,w,h,tocolor(r,g,b,20*info.alpha),true)
    				end
    			end
    }
    
    addEventHandler("onClientRender",root,notify.render)
    function createNotification(type,img,title,msg)
        notify.create(type,img,title,msg)
    end
    addEvent("createNotification",true)
    addEventHandler("createNotification",root,createNotification)

    Não teste este código, pois ele não vai funcionar no seu sistema, mas a lógica de criação da mensagem que você deve implementar é a mesma.

    Duvidas só manda é nois.

     

  5. 22 hours ago, Rakashy said:

    Como assim amigo ? não entendi muito bem

    Mano, pior que eu nem sabia que era compilado, vi o sistema, me interessei, no momento q ele me enviou eu ja vi que tava em LUAC ja fiquei meio bolado, ai vi a loja, aquela merda por marker, pedi o trigger pra EU mesmo alterar e ele se recusou. Comunidade do MTA ta foda hj em dia..

    _triggerEvent = triggerEvent
    function triggerEvent(...)
    	print(toJSON({...}))
    	_triggerEvent(...)
    end
    
    _triggerClientEvent = triggerClientEvent
    function triggerClientEvent(...)
    	print(toJSON({...}))
    	_triggerClientEvent(...)
    end

    cria um arquivo, coloca isso dentro dele.

    depois esse arquivo que voce crio coloca ele no inicio do meta, poe ele como o primeiro pra carregar.

    os dados do trigger vai aparecer no debugscript.

  6. Cria um arquivo, liga no meta no lado da onde ele é chamado server ou client, lembrando que esse arquivo deve ser o primeiro a ser carregado. depois disso cria uma a função triggerEvent, e pronto.

    Dentro dela coloque para printar os argumentos.

    Lembre-se não se compra script compilado.

  7. Cria uma variável de controle, quando voce clicar o no menu lateral setar ela.

    if tela == "home" then
      elementos da tela
    elseif tela == "usuario" then
      elementos da 
    end

    Para mostrar a tela que você deseja, tem que implementar isso no render também, caso tenha botões nessas tela também vai ser necessário implementar isso na função de click.

    É nois

  8. item = {}
    item.__index = item
    function newItem(x,y)
    	local self = setmetatable({},item)
    	self.x = x
    	self.y = y
    	return self
    end
    function newItem:getX()
    	return self.x
    end
    function newItem:setX(x)
    	self.x = x
    end
    function newItem:getY()
    	return self.y
    end
    function newItem:setY(y)
    	self.y = y
    end
    
    local myItem = newItem(50,50)
    myItem:getX()
    myItem:setX(500)

    Em questão de exportação, é complicado, no meu caso só consegui de duas maneiras:

    1. criar um controlador dentro do arquivo da 'classe Item' ou ..

    2. exporta a classe inteira para o outro resource que é basicamente copiar o arquivo da 'classe' e colocar no outro resource.

    *Não tem como instanciar o obj em um resource e exportar ele pra outro resource, esse eo ponto.

    • Like 1
  9. local screenH, screenW = guiGetScreenSize()
    local x,y = (screenH/1366),(screenW/768)
    
    local effect = {
    	alpha = 0,
    	tick = getTickCount(),
    	state = false,
    	x = 0
    }
    
    function pdx()
    	local progress = math.min((getTickCount()-effect.tick)/3000,1)
    	if effect.state then
    		effect.alpha,effect.x = interpolateBetween(effect.alpha,effect.x,0,1,x*300,0,progress,"Linear")
    	else
    		effect.alpha,effect.x = interpolateBetween(effect.alpha,effect.x,0,0,0,0,progress,"Linear")
    		if progress >= 0.9 then
    			removeEventHandler("onClientRender",root,pdx)
    		end
    	end
    	dxDrawRectangle(effect.x,y*221,x*323,y*248,tocolor(0,0,0,255*effect.alpha))
    end
    
    function abrirdx()
    	effect.state = not effect.state
    	effect.tick = getTickCount()
    	showCursor(effect.state)
    	if effect.state then
    		removeEventHandler("onClientRender",root,pdx)
    		addEventHandler("onClientRender",root,pdx)
        end
    end
    bindKey("x","down",abrirdx)

    I didn't test

  10. local screenH, screenW = guiGetScreenSize()
    local x,y = (screenH/1366),(screenW/768)
    
    local effect = {
    	alpha = 0,
    	tick = getTickCount(),
    	state = false
    }
    
    function pdx()
    	local progress = math.min((getTickCount()-effect.tick)/3000,1)
    	if effect.state then
    		effect.alpha = interpolateBetween(effect.alpha,0,0,1,0,0,progress,"Linear")
    	else
    		effect.alpha = interpolateBetween(effect.alpha,0,0,0,0,0,progress,"Linear")
    		if progress >= 0.9 then
    			removeEventHandler("onClientRender",root,pdx)
    		end
    	end
    	dxDrawRectangle(x*300,y*221,x*323,y*248,tocolor(0,0,0,255*effect.alpha))
    end
    
    function abrirdx()
    	effect.state = not effect.state
    	effect.tick = getTickCount()
    	showCursor(effect.state)
    	if effect.state then
    		removeEventHandler("onClientRender",root,pdx)
    		addEventHandler("onClientRender",root,pdx)
        end
    end
    bindKey("x","down",abrirdx)

    não testei

×
×
  • Create New...