我正在尝试通过使用 Lua 连接一个函数,因为它实际上是一个玩家姓名的变量。游戏再次成为命令与征服:叛徒。
错误是:Attempt to concatenate local 'Value' (a function value)
这是通过使用 Get_Player_Name_By_ID 发生的,但是,我不知道使用它的任何方法,因为我需要能够确定哪个用户有哪些杀手!此外,它出现在第 210 行附近。那是在 WriteINI 函数中。
这是我的代码:
function OnChat(pID, Type, Message, Target)
FindWords(Message)
if Message == "!killstreaks" then
InputConsole("pamsg %d Killstreaks are a fundamental part of our server. You choose 3 killstreaks to be enabled for use, when you achieve a certain number of kills. Now type !select <Assault/Support>", pID)
end
if FirstW == "!select" or FirstW == "!choose" then
if SecondW == "Assault" or SecondW == "assault" then
InputConsole("pamsg %d Attack Chopper Strafe Run AH-6 Overwatch Reaper Assault Drone AC130 Pavelow Juggernaut Oseprey Gunner", pID)
InputConsole("pamsg %d UAV Care Package IMS Predator Missile Sentry Gun Precision Airstrike", pID)
InputConsole("pamsg %d Now type !ks1 <killstreak>, then !ks2 <killstreak>, then !ks3 <killstreak> with 3 of these killstreaks:", pID)
WriteINI("killstreaks.ini", "Choice", "Assault", Get_Player_Name_By_ID)
elseif SecondW == "Support" or SecondW == "support" then
InputConsole("pamsg %d EMP Juggernaut Recon Escort Airdrop", pID)
InputConsole("pamsg %d UAV Counter UAV Ballistic Vests Airdrop Trap SAM Turret Recon Drone Advanced UAV Remote Turret Stealth Bomber", pID)
InputConsole("pamsg %d Now type !ks1 <killstreak>, then !ks2 <killstreak>, then !ks3 <killstreak> with 3 of these killstreaks:", pID)
WriteINI("killstreaks.ini", "Choice", "Support", Get_Player_Name_By_ID)
end
end
return 1
end
function ReadINI(File, Section, KeyName)
blnSection = false
intAction = 0
strBracket = [[[]]
if File ~= nil and Section ~= nil and KeyName ~= nil then
if File ~= "" and Section ~= "" and KeyName ~= "" then
i = io.open(File, "r")
if i ~= nil then
while true do
local Line = i:read() -- Reads a line
if Line == nil or intAction ~= 0 then
break
else
if blnSection == false then
Found = string.sub(Line, 0, 1)
if Found == strBracket then -- Found Header
Header = string.sub(Line, 2, -2)
if Header == Section then
blnSection = true
end
end
else
Header = string.sub(Line, 0, 1)
if Header == strBracket then
intAction = 2
elseif Header == ";" then
-- Ignor Comments
elseif Line == "" then
-- Ignor Blank Lines
else
strFindEqual = string.find(Line, "=")
if strFindEqual ~= nil then
strKeyname = string.sub(Line, 0, strFindEqual - 1)
if strKeyname == KeyName then
intAction = 1
Value = string.sub(Line, strFindEqual + 1)
end
end
end
end
end
end
i:close()
if intAction == 1 then
return Value
elseif intAction == 2 then
return NoneError
else
return NoneError
end
else
return FileError
end
else
return ArgError
end
else
return ArgError
end
end
function WriteINI(File, Section, KeyName, Value)
blnSection = false
intAction = 0
strBracket = [[[]]
strCloseBracket = [[].]]
strCloseBracket = string.sub(strCloseBracket, 1, 1)
Save = ""
if File ~= nil and Section ~= nil and KeyName ~= nil and Value ~= nil then
if File ~= "" and Section ~= "" and KeyName ~= "" and Value ~= "" then
i = io.open(File, "r")
if i ~= nil then
while true do
local Line = i:read() -- Reads a line
if Line == nil then
break
else
if intAction == 0 then
if blnSection == false then
Found = string.sub(Line, 0, 1)
if Found == strBracket then -- Found Header
Header = string.sub(Line, 2, -2)
if Header == Section then
blnSection = true
end
end
else
Header = string.sub(Line, 0, 1)
if Header == strBracket then
blnSection = false
Line = KeyName .. "=" .. Value .. "\n" .. Line
intAction = 1
elseif Header == ";" then
-- Ignor Comments
elseif Line == "" then
-- Ignor Blank Lines
else
strFindEqual = string.find(Line, "=")
if strFindEqual ~= nil then
strKeyname = string.sub(Line, 0, strFindEqual - 1)
if strKeyname == KeyName then
Line = KeyName .. "=" .. Value
intAction = 1
end
end
end
end
end
Save = Save .. Line .. "\n"
end
end
i:close()
if intAction ~= 1 then
if blnSection == false then
Save = Save .. strBracket .. Section .. strCloseBracket .. "\n" .. KeyName .. "=" .. Value
else
Save = Save .. KeyName .. "=" .. Value
end
end
i = io.open(File, "w")
i:write(Save)
i:close()
else
i = io.open(File, "w")
i:write(strBracket .. Section .. strCloseBracket .. "\n" .. KeyName .. "=" .. Value)
i:close()
end
else
return ArgError
end
else
return ArgError
end
end
function FindWords(Text)
Found = string.find(Text, " ")
if Found ~= nil then
FirstW = string.sub(Text, 0, Found - 1)
SecondW = string.sub(Text, Found + 1)
SecondPlus = SecondW
Found = string.find(SecondW, " ")
if Found ~= nil then
ThirdW = string.sub(SecondW, Found + 1)
SecondW = string.sub(SecondW, 0, Found - 1)
ThirdPlus = ThirdW
Found = string.find(ThirdW, " ")
if Found ~= nil then
FourthW = string.sub(ThirdW, Found + 1)
ThirdW = string.sub(ThirdW, 0, Found - 1)
Found = string.find(FourthW, " ")
if Found ~= nil then
FourthW = string.sub(FourthW, 0, Found - 1)
end
else
FourthW = ""
end
else
ThirdW = ""
ThirdPlus = ""
FourthW = ""
end
else
FirstW = Text
SecondW = ""
SecondPlus = ""
ThirdW = ""
ThirdPlus = ""
FourthW = ""
end
end