Natan Beckman
Well-Known Member
I use TFS 1.0.
when execute command !guildpoints
show this error:
help
when execute command !guildpoints
show this error:
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/guildpoints.lua:onSay
data/talkactions/scripts/guildpoints.lua:75: attempt to index global 'Query' (a number value)
stack traceback:
[C]: in function '__index'
data/talkactions/scripts/guildpoints.lua:75: in function <data/talkactions/scripts/guildpoints.lua:71>
Code:
GuildPointsConfigs={
ExecuteIntervalHours=24,
NeedPlayersOnline=7,
NeedDiferentIps=5,
MinLevel=70,
AddPointsForAcc=19}
function getGuildPlayersValidAccIDS(GuildID,MinLevel)
localRanksIDS={}
localAccsID={}
localValidAccsID={}
Query1= db.storeQuery("SELECT `id` FROM `guild_ranks` WHERE guild_id = '"..GuildID.."'")
if(Query1:getID()==-1)then
returnValidAccsID
end
for i =1,Query1:getRows()do
table.insert(RanksIDS,Query1:getDataInt("id"))
Query1:next()
end
Query2= db.storeQuery("SELECT `account_id` FROM `players` WHERE `rank_id` IN (".. table.concat(RanksIDS,', ')..") AND `level` >= "..MinLevel.."")
if(Query2:getID()==-1)then
returnValidAccsID
end
for i =1,Query2:getRows()do
localAccID=Query2:getDataInt("account_id")
if#AccsID > 0 then
for k =1,#AccsID do
ifAccID==AccsID[k]then
AddAccList=false
break
end
AddAccList=true
end
ifAddAccListthen
table.insert(AccsID,AccID)
end
else
table.insert(AccsID,AccID)
end
Query2:next()
end
Query3= db.storeQuery("SELECT `id` FROM `accounts` WHERE `guild_points_stats` = 0 AND `id` IN (".. table.concat(AccsID,', ')..")")
if(Query3:getID()==-1)then
returnValidAccsID
end
for i =1,Query3:getRows()do
localAccID=Query3:getDataInt("id")
if#ValidAccsID > 0 then
for k =1,#ValidAccsID do
ifAccID==ValidAccsID[k]then
AddAccList=false
break
end
AddAccList=true
end
ifAddAccListthen
table.insert(ValidAccsID,AccID)
end
else
table.insert(ValidAccsID,AccID)
end
Query3:next()
end
returnValidAccsIDend
function onSay(cid, words, param, channel)
if(getPlayerGuildLevel(cid)==3)then
localGuildID= getPlayerGuildId(cid)
Query= db.storeQuery("SELECT `last_execute_points` FROM `guilds` WHERE id = '"..GuildID.."'")
if(Query:getID()==-1)then
returntrue
end
ifQuery:getDataInt("last_execute_points")< os.time()then
localGuildMembers={}
localGuildMembersOnline={}
localPlayersOnline= getPlayersOnline()
for i, pid in ipairs(PlayersOnline)do
if getPlayerGuildId(pid)==GuildIDthen
if getPlayerLevel(pid)>=GuildPointsConfigs.MinLevelthen
table.insert(GuildMembersOnline, pid)
end
end
end
if#GuildMembersOnline >= GuildPointsConfigs.NeedPlayersOnline then
local IPS ={}
for i, pid in ipairs(GuildMembersOnline)do
localPlayerIP= getPlayerIp(pid)
if#IPS > 0 then
for k =1,#IPS do
ifPlayerIP== IPS[k]then
AddIPList=false
break
end
AddIPList=true
end
ifAddIPListthen
table.insert(IPS,PlayerIP)
end
else
table.insert(IPS,PlayerIP)
end
end
if#IPS >= GuildPointsConfigs.NeedDiferentIps then
localValidAccounts= getGuildPlayersValidAccIDS(GuildID,GuildPointsConfigs.MinLevel)
db.executeQuery("UPDATE `guilds` SET `last_execute_points` = ".. os.time()+(GuildPointsConfigs.ExecuteIntervalHours*3600).." WHERE `guilds`.`id` = "..GuildID..";")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..#ValidAccounts .." Players received points")
if#ValidAccounts > 0 then
db.executeQuery("UPDATE `accounts` SET `guild_points` = `guild_points` + "..GuildPointsConfigs.AddPointsForAcc..", `guild_points_stats` = ".. os.time().." WHERE `id` IN (".. table.concat(ValidAccounts,',')..");")
for i, pid in ipairs(GuildMembersOnline)do
localPlayerMSGAccID= getPlayerAccountId(pid)
for k =1,#ValidAccounts do
ifPlayerMSGAccID==ValidAccounts[k]then
doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR,"You received "..GuildPointsConfigs.AddPointsForAcc.." guild points.")
break
end
end
end
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Only "..#IPS .." players are valid, you need ".. GuildPointsConfigs.NeedDiferentIps .." players with different ips.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Has only "..#GuildMembersOnline .." players online you need ".. GuildPointsConfigs.NeedPlayersOnline .." players online at least from level "..GuildPointsConfigs.MinLevel ..".")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"The command can only be run once every "..GuildPointsConfigs.ExecuteIntervalHours.." hours.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Only guild leader can request points.")
end
return true
end
help