Jump to content

Joinquit Country


MrXz

Recommended Posts

addEventHandler('onPlayerJoin',g_Root, 
function () 
    local country = exports['admin']:getPlayerCountry(source) 
    setElementData(source,'Country',country) 
    outputChatBox('[JOIN] #ffffff' .. getPlayerName(source) .. '#00FF09 Joined The Server From #FF8900[' .. tostring(country) .. '] ', getRootElement(), 2, 255, 2, true) 
    end 

As modified it to bring up the full name of the country?

Link to comment

Make an array like this:

  
countryNames = { 
    ["IT"]="Italy", 
    ["MX"]="Mexico", 
    ["SA"]="SAUDI ARBIA", 
    ["EG"]="EGYPT" 
} 
  

addEventHandler("onPlayerJoin", getRootElement(), 
function() 
    local country = exports['admin']:getPlayerCountry(source) 
    if country then 
        setElementData(source, "Country", country) 
        local thecountry = countryNames[country] 
        outputChatBox('[JOIN] #ffffff' .. getPlayerName(source) .. '#00FF09 Joined The Server From #FF8900[' .. tostring(thecountry) .. '] ', getRootElement(), 2, 255, 2, true) 
    end 
end) 

Link to comment
countryNames = { 
    ["IT"]="Italy", 
    ["MX"]="Mexico", 
    ["SA"]="SAUDI ARBIA", 
    ["EG"]="EGYPT" 
} 
addEventHandler('onPlayerJoin',g_Root, 
function () 
    local country = exports['admin']:getPlayerCountry(source) 
    setElementData(source,'Country',country) 
    outputChatBox('[JOIN] #ffffff' .. getPlayerName(source) .. '#00FF09 Joined The Server From #FF8900[' .. tostring(country) .. '] ', getRootElement(), 2, 255, 2, true) 
    end 

So the script would be?

Link to comment
countryNames = { 
    ["IT"]="Italy", 
    ["MX"]="Mexico", 
    ["SA"]="SAUDI ARBIA", 
    ["EG"]="EGYPT" 
} 
addEventHandler('onPlayerJoin',g_Root, 
function () 
    local country = exports['admin']:getPlayerCountry(source) 
    setElementData(source,'Country',country) 
    outputChatBox('[JOIN] #ffffff' .. getPlayerName(source) .. '#00FF09 Joined The Server From #FF8900[' .. countryNames[tostring(country)] .. '] ', getRootElement(), 2, 255, 2, true) 
    end 

Link to comment
countryNames = { 
    ["IT"]="Italy", 
    ["MX"]="Mexico", 
    ["SA"]="SAUDI ARBIA", 
    ["EG"]="EGYPT" 
} 
addEventHandler('onPlayerJoin',g_Root, 
function () 
    local country = exports['admin']:getPlayerCountry(source) 
flag=unpack(countryNames[country]) or country ----flag return the country full name from the tabel if he don't find a contry in the tabel then return the country from admin panel  
    setElementData(source,'Country',flag) 
    outputChatBox('[JOIN] #ffffff' .. getPlayerName(source) .. '#00FF09 Joined The Server From #FF8900[' .. countryNames[tostring(flag)] .. '] ', getRootElement(), 2, 255, 2, true) 
    end 

Link to comment
countryNames = { 
    ["IT"]="Italy", 
    ["MX"]="Mexico", 
    ["SA"]="SAUDI ARBIA", 
    ["EG"]="EGYPT" 
} 
addEventHandler('onPlayerJoin',g_Root, 
function () 
    local country = exports['admin']:getPlayerCountry(source) 
flag=unpack(countryNames[country]) or country ----flag return the country full name from the tabel if he don't find a contry in the tabel then return the country from admin panel  
    setElementData(source,'Country',flag) 
    outputChatBox('[JOIN] #ffffff' .. getPlayerName(source) .. '#00FF09 Joined The Server From #FF8900[' .. countryNames[tostring(flag)] .. '] ', getRootElement(), 2, 255, 2, true) 
    end 

Why would you use unpack?

Unpack will fail because countryNames[country] is not a table.

edit: also if flag becomes a full name then it fails @ outputChatBox

edit2: oh and setElementData is most likely used there to set the dxscoreboard's column.. So why would you set the column to the full name of the country? The initials will do just fine

  
    addEventHandler("onPlayerJoin", getRootElement(), 
    function() 
        local country = exports['admin']:getPlayerCountry(source) 
        if country then 
            setElementData(source, "Country", country) 
            local thecountry = countryNames[country] or country  --this is the only addition to FatalTerror's script. 
            outputChatBox('[JOIN] #ffffff' .. getPlayerName(source) .. '#00FF09 Joined The Server From #FF8900[' .. tostring(thecountry) .. '] ', getRootElement(), 2, 255, 2, true) 
        end 
    end) 

@TopicStarter you should use FatalTerror's script with that single line I edited. Check it above in my post :')

Link to comment

The script I posted.

Because I copied FatalTerror's script which works fine, but I changed 1 line which makes it even better.

By better I mean that it will return still return 'US' in the chatbox in case you didn't modify the database of country names to add US as United States

PS: You do understand that the script requires an enormous database, don't you?

You will have to add the countries manually

Link to comment
    addEventHandler("onPlayerJoin", getRootElement(), 
    function() 
        local country = exports['admin']:getPlayerCountry(source) 
        if country then 
            setElementData(source, "Country", country) 
            local thecountry = countryNames[country] or country 
            outputChatBox('[JOIN] #ffffff' .. getPlayerName(source) .. '#00FF09 Joined The Server From #FF8900[' .. tostring(thecountry) .. '] ', getRootElement(), 2, 255, 2, true) 
        end 
    end) 

This Script?

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