Jump to content

مساعده في كود


Tarek1

Recommended Posts

8 hours ago, Tarek1 said:

--Error attempt to concatenate global 'ctr' ( a bollean value )


outputChatBox("("..ctr..") "..string.gsub(getPlayerName(thePlayer), "#%x%x%x%x%x%x", "")..": #FFFFFF"..table.concat({...}, " "), v, r, g, b, true)

 

true or false او قيمته تساوي ctr مو معرف

تاكد من الكود كويس او اطرح الكود عشان نقدر نساعدك

Link to comment
7 hours ago, #SycroX said:

true or false او قيمته تساوي ctr مو معرف

تاكد من الكود كويس او اطرح الكود عشان نقدر نساعدك

addCommandHandler("LangChat", function (thePlayer, cn, ...)
    if isPlayerMuted(thePlayer) or isGuestAccount(getPlayerAccount(thePlayer)) then return end
    if isTimer(spam[thePlayer]) then exports.URGMessages: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))
    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
            outputChatBox("("..ctr..") "..string.gsub(getPlayerName(thePlayer), "#%x%x%x%x%x%x", "")..": #FFFFFF"..table.concat({...}, " "), v, r, g, b, true)
        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 = {
    ["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://162.250.144.215/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)
end
end
 

7 hours ago, #SycroX said:

true or false او قيمته تساوي ctr مو معرف

تاكد من الكود كويس او اطرح الكود عشان نقدر نساعدك

addCommandHandler("LangChat", function (thePlayer, cn, ...)
	if isPlayerMuted(thePlayer) or isGuestAccount(getPlayerAccount(thePlayer)) then return end
	if isTimer(spam[thePlayer]) then exports.URGMessages: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))
	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
			outputChatBox("("..ctr..") "..string.gsub(getPlayerName(thePlayer), "#%x%x%x%x%x%x", "")..": #FFFFFF"..table.concat({...}, " "), v, r, g, b, true)
		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 = {
	["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://162.250.144.215/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)
end
end

 

Link to comment
16 hours ago, Tarek1 said:

al error   

line 15   (True)

addCommandHandler("LangChat",
	function(player,_, ...)
		if not isGuestAccount(getPlayerAccount(player)) then
			if not isPlayerMuted(player) then
				if not isTimer(spam[player]) then
					local ctr
					if plang[getElementData(player, "Country")] then
						ctr = plang[getElementData(player, "Country")]
						isclg = true
					else
						ctr = getElementData(player, "Country")
						isclg = false
					end
					local r, g, b = getTeamColor(getPlayerTeam(player))
					spam[player] = setTimer(function() end, 1000, 1) 
					for _,v in ipairs(getElementsByType("player")) do
						if ifnot(isclg, plang[getElementData(v, "Country")], getElementData(v, "Country")) == ctr then
							outputChatBox("("..ctr..") "..string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")..": #FFFFFF"..table.concat({...}, " "), v, r, g, b, true)
						end
					end
					outputServerLog("LANGCHAT: ("..ctr..") "..getPlayerName(player)..": "..table.concat({...}, " "))
					logThis("Lang Chat", "("..ctr..") "..getPlayerName(player)..": "..table.concat({...}, " "))
				else
					exports.URGMessages:sendClientMessage("Anti-spam: please refrain from spamming the chats!",player, 255, 0, 0)
				end
			else
				exports.URGMessages:sendClientMessage("you'r muted!",player, 255, 0, 0)
			end
		else
			exports.URGMessages:sendClientMessage("please log in first",player, 255, 0, 0)
		end
	end
)

 

Link to comment
4 hours ago, #SycroX said:

addCommandHandler("LangChat",
	function(player,_, ...)
		if not isGuestAccount(getPlayerAccount(player)) then
			if not isPlayerMuted(player) then
				if not isTimer(spam[player]) then
					local ctr
					if plang[getElementData(player, "Country")] then
						ctr = plang[getElementData(player, "Country")]
						isclg = true
					else
						ctr = getElementData(player, "Country")
						isclg = false
					end
					local r, g, b = getTeamColor(getPlayerTeam(player))
					spam[player] = setTimer(function() end, 1000, 1) 
					for _,v in ipairs(getElementsByType("player")) do
						if ifnot(isclg, plang[getElementData(v, "Country")], getElementData(v, "Country")) == ctr then
							outputChatBox("("..ctr..") "..string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")..": #FFFFFF"..table.concat({...}, " "), v, r, g, b, true)
						end
					end
					outputServerLog("LANGCHAT: ("..ctr..") "..getPlayerName(player)..": "..table.concat({...}, " "))
					logThis("Lang Chat", "("..ctr..") "..getPlayerName(player)..": "..table.concat({...}, " "))
				else
					exports.URGMessages:sendClientMessage("Anti-spam: please refrain from spamming the chats!",player, 255, 0, 0)
				end
			else
				exports.URGMessages:sendClientMessage("you'r muted!",player, 255, 0, 0)
			end
		else
			exports.URGMessages:sendClientMessage("please log in first",player, 255, 0, 0)
		end
	end
)

 

Error : Line 7:attempt to index global 'plang' ( anil value)

Link to comment
Just now, Tarek1 said:

al sevrer side  ملهوش لازمه Binds bs 

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

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

addCommandHandler("LangChat",
	function(player,_, ...)
		if not isGuestAccount(getPlayerAccount(player)) then
			if not isPlayerMuted(player) then
				if not isTimer(spam[player]) then
					local ctr
					local country = getElementData(player, "Country")
					if plang[country] then
						ctr = plang[country]
						isclg = true
					else
						ctr = country
						isclg = false
					end
					local r, g, b = getTeamColor(getPlayerTeam(player))
					spam[player] = setTimer(function() end, 1000, 1) 
					for _,v in ipairs(getElementsByType("player")) do
						if ifnot(isclg, plang[getElementData(v, "Country")], getElementData(v, "Country")) == ctr then
							outputChatBox("("..ctr..") "..string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")..": #FFFFFF"..table.concat({...}, " "), v, r, g, b, true)
						end
					end
					outputServerLog("LANGCHAT: ("..ctr..") "..getPlayerName(player)..": "..table.concat({...}, " "))
					logThis("Lang Chat", "("..ctr..") "..getPlayerName(player)..": "..table.concat({...}, " "))
				else
					exports.URGMessages:sendClientMessage("Anti-spam: please refrain from spamming the chats!",player, 255, 0, 0)
				end
			else
				exports.URGMessages:sendClientMessage("you'r muted!",player, 255, 0, 0)
			end
		else
			exports.URGMessages:sendClientMessage("please log in first",player, 255, 0, 0)
		end
	end
)

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

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

جرب

Link to comment
23 hours ago, #SycroX said:

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

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

addCommandHandler("LangChat",
	function(player,_, ...)
		if not isGuestAccount(getPlayerAccount(player)) then
			if not isPlayerMuted(player) then
				if not isTimer(spam[player]) then
					local ctr
					local country = getElementData(player, "Country")
					if plang[country] then
						ctr = plang[country]
						isclg = true
					else
						ctr = country
						isclg = false
					end
					local r, g, b = getTeamColor(getPlayerTeam(player))
					spam[player] = setTimer(function() end, 1000, 1) 
					for _,v in ipairs(getElementsByType("player")) do
						if ifnot(isclg, plang[getElementData(v, "Country")], getElementData(v, "Country")) == ctr then
							outputChatBox("("..ctr..") "..string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")..": #FFFFFF"..table.concat({...}, " "), v, r, g, b, true)
						end
					end
					outputServerLog("LANGCHAT: ("..ctr..") "..getPlayerName(player)..": "..table.concat({...}, " "))
					logThis("Lang Chat", "("..ctr..") "..getPlayerName(player)..": "..table.concat({...}, " "))
				else
					exports.URGMessages:sendClientMessage("Anti-spam: please refrain from spamming the chats!",player, 255, 0, 0)
				end
			else
				exports.URGMessages:sendClientMessage("you'r muted!",player, 255, 0, 0)
			end
		else
			exports.URGMessages:sendClientMessage("please log in first",player, 255, 0, 0)
		end
	end
)

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

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

جرب

نفس المشكله 

المشكله هنا  :outputChatBox("("..ctr..") "..string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")..": #FFFFFF"..table.concat({...}, " "), v, r, g, b, true)

Edited by Tarek1
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...