Jump to content

what's worng


Ayee

Recommended Posts

its LangChat Script idk why its wont work and its not giving errors at debugscript 

Could anyone help me

 

addCommandHandler("LangChat", function (thePlayer, cn, ...)
	if isPlayerMuted(thePlayer) or isGuestAccount(getPlayerAccount(thePlayer)) then return end
	if isTimer(spam[thePlayer]) then exports.GTCMessages:sendClientMessage("Anti-spam: please refrain from spamming the chats!",thePlayer, 255, 0, 0) return end
	if plang[getElementData(thePlayer, "Country")] then
		ctr = plang[getElementData(thePlayer, "Country")]
		isclg = true
	else
		ctr = getElementData(thePlayer, "Country")
		isclg = false
	end
	r, g, b = getTeamColor(getPlayerTeam(thePlayer))
	if getTeamName(getPlayerTeam(thePlayer)) == "Government" and getElementData(thePlayer,"Clan") == "SWAT" then 
	r, g, b = 12, 2, 219
	end
	if getTeamName(getPlayerTeam(thePlayer)) == "Government" and getElementData(thePlayer,"Clan") == "Military" then 
	r, g, b = 21, 97, 8
	end
	spam[thePlayer] = setTimer(function () end, 1000, 1) 
	for k, v in ipairs(getElementsByType("player")) do --- getElementData(v, "nonEnglishChat"))
		if(ifnot(isclg, plang[getElementData(v, "Country")], getElementData(v, "Country")) == ctr ) then
		if getElementData(v,"nonEnglishChat") then 
                        
			outputChatBox("("..ctr..") "..string.gsub(getPlayerName(thePlayer), "#%x%x%x%x%x%x", "")..": #FFFFFF"..table.concat({...}, " "), v, r, g, b, true)
			end
		end
	end
	outputServerLog("LANGCHAT: ("..ctr..") "..getPlayerName(thePlayer)..": "..table.concat({...}, " "))
	logThis("Lang Chat", "("..ctr..") "..getPlayerName(thePlayer)..": "..table.concat({...}, " "))
end)

function ifnot(a, b, c)
	if a then return b else return c end
end

plang = {
	--- Arabic End
	["Portugal"] = "Portuguese",
	["Brazil"] = "Portuguese",
	["Slovenia"] = "Ex-Yu",
	["Serbia"] = "Ex-Yu",
	["Croatia"] = "Ex-Yu",
	["Macedonia"] = "Ex-Yu",
}


addEventHandler("onPlayerJoin", getRootElement(), function ()
	bindKey(source, "5", "down", "chatbox", "LangChat")
	dap = source
	fetchRemote("http://134.119.223.179/json/"..getPlayerIP(dap), countryCheck, "", false, dap)
end)

function countryCheck(resp, erno, dap)
if resp ~= "ERROR" then
	if(fromJSON(resp)["query"] == "127.0.0.1") then pip = "Portugal" else pip = fromJSON(resp)["country"] end
	setElementData(dap, "Country", pip)
        
	setElementData(dap, "CC", string.lower(fromJSON(resp)["countryCode"] or "zz"))
	if fileExists(":admin/client/images/flags/"..getElementData(dap, "CC")..".png") then
		path = ":admin/client/images/flags/"..getElementData(dap, "CC")..".png"
	else
		path = ":admin/client/images/flags/zz.png"
	end
	setElementData(dap,"Pic",path)
if getAccountName(getPlayerAccount(dap)) == "Maxman" then setElementData(dap, "Country", "Brazil") end
end
end

 

Link to comment
  • 2 years later...

@Ayee

plang = {
	--- Arabic End
	["Portugal"] = "Portuguese",
	["Brazil"] = "Portuguese",
	["Slovenia"] = "Ex-Yu",
	["Serbia"] = "Ex-Yu",
	["Croatia"] = "Ex-Yu",
	["Macedonia"] = "Ex-Yu",
}

Check Flags name from ur scoreboard

like

plang = {
	--- Arabic End
	["PT"] = "Portuguese",
	["BR"] = "Portuguese",

}

 

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