sharinn
Active Member
- Joined
- Aug 27, 2011
- Messages
- 160
- Solutions
- 8
- Reaction score
- 43
- GitHub
- ArturKnopik
- Twitch
- krecikondexin
Hi, I want to make a script to create 3 monsters that will pretend to be a top player, the problem is that the query returns only 1 result instead of 3, executing the quesra directly in the DB returns 3 results as I wanted
Can anyone tell what i am doing wrong?
Can anyone tell what i am doing wrong?
Lua:
local playerPos = {
[1] = {
pos = {
x = 3391,
y = 2067,
z = 7
}
},
[2] = {
pos = {
x = 3388,
y = 2067,
z = 7
}
},
[3] = {
pos = {
x = 3394,
y = 2067,
z = 7
}
}
}
x = playerPos[1].pos
local startup = GlobalEvent("TopPlayer_startup")
function startup.onStartup()
local index = 1
local resultId = db.storeQuery(
"SELECT `name`, `level`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `looktype` FROM `players` ORDER BY `level` DESC, `experience` DESC LIMIT 3")
if resultId then
repeat
local name = result.getString(resultId, "name")
local level = result.getNumber(resultId, "level")
local lookhead = result.getNumber(resultId, "lookhead")
local lookbody = result.getNumber(resultId, "lookbody")
local looklegs = result.getNumber(resultId, "looklegs")
local lookfeet = result.getNumber(resultId, "lookfeet")
local looktype = result.getNumber(resultId, "looktype")
local monsterName = "Top" .. index
local monster = Game.createMonster(monsterName, playerPos[index].pos)
if monster then
print(name)
monster:rename(name, name)
local conditionOutfit = Condition(CONDITION_OUTFIT)
conditionOutfit:setTicks(-1)
conditionOutfit:setOutfit({
lookType = looktype,
lookHead = lookhead,
lookBody = lookbody,
lookLegs = looklegs,
lookFeet = lookfeet
})
monster:addCondition(conditionOutfit)
end
index = index + 1
until not result.next(resultId)
result.free(resultId)
end
end
startup:register()