Jump to content

Recommended Posts

Posted

Вообщем, у меня все работает, НО, когда задаю элементу ключ, и потом использую getElementData выходит ошибка в консоле "attemp to compare number with string", и соответственно скрипт не работает. Вот скрипт которым я задаю ключ:

function giveadm (source, command, ident, lvl)
   if(getElementData(source,"admlvl") > 8) then
   if (ident) then
    for id, player in ipairs ( getElementsByType ( "player" ) ) do
		if ( tonumber(getElementData ( player, "ID" )) ==  tonumber(ident) ) then
		local thePlayer = getAccountName (getPlayerAccount(player))
   if lvl then
   if((tonumber(lvl) > -1) and (tonumber(lvl) < 11))then
    local RootNode = xmlLoadFile ( "Accounts/"..thePlayer..".xml" )
	local playeradmlvl = xmlFindChild ( RootNode, "admlvl", 0 )
	local valueadmlvl = xmlNodeSetValue ( playeradmlvl, lvl.."" )
	local serial = xmlNodeGetValue ( xmlFindChild (RootNode, "serial", 0) )
	
	xmlSaveFile(RootNode)
	xmlUnloadFile(RootNode)
	outputChatBox("* Вы выдали "..lvl.." уровень администратирования игроку "..thePlayer..".", source, 255, 215, 0, true)
	setElementData ( player, "admlvl", lvl )
	else
    outputChatBox("* неверный уровень администратирования", source, 255, 215, 0, true)
	end
   else
    outputChatBox("* /makeadmin [id] [0-10]", source, 255, 215, 0, true)
   end
end
end
else
outputChatBox ("* /makeadmin [id] [0-10]", source, 255, 215, 0, true)
end
else
outputChatBox ("* У Вас нет доступа.", source, 255, 215, 0, true)
end
end
addCommandHandler ("makeadmin", giveadm)

Дальше, если я буду использовать скрипты, у меня будет ошибка в строчке: " if(getElementData(source,"admlvl") > 8 then ".

Заранее спасибо!

Posted
45 minutes ago, K1parik said:

тут скобка лишняя

Не, нормально все в самом скрипте, просто не дописал скобку внизу

  • Moderators
Posted

"attemp to compare number with string"

попытка сравнить число со строкой, приведи оба значения либо к числам, либо к строкам через функции tonumber, tostring.

  • Like 1

Developers, Developers, Developers, Developers.... © Steve Balmer

http://www.lua.org/about.html

Quote
Please do not write it as "LUA", which is both ugly and confusing, because then it becomes an acronym with different meanings for different people. So, please, write "Lua" right!
Posted
17 hours ago, Disinterpreter said:

"attemp to compare number with string"

попытка сравнить число со строкой, приведи оба значения либо к числам, либо к строкам через функции tonumber, tostring.

Благодарю за помощь. :)

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