MrXz Posted January 7, 2012 Share Posted January 7, 2012 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
FatalTerror Posted January 7, 2012 Share Posted January 7, 2012 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
MrXz Posted January 7, 2012 Author Share Posted January 7, 2012 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
12p Posted January 7, 2012 Share Posted January 7, 2012 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
bandi94 Posted January 7, 2012 Share Posted January 7, 2012 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
BinSlayer1 Posted January 7, 2012 Share Posted January 7, 2012 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
bandi94 Posted January 7, 2012 Share Posted January 7, 2012 oh my foult whit unpack i don't noticed that are not tabel in my country is and bk that i write unpack Link to comment
MrXz Posted January 7, 2012 Author Share Posted January 7, 2012 At the end what would be the correct script, because I'm confused e_e! Link to comment
BinSlayer1 Posted January 7, 2012 Share Posted January 7, 2012 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
MrXz Posted January 7, 2012 Author Share Posted January 7, 2012 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
BinSlayer1 Posted January 7, 2012 Share Posted January 7, 2012 Yes Remember to add the database! Link to comment
12p Posted January 7, 2012 Share Posted January 7, 2012 NOTE: He means batabase by this countryNames = { ["IT"]="Italy", ["MX"]="Mexico", ["SA"]="SAUDI ARBIA", ["EG"]="EGYPT" } Remember to declare the database before anything else in your code. Link to comment
MrXz Posted January 7, 2012 Author Share Posted January 7, 2012 Thanks !! I'll be trying script Thanks for the support ^^! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now