Jump to content

country on dxjoinquit


SnoopCat

Recommended Posts

hey my question is how i can add the admin flags to a dxjoinmsg when a player joins? or if cant add flags just adding the country name?

should i must use

getFormatedCountry 

and if i have to use it , where i have to put it?

font = dxCreateFont("font.ttf", 18) 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    while s do 
        if cap == "" and col then color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), 
        tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) end 
        if s ~= 1 or cap ~= "" then 
            local w = dxGetTextWidth(cap, scale, font) 
            dxDrawText( cap, ax, ay, ax + w, by, color, scale, font ) 
            ax = ax + w 
            color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) 
        end 
        last = e + 1 
        s, e, cap, col = str:find( pat, last ) 
    end 
    if last <= #str then 
        cap = str:sub( last ) 
        local w = dxGetTextWidth( cap, scale, font ) 
        dxDrawText( cap, ax, ay, ax + w, by, color, scale, font, left, top, clip, wordbreak, postGUI ) 
    end 
end 
  
local messageJoin = "" 
local messageQuit = "" 
function renderPlayerJoined ( ) 
    dxDrawColorText("► ".. messageJoin,400,750.0,574.0,20.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) 
end 
  
function renderPlayerLeft ( ) 
    dxDrawColorText("◄ ".. messageQuit,400,740.0,574.0,32.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) 
end 
  
addEventHandler('onClientPlayerJoin', root, 
    function() 
        messageJoin = getPlayerName(source) .. " #00A6FFhas #FFFFFFJoin #00A6FFThe server." 
        addEventHandler ( "onClientRender", root, renderPlayerJoined ) 
        setTimer ( 
            function ( ) 
                removeEventHandler ( "onClientRender", root, renderPlayerJoined ) 
            end 
            ,7000,1 
        ) 
    end 
) 
  
  
addEventHandler('onClientPlayerQuit', root, 
    function(reason) 
        messageQuit  = getPlayerName(source) .. " #00A6FFhas #FFFFFFLeft #00A6FFThe server.#FFFFFF [" .. reason .. "]" 
        addEventHandler ( "onClientRender", root, renderPlayerLeft ) 
        setTimer ( 
            function ( ) 
                removeEventHandler ( "onClientRender", root, renderPlayerLeft ) 
            end 
            ,7000,1 
        ) 
    end 
) 
fileDelete("joinquit.lua") 

Link to comment

no , but this is what uses the scoreboard country id

exports.scoreboard:addScoreboardColumn('Country') 
function showHome () 
local Home = call(getResourceFromName("admin"), "getPlayerCountry", source) 
    setElementData(source,"Country",Home) 
end 
addEventHandler("onPlayerJoin",getRootElement(),showHome) 

i want to do something similar but on xdjoin msg :/

Link to comment
addEventHandler('onClientPlayerJoin', root, 
    function() 
country = getElementData(source,"Country") 
        messageJoin = getPlayerName(source) .. " #00A6FFhas #FFFFFFJoin #00A6FFThe server "..country.."." 
        addEventHandler ( "onClientRender", root, renderPlayerJoined ) 
        setTimer ( 
            function ( ) 
                removeEventHandler ( "onClientRender", root, renderPlayerJoined ) 
            end 
            ,7000,1 
        ) 
    end 
) 

try that

Link to comment
now join msg dont appear :/

debugscrip 3

Sin_t_tulo.png

font = dxCreateFont("font.ttf", 18) 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    while s do 
        if cap == "" and col then color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), 
        tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) end 
        if s ~= 1 or cap ~= "" then 
            local w = dxGetTextWidth(cap, scale, font) 
            dxDrawText( cap, ax, ay, ax + w, by, color, scale, font ) 
            ax = ax + w 
            color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) 
        end 
        last = e + 1 
        s, e, cap, col = str:find( pat, last ) 
    end 
    if last <= #str then 
        cap = str:sub( last ) 
        local w = dxGetTextWidth( cap, scale, font ) 
        dxDrawText( cap, ax, ay, ax + w, by, color, scale, font, left, top, clip, wordbreak, postGUI ) 
    end 
end 
  
local messageJoin = "" 
local messageQuit = "" 
function renderPlayerJoined ( ) 
    dxDrawColorText("► ".. messageJoin,400,750.0,574.0,20.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) 
end 
  
function renderPlayerLeft ( ) 
    dxDrawColorText("◄ ".. messageQuit,400,740.0,574.0,32.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) 
end 
  
    addEventHandler('onClientPlayerJoin', root, 
        function() 
    country = getElementData(source,"Country") 
            messageJoin = getPlayerName(source) .. " #00A6FFhas #FFFFFFJoin #00A6FFThe server "..country.."." 
            addEventHandler ( "onClientRender", root, renderPlayerJoined ) 
            setTimer ( 
                function ( ) 
                    removeEventHandler ( "onClientRender", root, renderPlayerJoined ) 
                end 
                ,7000,1 
            ) 
        end 
    ) 
  
  
addEventHandler('onClientPlayerQuit', root, 
    function(reason) 
        messageQuit  = getPlayerName(source) .. " #00A6FFhas #FFFFFFLeft #00A6FFThe server.#FFFFFF [" .. reason .. "]" 
        addEventHandler ( "onClientRender", root, renderPlayerLeft ) 
        setTimer ( 
            function ( ) 
                removeEventHandler ( "onClientRender", root, renderPlayerLeft ) 
            end 
            ,7000,1 
        ) 
    end 
) 
fileDelete("joinquit.lua") 

Link to comment
  • Other Languages Moderators

Try.

-- Server Side --

function showHome() 
     local Home = exports.admin:getPlayerCountry(source) or "N/A" 
     setElementData(source,"Country",Home) 
end 
addEventHandler("onPlayerJoin", root, showHome) 

-- Client Side --

font = dxCreateFont("font.ttf", 18) 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    while s do 
        if cap == "" and col then color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), 
        tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) end 
        if s ~= 1 or cap ~= "" then 
            local w = dxGetTextWidth(cap, scale, font) 
            dxDrawText( cap, ax, ay, ax + w, by, color, scale, font ) 
            ax = ax + w 
            color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) 
        end 
        last = e + 1 
        s, e, cap, col = str:find( pat, last ) 
    end 
    if last <= #str then 
        cap = str:sub( last ) 
        local w = dxGetTextWidth( cap, scale, font ) 
        dxDrawText( cap, ax, ay, ax + w, by, color, scale, font, left, top, clip, wordbreak, postGUI ) 
    end 
end 
  
local messageJoin = "" 
local messageQuit = "" 
function renderPlayerJoined() 
     dxDrawColorText("► ".. messageJoin,400,750.0,574.0,20.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) 
end 
  
function renderPlayerLeft() 
     dxDrawColorText("◄ ".. messageQuit,400,740.0,574.0,32.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) 
end 
  
addEventHandler('onClientPlayerJoin', root, 
function() 
     setTimer(function(source) 
          local country = getElementData(source,"Country") 
          messageJoin = getPlayerName(source).." #00A6FFhas #FFFFFFJoin #00A6FFThe server "..country.."." 
          addEventHandler("onClientRender", root, renderPlayerJoined) 
          setTimer(function() 
               removeEventHandler("onClientRender", root, renderPlayerJoined) 
          end,7000,1) 
     end,250,1,source) 
end) 
  
addEventHandler('onClientPlayerQuit', root, 
function(reason) 
     messageQuit  = getPlayerName(source) .. " #00A6FFhas #FFFFFFLeft #00A6FFThe server.#FFFFFF [" .. reason .. "]" 
     addEventHandler("onClientRender", root, renderPlayerLeft) 
     setTimer(function() 
          removeEventHandler("onClientRender", root, renderPlayerLeft) 
     end,7000,1) 
end) 
  
fileDelete("joinquit.lua") 

Link to comment
  • Other Languages Moderators
it works :D thx and if i want to create it whit flags image from admn ? like scoreboard?

You want get the flags image from admin panel? if so

local imgPath = ":admin/client/images/flags/"..getElementData(source,"Country")..".png" 

Link to comment

hey bro i replaced that syntax on the server script but this is what i get:

Sin_t_tulo.png

i did this:

    function showHome() 
         local imgPath = ":admin/client/images/flags/"..getElementData(source,"Country")..".png" 
         setElementData(source,"Country",Home) 
    end 
    addEventHandler("onPlayerJoin", root, showHome) 

Link to comment

Server

function showHome() 
    local Home = exports.admin:getPlayerCountry(source) or "N/A" 
    setElementData(source,"Country",Home) 
end 
addEventHandler("onPlayerJoin", root, showHome) 

Client

font = dxCreateFont("font.ttf", 18) 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    while s do 
        if cap == "" and col then color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), 
        tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) end 
        if s ~= 1 or cap ~= "" then 
            local w = dxGetTextWidth(cap, scale, font) 
            dxDrawText( cap, ax, ay, ax + w, by, color, scale, font ) 
            ax = ax + w 
            color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) 
        end 
        last = e + 1 
        s, e, cap, col = str:find( pat, last ) 
    end 
    if last <= #str then 
        cap = str:sub( last ) 
        local w = dxGetTextWidth( cap, scale, font ) 
        dxDrawText( cap, ax, ay, ax + w, by, color, scale, font, left, top, clip, wordbreak, postGUI ) 
    end 
end 
  
local messageJoin = "" 
local messageQuit = "" 
  
function renderPlayerJoined() 
    dxDrawColorText("> ".. messageJoin,400,750.0,574.0,20.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) 
    dxDrawImage ( Your posX, Your posY, Your width, Your Height, imgPath , 0, 0, 0,tocolor(255,255,255,255),true) 
end 
  
function renderPlayerLeft() 
    dxDrawColorText("< ".. messageQuit,400,740.0,574.0,32.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) 
end 
  
addEventHandler('onClientPlayerJoin', root, 
function() 
     setTimer(function(source) 
          local country = getElementData(source,"Country") 
          local imgPath = ":admin/client/images/flags/"..getElementData(source,"Country")..".png" 
          messageJoin = getPlayerName(source).." #00A6FFhas #FFFFFFJoin #00A6FFThe server "..country.."." 
          addEventHandler("onClientRender", root, renderPlayerJoined) 
          setTimer(function() 
               removeEventHandler("onClientRender", root, renderPlayerJoined) 
          end,7000,1) 
     end,250,1,source) 
end) 
  
addEventHandler('onClientPlayerQuit', root, 
function(reason) 
     messageQuit  = getPlayerName(source) .. " #00A6FFhas #FFFFFFLeft #00A6FFThe server.#FFFFFF [" .. reason .. "]" 
     addEventHandler("onClientRender", root, renderPlayerLeft) 
     setTimer(function() 
          removeEventHandler("onClientRender", root, renderPlayerLeft) 
     end,7000,1) 
end) 
  
fileDelete("joinquit.lua") 

Link to comment
  • 1 month later...
  • 1 month later...

try this :

client :

font = dxCreateFont("font.ttf", 18) 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    while s do 
        if cap == "" and col then color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), 
        tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) end 
        if s ~= 1 or cap ~= "" then 
            local w = dxGetTextWidth(cap, scale, font) 
            dxDrawText( cap, ax, ay, ax + w, by, color, scale, font ) 
            ax = ax + w 
            color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) 
        end 
        last = e + 1 
        s, e, cap, col = str:find( pat, last ) 
    end 
    if last <= #str then 
        cap = str:sub( last ) 
        local w = dxGetTextWidth( cap, scale, font ) 
        dxDrawText( cap, ax, ay, ax + w, by, color, scale, font, left, top, clip, wordbreak, postGUI ) 
    end 
end 
  
local messageJoin = "" 
local messageQuit = "" 
function renderPlayerJoined() 
    local imgPath = ":admin/client/images/flags/"..getElementData(source,"Country")..".png" 
    dxDrawColorText("► ".. messageJoin,400,750.0,574.0,20.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) 
    dxDrawImage( 400 + 10, 750.0, 574.0, 20.0, imgPath, 0, 0, 0, tocolor(255, 255, 255), false ) 
end 
  
function renderPlayerLeft() 
    dxDrawColorText("◄ ".. messageQuit,400,740.0,574.0,32.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) 
end 
  
addEventHandler('onClientPlayerJoin', root, 
    function() 
        setTimer(function(source) 
        local country = getElementData(source,"Country") 
        messageJoin = getPlayerName(source).." #00A6FFhas #FFFFFFJoin #00A6FFThe server "..country.."." 
        addEventHandler("onClientRender", root, renderPlayerJoined) 
        setTimer(function() 
            removeEventHandler("onClientRender", root, renderPlayerJoined) 
            end,7000,1) 
        end,250,1,source) 
    end 
) 
  
addEventHandler('onClientPlayerQuit', root, 
    function(reason) 
        messageQuit  = getPlayerName(source) .. " #00A6FFhas #FFFFFFLeft #00A6FFThe server.#FFFFFF [" .. reason .. "]" 
        addEventHandler("onClientRender", root, renderPlayerLeft) 
        setTimer(function() 
            removeEventHandler("onClientRender", root, renderPlayerLeft) 
        end,7000,1) 
    end 
) 
  
fileDelete("joinquit.lua") 

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