• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Problem with script/database

mahant

Banned User
Joined
May 15, 2010
Messages
111
Reaction score
1
Hey my problem is that:

SCRIPT:
Code:
local function getPlayerFrags(cid) 
    local time = os.time() 
    local times = {today = (time - 86400), week = (time - (7 * 86400))} 
  
    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC") 
    if(result:getID() ~= -1) then 
        repeat 
            local content = {date = result:getDataInt("date")} 
            if(content.date > times.today) then 
                table.insert(contents.day, content) 
            elseif(content.date > times.week) then 
                table.insert(contents.week, content) 
            else 
                table.insert(contents.month, content) 
            end 
        until not result:next() 
        result:free()

Error
[14:42:02.438] [Warning - Event::loadScript] Event onThink not found (data/globalevents/scripts/fraglicznik.lua)

Error
[14:52:26.965] mysql_real_query(): UPDATE `players` SET `frags` = `frags` + 1 WHERE `id` = 10; - MYSQL ERROR: Unknown column 'frags' in 'field list' (1054)



about Error 2
- I dont have "frags" at my database, i got player_killers and killers
 
Last edited:
oh, sry


Code:
local function getPlayerFrags(cid) 
    local time = os.time() 
    local times = {today = (time - 86400), week = (time - (7 * 86400))} 
  
    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC") 
    if(result:getID() ~= -1) then 
        repeat 
            local content = {date = result:getDataInt("date")} 
            if(content.date > times.today) then 
                table.insert(contents.day, content) 
            elseif(content.date > times.week) then 
                table.insert(contents.week, content) 
            else 
                table.insert(contents.month, content) 
            end 
        until not result:next() 
        result:free() 
    end 
  
    local size = { 
        day = table.maxn(contents.day), 
        week = table.maxn(contents.week), 
        month = table.maxn(contents.month) 
    } 
  
    return size.day + size.week + size.month 
end         
function onLook(cid, thing, position, lookDistance) 
if isPlayer(thing.uid) then 
doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .." has "..getPlayerFrags(thing.uid).." frags") 
return true 
end 
return true 
end
 
Try this:
Code:
local function getPlayerFrags(cid)
    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}
 
    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {date = result:getDataInt("date")}
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end
 
    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    }
 
    return size.day + size.week + size.month
end        
 function onLook(cid, thing, position, lookDistance)
	if isPlayer(thing.uid) then
		doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .." has "..getPlayerFrags(thing.uid).." frags")	
	end
	return true
end
 
First of all this should be located in creaturescript , not globalevent, and it type should be "look" , and regestire it in login.lua second
+ the script you shouwed works well, that frag sql error thing is in another script
 
Virrages, 0 errors at console but in game any char doesn't have anything like "He has xx frags".
@up
Ye, i use creaturescript, i had second script at globalevent too, and it was error of this second, now i deleted it.


So:
This script doesnt make any errors, but it dont have any effects
 
check the line you pasted in the creature.xml , memorize what is beside name =""
then go to login.lua and paste this line before last return true in script
Code:
registerCreatureEvent(cid, "xxxxx")
in xxxx write the name you memorized
 
Works, great butttt!!

It counts only frags, when i kill someone "illegal", how to do that it counts everykill of player? Cuz i need to use that at my pvp enfo!



@Edit
Doens't works ;o

[19:10:26.526] mysql_real_query(): UPDATE `players` SET `frags` = `frags` + 1 WHERE `id` = 8; - MYSQL ERROR: Unknown column 'frags' in 'field list' (1054)
 
As i said the script up doesnt include this query so this query is included in another script
so in whatever script is it in replace with this
Code:
db.executeQuery("UPDATE `killers` SET `unjustified` = `unjustified`+ 1 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
 
[14:52:26.965] mysql_real_query(): UPDATE `players` SET `frags` = `frags` + 1 WHERE `id` = 10; - MYSQL ERROR: Unknown column 'frags' in 'field list' (1054)


Ehh error is that i dont have column "frags", what other column it should be, player_killers or killers?
 
make a column called frags in players table :0 , but keep in mind you need to make a function so that these frags be move after a definit time.
 
Back
Top