Jump to content

Mefisto_PL

Members
  • Posts

    460
  • Joined

  • Last visited

Posts posted by Mefisto_PL

  1. I was trying to use this method, but after all this pain i've been through, it still looks different on each resolution, it works perfectly on 800x600.

    Here is the photo of 1280x1024:
    https://imgur.com/nYswa5d

    The text should be in the right corner

    local devSX = 1920
    local devSY = 1080
    local sx, sy = guiGetScreenSize()
    local scaleV = sy / devSY
    scaleV = math.max(scaleV, 0.65)
    
    function statsShow ()
    local text = "Ping: " ..getPlayerPing(localPlayer) .. " | FPS: " .. getElementData(localPlayer, "FPS")
    local textWidth = dxGetTextWidth(text)
    local centerX = sx/2
    local centerY = sy/2
    local textX = centerX - ((scaleV*-840)/2)
    local textY = centerY - ((scaleV*-830)/2)
        dxDrawText( text, textX-2, textY, textWidth, sy, tocolor(0, 0, 0, 255), scaleV*2, "arial")
        dxDrawText( text, textX+2, textY, textWidth, sy, tocolor(0, 0, 0, 255), scaleV*2, "arial")
        dxDrawText( text, textX, textY-2, textWidth, sy, tocolor(0, 0, 0, 255), scaleV*2, "arial")
        dxDrawText( text, textX, textY+2, textWidth, sy, tocolor(0, 0, 0, 255), scaleV*2, "arial")
        dxDrawText( text, textX, textY, textWidth, sy, tocolor(255, 255, 255, 255), scaleV*2, "arial")
    end
    addEventHandler("onClientRender", root, statsShow)
    
  2. Hi, I've got an interesting bug with my localchat script. When the players are in range of local chat then for some of them a *action text* part is not colored, but when they're alone in their chat distance, everything works fine and message is fully colored.
     

    	function RGBToHex(red, green, blue, alpha)
        
        -- Make sure RGB values passed to this function are correct
        if( ( red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 ) or ( alpha and ( alpha < 0 or alpha > 255 ) ) ) then
            return nil
        end
    	    -- Alpha check
        if alpha then
            return string.format("#%.2X%.2X%.2X%.2X", red, green, blue, alpha)
        else
            return string.format("#%.2X%.2X%.2X", red, green, blue)
        end
    	end
    	function localchat (msg, msgtype, cmdname)
        local x, y, z = getElementPosition (source)
        local playerdim = getElementDimension (source)
        local range = 30
        local playerName = getPlayerName (source)
            for index, player in pairs(getElementsByType ("player")) do 
                local playersdim = getElementDimension (player)
                    if playerdim == playersdim then 
                        local xp, yp, yz = getElementPosition (player)
                        local distance = getDistanceBetweenPoints3D (x, y, z, xp, yp, yz)
                            if  ( distance <= range ) then
                                r = tonumber (255 - (tonumber((distance))* 3))
                                g = tonumber (255 - (tonumber((distance))* 3))
                                b = tonumber (255 - (tonumber((distance))* 3))
                                mr = tonumber (255 - (tonumber((distance))* 3))
                                mg = 0
                                mb = tonumber (255 - (tonumber((distance))* 3))
                                if msgtype == 0 then
                                    cancelEvent()
                                    msg = string.gsub(msg, "#%x%x%x%x%x%x", "")
                                    msg = msg:gsub("^%l", string.upper)
                                    playerName = string.gsub(playerName, "#%x%x%x%x%x%x", "")
                                    playerName = string.gsub(playerName, "_", " ")
                                    mecolor = RGBToHex(mr, mg, mb)
                                    normalcolor = RGBToHex(r, g, b)
                                    while true do
                                            local find,find2 = string.find(msg, "%<(.-)%>")
                                                if (find and find2) then
                                                    msg = string.sub(msg,1,find-1) .. mecolor .. "*".. string.sub(msg, find+1, find2-1) .. "*" .. normalcolor .. string.sub(msg, find2+1, #msg)
                                                    else
                                                        break
                                                end
                                    end
                                        if string.find(msg, ".", -1, true) or string.find(msg, "?", -1, true) or string.find(msg, "!", -1, true) then
                                                        outputChatBox(playerName .. " mówi: " .. msg , player, r, g, b, true)
                                                else
                                                        msg = msg.. "."
                                                        outputChatBox(playerName .. " mówi: " .. msg , player, r, g, b, true)
                                                        --outputChatBox(playerName .. " mówi: " .. msg .. ".", player, 255, 255, 255, true)
                                        end
                                end
                            end
                    end
            end
    end
    addEventHandler("onPlayerChat", getRootElement(), localchat)
  3. local troller = getPlayerName(root,thePlayer) - wat? 
    

    There root isn't needed. Try this:

    function getPlayerFromNamePart(name) 
        local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
        if name then 
            for _, player in ipairs(getElementsByType("player")) do 
                local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
                if name_:find(name, 1, true) then 
                    return player 
                end 
            end 
        end 
    end 
      
    function trollRandomPlayerWithFire(commandName,thePlayer,theTarget) 
      
    local target = getPlayerFromNamePart ( theTarget ) 
    local troller = getPlayerName( getLocalPlayer() ) 
         if ( theTarget ) then 
                 setPedOnFire(target,true) 
                 outputChatBox("You've been set on fire by" .. troller .. "",root,255,0,0,true) 
                 outputDebugString( target .. "has been set on fire by" .. troller .. "" ) 
       end 
    end 
    addCommandHandler("fire",trollRandomPlayerWithFire) 
    

  4. function getPlayerFromNamePart(name) 
        local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
        if name then 
            for _, player in ipairs(getElementsByType("player")) do 
                local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
                if name_:find(name, 1, true) then 
                    return player 
                end 
            end 
        end 
    end 
      
    function trollRandomPlayerWithFire(commandName,thePlayer,theTarget) 
      
    local target = getPlayerFromNamePart ( theTarget ) 
    local troller = getPlayerName(thePlayer) 
         if ( theTarget ) then 
                 setPedOnFire(theTarget,true) 
                 outputChatBox("You've been set on fire by" .. troller .. "",255,0,0) 
                 outputDebugString( target .. "has been set on fire by" .. troller .. "" ) -- If your argument is first what you want to add in chat/debug then you don't have to put ".." before it or if it's the last argument and it close your message then you don't have to put ".." after it. 
       end 
    end 
    addCommandHandler("fire",trollRandomPlayerWithFire) 
    

  5. My function should change colors in my buttons and it's working.. but I add event that when mouse leave from this button then colors should be changed again and now when I move cursor up then simple change colors, but when I move cursor down, left, right it isn't changed..

    function spawnMenuInit ( ) 
    if source == ls_bg then 
    guiLabelSetColor ( ls_label, 255, 255, 255 ) 
    guiSetProperty ( ls_bg, "ImageColours", "tl:FF000000 tr:FF000000 bl:FF000000 br:FF000000" ) 
    elseif source == sf_bg then 
    guiLabelSetColor ( sf_label, 255, 255, 255 ) 
    guiSetProperty ( sf_bg, "ImageColours", "tl:FF000000 tr:FF000000 bl:FF000000 br:FF000000" ) 
    elseif source == lv_bg then 
    guiLabelSetColor ( lv_label, 255, 255, 255 ) 
    guiSetProperty ( lv_bg, "ImageColours", "tl:FF000000 tr:FF000000 bl:FF000000 br:FF000000" ) 
    end 
    end 
    addEventHandler( "onClientMouseEnter", getRootElement(), spawnMenuInit ) 
      
    function spawnMenuLeave ( ) 
    if source == ls_bg then 
    guiLabelSetColor ( ls_label, 155, 155, 155 ) 
    guiSetProperty ( ls_bg, "ImageColours", "tl:CC000000 tr:CC000000 bl:AA000000 br:AA000000" ) 
    elseif source == sf_bg then 
    guiLabelSetColor ( sf_label, 155, 155, 155 ) 
    guiSetProperty ( sf_bg, "ImageColours", "tl:AA000000 tr:AA000000 bl:AA000000 br:AA000000" ) 
    elseif source == lv_bg then 
    guiLabelSetColor ( lv_label, 155, 155, 155 ) 
    guiSetProperty ( lv_bg, "ImageColours", "tl:AA000000 tr:AA000000 bl:CC000000 br:CC000000" ) 
    end 
    end 
    addEventHandler( "onClientMouseLeave", getRootElement(), spawnMenuLeave ) 
    

  6. Nie odbezpieczysz, zabezpieczane jest to właśnie żeby nikt nie kradł tego kodu. Jest dekoder lua, ale nie jest na tyle sprawny, żeby przetłumaczyć dobrze kod i on działał poprawnie, w każdym razie nawet jeśli przetłumaczy jest on wciąż nie zrozumiały, nie ma dziwnych krzaczków, ale tego po prostu nie zrozumiesz. :P

  7. TriggerEvent służy do wywołania funkcji połączonej z eventem stworzonym za pomocą "addEvent". Wytłumaczę Ci kodem.

    addEvent ( "mojwlasniestworzonyevent", true ) 
      
    function TextTest ( ) 
    outputChatBox ( "TEXT TEXT TEXT" ) 
    end 
    addEventHandler ( "mojwlasniestworzonyevent", getRootElement(), TextTest ) 
    

    Korzystając teraz z triggerClientEvent ( "mojwlasniestworzonyevent", getRootElement() ) wywołasz funkcję TextTest.

  8. poli = createTeam ( "PGM", 193, 177, 2 ) 
      
      
    function poli1 ( thePlayer ) 
    local playerName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ( "user." .. playerName, aclGetGroup ( "PGM" ) ) then 
    setPlayerTeam ( thePlayer, poli )     
    setElementPosition ( thePlayer, 1549.84143, -1208.50720, 20.03212 ) 
    setPlayerNametagColor ( thePlayer, 193, 177, 2 ) 
    else 
    outputChatBox( "Nie jestes w tym gangu.", getRootElement()) 
    end 
    end 
    addEventHandler("onPlayerLogin",getRootElement(),poli1) 
    

  9. Sorry for double post, I can't remove post before.

    I change fadeCamera to true and it's showed now, but only for 2 seconds and screen backs to black color.. Anybody know how to fix it?

    function notifyLoadingMap( mapName, authorName ) 
        fadeCamera ( true ) 
        setCameraMatrix ( 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316 ) 
        TravelScreen.show( mapName, authorName ) 
        showChat ( false ) 
    end 
    

    ///EDIT

    I found that in race_client.lua, but I don't know what I must change, i tried but it always was fail :D There is a code ( not full but this part is important )

        fadeCamera( false, 0.0 ) 
      
        -- Editor start 
        if isEditor() then 
            editorInitRace() 
            return 
        end 
      
        -- Min 3 seconds on travel message 
        local delay = TravelScreen.getTicksRemaining() 
        delay = math.max(50,delay) 
        setTimer(TravelScreen.hide,delay,1) 
      
        -- Delay readyness until after title 
        TitleScreen.bringForwardFadeout(3000) 
        delay = delay + math.max( 0, TitleScreen.getTicksRemaining() - 1500 ) 
      
        -- Do fadeup and then tell server client is ready 
        setTimer(fadeCamera, delay + 750, 1, true, 10.0) 
        setTimer(fadeCamera, delay + 1500, 1, true, 2.0) 
      
        setTimer( function() triggerServerEvent('onNotifyPlayerReady', g_Me) end, delay + 3500, 1 ) 
        outputDebug( 'MISC', 'initRace end' ) 
        setTimer( function() setCameraBehindVehicle( g_Vehicle ) end, delay + 300, 1 ) 
    end 
    

  10. It's default function from Race, only added setCameraMatrix.

    PS. This event starts function..

    addEventHandler('onGamemodeMapStart', g_Root, 
        function(mapres) 
            outputDebugString('onGamemodeMapStart(' .. getResourceName(mapres) .. ')') 
            if getTotalPlayerCount() == 0 then 
                outputDebugString('Stopping map') 
                triggerEvent('onGamemodeMapStop', g_Root) 
                return 
            end 
            gotoState('LoadingMap') 
            -- set up all players as not ready 
            for i,player in ipairs(getElementsByType('player')) do 
                setPlayerNotReady(player) 
            end 
            -- tell clients new map is loading 
            clientCall(g_Root, 'notifyLoadingMap', getResourceInfo(mapres, "name") or getResourceName(mapres), g_GameOptions.showauthorname and getResourceInfo( mapres , "author") ) 
      
            if g_CurrentRaceMode then 
                outputDebugString('Unloading previous map') 
                unloadAll() 
            end 
            TimerManager.createTimerFor("raceresource","loadmap"):setTimer( doLoadMap, 50, 1 ,mapres ) 
        end 
    ) 
    

  11. Hi everyone ! I want to simply change the loading screen effect, but there is a one problem. I put there a setCameraMatrix, but it doesn't work.. Only black screen and my text which I render.. In debugscript isn't any error. I add only setCameraMatrix and nothing else. Only for see how it looks, here is a code.

    function notifyLoadingMap( mapName, authorName ) 
        --fadeCamera( false, 0.0, 0,0,0 ) -- fadeout, instant, black 
        setCameraMatrix ( 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316 ) 
        TravelScreen.show( mapName, authorName ) 
        showChat ( false ) 
    end 
    

  12. Hi, I made code which shows how many players is alive, it was working, but now it doesn't.. Debugscript: "@bad argument 'dxDrawText'' [expected number at argument 16, got boolean]". - but wtf, there is no needed number.. Here is a code:

      
    bnt_font = dxCreateFont ( "fonts/bnt.ttf", 20 ) 
      
    function aliveplayers ( ) 
    local screenWidth, screenHeight = guiGetScreenSize() 
        dxDrawText ( '#006699ALIVE: #FFFFFF' .. tonumber(getRaceAlivePlayers ( )), 2, screenHeight - dxGetFontHeight(0.7, bnt_font)/0.5, 0.5, 1.5, tocolor ( 255, 255, 255, 255 ), 0.9, bnt_font, 'left', 'top', false, false, false, true, false, false) 
    end 
    addEventHandler ( "onClientRender", getRootElement(), aliveplayers ) 
      
      
    function getRaceAlivePlayers ( ) 
        local players = 0 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            if ( getElementData ( player, "state" ) == "alive" ) then 
                players = ( players + 1 ) 
            end 
        end 
      
        return players 
    end 
    

×
×
  • Create New...