i cannot get this simple script to work.. all i want to do is count how many rows have the killer's id and return me an integer
PHP:
function onKill(cid, target)
if (isPlayer(cid) == true) and (isPlayer(target) == true) and getPlayerStorageValue(cid,17100) ~= 1 then
local id = getPlayerGUID(cid)
local Info = db.getResult("SELECT `killer_id`,`killed_id` FROM `kill_log` WHERE `killer_id` = " .. id .. "")
local Info2 = db.getResult("SELECT COUNT(1) as \"counter\" FROM `kill_log` WHERE `killer_id` = " .. id .. "")
local counter = Info2:getDataInt("counters")
doPlayerSendTextMessage(cid,22, "count of ".. info2 .."")
if Info:getID() ~= LUA_ERROR then
local killer_id, killed_id = Info:getDataString("killer_id"), Info:getDataString("killed_id")
doPlayerSendTextMessage(cid,22, "gratz noob".. killer_id .."")
Info:free()
---
local count = {}
for i = 1, #killer_id do
table.insert(count, 1)
end
if #count > 0 then
doPlayerSendTextMessage(cid,22, "winnn ".. #count .."")
end
----
end
end
return TRUE
end