Jump to content

SRmasazuka

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by SRmasazuka

  1. Hello everybody.

    I have a level code and a HUD. However, the HUD always returns level 0, even with the correct code and getElementData pulling saved level information. I really don't understand why it doesn't work.

    Even after hours of reading documentation about. Does anyone have light?

    Script LEVEL Cod

     

    --
    --  -_-_-_-_-      SCRIPT LEVE POR HORA     -_-_-_-_-
    --  -_-_-_-_-  EDITADO POR FAIK_MORNINGSTAR -_-_-_-_-
    --
    exports [ "scoreboard" ]:addScoreboardColumn ( "Level") 
    function upLevel (thePlayer)
        for i,player in ipairs(getElementsByType("player")) do
            if ( player ) then
                if ( getPlayerAccount(player) ) and not ( isGuestAccount(getPlayerAccount(player)) ) then
                    setElementData(player,"minutes",(getElementData(player,"minutes") or 0) +1)
                    if ( getElementData(player,"minutes") > 59 ) then
                        setElementData(player,"minutes",0)
                        setElementData(player,"Level",(getElementData(player,"Level") or 0) +1)
                            local bonus = math.random(25,950)
                            local interest = math.random(25,150)
                            local value = (bonus-interest)
                        givePlayerMoney(player,value)
                            exports.Scripts_Dxmessages:outputDx(player,'#1E90FF[LEVEL]#ffffffVocê jogou durante 1hora e Obteve +1 level.',player,255,255,255,true)
                            outputChatBox("#FFFFFFPagamento : R$ #00FF00"..value, player, 255, 255, 255, true )
                        local accName = getAccountName ( getPlayerAccount ( player ) )
                        if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Everyone" ) ) then
                        end
                    end
                end
            end
        end
    end
    setTimer(upLevel,60000,0)
    -- Comandos by Faik
    addCommandHandler ("setlevel", function (thePlayer, cmd, account, level)
    	local theJogador = getPlayerFromName (account)
    	if (not theJogador) or (not level) then return end
    	if (isObjectInACLGroup ("user."..getAccountName (getPlayerAccount (thePlayer)), aclGetGroup ("Console"))) then
    	setElementData (theJogador, "Level", tonumber(level))
    	exports.Scripts_Dxmessages:outputDx(thePlayer,'#1E90FF[LEVEL]#ffffffLevel setado com sucesso.',thePlayer,255,255,255,true)
        end
    end)
    
    addCommandHandler ("setxp", function (thePlayer, cmd, account, minutes)
    	local theJogador = getPlayerFromName (account)
    	if (not theJogador) or (not minutes) then return end
    	if (isObjectInACLGroup ("user."..getAccountName (getPlayerAccount (thePlayer)), aclGetGroup ("Console"))) then
    	setElementData (theJogador, "minutes", tonumber(minutes))
    	exports.Scripts_Dxmessages:outputDx(thePlayer,'#1E90FF[EXPERIENCIA]#ffffffNível de experiencia setado com sucesso.',thePlayer,255,255,255,true)
        end
    end)
    
    -- Fim Comandos by Faik
    
    function setLevelLogin ()
    	local account = getPlayerAccount(source)
    	if ( account ) then
    		local Level = (getAccountData(account,"Level") or 0)
    		local minutes = (getAccountData(account,"minutes") or 0)
    		setElementData(source,"Level",Level)
    		setElementData(source,"minutes",minutes)
    	end
    end
    addEventHandler("onPlayerLogin",getRootElement(),setLevelLogin)
    
    function setLevelJoin ()
    	setElementData(source,"Level",0)
    	setElementData(source,"minutes",0)
    end
    addEventHandler("onPlayerJoin",getRootElement(),setLevelJoin)
    
    function setLevelQuit ()
    	local account = getPlayerAccount(source)
    	if ( account ) then
    		local minutes = (getElementData(source,"minutes") or 0)
    		local Level = (getElementData(source,"Level") or 0)
    		setAccountData(account,"minutes",minutes)
    		setAccountData(account,"Level",Level)
    	end
    end
    addEventHandler("onPlayerQuit",getRootElement(),setLevelQuit)

    Script HUD (Client)
     

    local screenW,screenH = guiGetScreenSize()
    local px,py = 1600,900
    local x,y = (screenW/px), (screenH/py)
    
    local font1 = dxCreateFont("files/Gilroy-Light.ttf", 20)
    local font2 = dxCreateFont("files/Gilroy-Medium.ttf", 20)
    local font3 = dxCreateFont("files/Gilroy-Regular.ttf", 40)
    
    function enableCustomHUD()
    	customHUDEnabled = not customHUDEnabled
    	setPlayerHudComponentVisible("ammo", not customHUDEnabled)
    	setPlayerHudComponentVisible("health", not customHUDEnabled)
    	setPlayerHudComponentVisible("armour", not customHUDEnabled)
    	setPlayerHudComponentVisible("breath", not customHUDEnabled)
    	setPlayerHudComponentVisible("clock", not customHUDEnabled)	
    	setPlayerHudComponentVisible("money", not customHUDEnabled)
    	setPlayerHudComponentVisible("weapon", not customHUDEnabled)
    	setPlayerHudComponentVisible("vehicle_name", not customHUDEnabled)
    	setPlayerHudComponentVisible("area_name", not customHUDEnabled)
    	setPlayerHudComponentVisible("radio", not customHUDEnabled)
        setPlayerHudComponentVisible("wanted", not customHUDEnabled)
    	--setPlayerHudComponentVisible("radar", not customHUDEnabled)
    end
    
    addCommandHandler("customhud", enableCustomHUD)
    enableCustomHUD()
    
    --------------------------------------------------
    
    function dxHud()
    
    	local name = getPlayerName (localPlayer)
        
        local money = string.gsub(getPlayerMoney(), "^(-?%d+),(%d%d%d)", "%1 %2")
        local money = string.gsub(money, "^(-?%d+)(%d%d%d)", "%1 %2")
        local money = string.gsub(money, "^(-?%d+)(%d%d%d)", "%1 %2")
        
        local level = getElementData(localPlayer, "player:level") or 1
        local xp = getElementData(localPlayer, "player:xp") or 0
        
        local time = getRealTime()
    	local hours = time.hour
    	local minutes = time.minute
        if minutes <= 9 then
            minutes = "0"..minutes
        end
        
        local dia = ("%02d"):format(time.monthday)
        local mes = ("%02d"):format(time.month+1)
        
        dxDrawText(name, x*1245, y*35, x*1670, y*25, tocolor(255, 255, 255, 255), 0.5, font2, "left", "center", false, false, true, true, false)
        dxDrawText(money.." $", x*1295, y*245, x*1670, y*25, tocolor(255, 255, 255, 255), 0.75, font1, "left", "center", false, false, true, true, false)
        dxDrawText("Nível: "..level, 1250*x, 77*y, 1670*x, 25*y, tocolor(255, 255, 255, 255), 0.4, font2, "left", "center", false, false, true, true, false)
        dxDrawText("EXP: "..math.floor(xp).."/"..(level*400), 1355*x, 77*y, 1670*x, 25*y, tocolor(255, 255, 255, 255), 0.4, font2, "left", "center", false, false, true, true, false)
        
        dxDrawText(hours..":"..minutes, x*1415, y*240, x*1670, y*25, tocolor(255,255,255, 255), 0.5, font3, "center", "center", false, false, true, true, false)
        
        dxDrawText(dia, x*1290, y*220, x*1670, y*25, tocolor(255, 255, 255, 255), 0.55, font1, "center", "center", false, false, true, true, false)
        dxDrawText(mes, x*1290, y*260, x*1670, y*25, tocolor(255, 255, 255, 255), 0.55, font1, "center", "center", false, false, true, true, false)
        
        Health = math.floor(getElementHealth(localPlayer))
        armor = math.floor(getPedArmor(localPlayer))
        dxDrawRectangle(1270*x, 70*y, 2.04*x*Health, (12/y)*y, tocolor(220,37,72,255), false) -- Здоровье
        dxDrawRectangle(1270*x, 93*y, 2.04*x*armor, (12/y)*y, tocolor(255,255,255,255), false) -- Голод
        
        dxDrawImage(1235*x, 15*y, 355*x, 140*y,"files/hud.png",0.0,0.0,0.0,tocolor(255,255,255,255), false)
    end
    
    function renderDxHud()
    	addEventHandler("onClientRender", getRootElement(), dxHud)
    end
    addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), renderDxHud)
    
    
    function toggleHud()
    	if isVisible then
    		addEventHandler("onClientRender", root, dxHud)
    	else
    		removeEventHandler("onClientRender", root, dxHud)
    	end
    	isVisible = not isVisible
    end
    addCommandHandler("hud", toggleHud)
    
    local playerMoney = getPlayerMoney ( localPlayer )
    local messages =  { }
    
    addEventHandler ( "onClientRender", root, function ( )
    	local tick = getTickCount ( )
    	if ( playerMoney ~= getPlayerMoney ( localPlayer ) ) then
    		local pM = getPlayerMoney ( localPlayer ) 
    		if ( pM > playerMoney ) then
    			local diff = pM - playerMoney
    			table.insert ( messages, { diff, true, tick + 2500, 180 } )
    		else
    			local diff = playerMoney - pM
    			table.insert ( messages, { diff, false, tick + 2500, 180 } )
    		end
    		playerMoney = pM
    	end
    	
    	if ( #messages > 7 ) then
    		table.remove ( messages, 1 )
    	end
    	
    	for index, data in ipairs ( messages ) do
    		local v1 = data[1]
    		local v2 = data[2]
    		local v3 = data[3]
    		local v4 = data[4]
            
    		if ( v2 ) then
    			dxDrawText ( "+ "..convertNumber(v1).." $", 1275*x, 350*y -(index*25), 50*x, 20*y, tocolor(0, 255, 0, v4+75), 0.75, font1, "left", "center", false, false, true, true, false)
    		else
    			dxDrawText ( "- "..convertNumber(v1).." $", 1275*x, 350*y -(index*25), 50*x, 20*y, tocolor(255, 0, 0, v4+75), 0.75, font1, "left", "center", false, false, true, true, false)
    		end
    		
    		if (tick >= v3) then
    			messages[index][4] = v4-2
    			if (v4 <= 25) then
    				table.remove (messages, index)
    			end
    		end
    	end
    end )
    
    
    
    function convertNumber(number)  
    	local formatted = number  
    	while true do      
    		formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1 %2')    
    		if (k==0) then      
    			break   
    		end  
    	end  
    	return formatted
    end

     

  2. On 28/04/2021 at 18:00, Sarrum said:

    ?. If you are talking about the loading bar progress, it's a visual bug.
    Suppose we have files with a size of 200 MB, due to compression only 100 MB will be transferred.
    MTA will show that 200 MB is being downloaded, but after 50% the download will be completed.O MTA mostrará que 200 MB estão sendo baixados, mas depois de 50% o download estará concluído.

    Thanks for the clear explanation.

    Many customers question me about this and I don't know how to respond objectively to the problem. Thanks

    On 4/28/2021 at 6:35 PM, Dutchman101 said:

    At the time i wrote this discussion: https://github.com/multitheftauto/mtasa-blue/discussions/1909 i didn't know much about any such compression already working on MTA, but apparently yes and that explains the DL size having a visual bug that @Sarrum described.

    That discussion contains some interesting info that you may want to read, though

    @SRmasazuka

    I read and understood more about it. Even though I made the compression system via nginx I didn't really understand how it worked.

    Perhaps this post will help others.

  3. Hello Everyone !

    I apologize if this post is in the wrong area.

     

    I have a hosting company where I use TCAdmin for server administration.

    The servers have a download and compression system using Nginx and everything works fine.

    The only problem is, a server on which the download should have its size at 100MB when sent to hosting it starts to have a size of 200MB.

    I noticed that this also occurs in some cases with files on Windows when unzipped. Does anyone know why this occurs?

  4. Olá todos. Perdoem caso esteja numa área errada do fórum.

    Recentemente adquiri um servidor virtual para fazer ali hospedagens de servidores mta:sa. Inicialmente tentei com windows e coloquei sites online etc. Porem não consigo fazer o modo de compressão para os servidores mta:sa
    Formatei a maquina com o debian8(Já que o wiki mta ensina no debian 7) mas nao passei da etapa de criação do mtaserver1, sou muito leigo no linux.
    Se alguém souber e poder me ajudar ou souber um tutorial mais detalhado sobre isso ficarei extremamente grato.

    :D

  5. Olá, bom dia a todos. Alguém poderia me ajudar em algo que é "digamos" chato.

    O servidor fica apresentando os nomes dos veiculos quando entra e nome dos bairros ao passar. Sendo que o radar já faz isso.
    Algumas prints

     

    https://imgur.com/XGBH3Hf

    https://imgur.com/jd3qrUO

    https://imgur.com/R9sL3so

    Agradeço desde já a ajuda :)

    @edit

    Tentei fazer

     

    addEventHandler ( "onPlayerJoin", root, 
        function ()
            setPlayerHudComponentVisible ( source, "area_name", false )
            setPlayerHudComponentVisible ( source, "vehicle_name", false )
        end

    Em um momento funcionou, mas ao sair e entrar no veiculo voltou a aparecer nome dos veiculos e lugares '-'

  6. 18 hours ago, Eficiencia said:

    Cara, acho que a melhor maneira é quando cara fechar o caixa setar uma data, ai no mod de enviar dinheiro verificar se ela é true, e por um setTime para remover a data, pois assim ira dar tempo para salvar os dados.

    Ai se ela for true cancela o envio do dinheiro.

    Obrigado por responder.

    O problema é que não sou programador e utilizo nos encontrados na net. Não sei como alterar tanto assim os códigos.

  7. Previamente venho pedir desculpas caso eu esteja postando isto no lugar errado.

    Meu servidor já iniciou com inimigos... Inimigos esses que utilizam os mesmos mods que eu, todos da internet.
    Já entraram no servidor e bugaram o dinheiro da seguinte forma.
    Indo ao caixa eletronico sacando o dinheiro, transferindo a outro jogador e depois deslogando e logando por bind.
    Logo que descobri fiz um bloqueio dos comandos /login /register /logout no f8.

    Mesmo assim hoje dia 30 de setembro vim a ter o mesmo problema, bugaram dinheiro e mandaram quase 1kk a todos os jogadores e não sei como resolver desta vez.
    Se alguém poderia me ajudar gostaria de saber se existe um modo de sanar de vez este bug do dinheiro. Pelo visto é a única falha no meu servidor.

    Desde já agradeço ^^

×
×
  • Create New...