• 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!

Lua !frags talkaction

Luka Trklja

Member
Joined
Jul 8, 2016
Messages
121
Solutions
5
Reaction score
8
Location
Croatia
Couldn't find anywhere how to fix it... When i say !frags nothing happens.

Using TF 0.3.6

Code:
[07/03/2017 00:42:58] [Error - TalkAction Interface]
[07/03/2017 00:42:58] data/talkactions/scripts/frags.lua:onSay
[07/03/2017 00:42:58] Description:
[07/03/2017 00:42:58] data/talkactions/scripts/frags.lua:14: attempt to call field 'getResult' (a nil value)
[07/03/2017 00:42:58] stack traceback:
[07/03/2017 00:42:58]     data/talkactions/scripts/frags.lua:14: in function <data/talkactions/scripts/frags.lua:6>

This is my current code:

Lua:
local config = {
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler')),
    advancedFragList = getBooleanFromString(getConfigValue('advancedFragList'))
}

function onSay(cid, words, param, channel)
    if(not config.useFragHandler) then
        return false
    end

    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 = {
                name = result:getDataString("name"),
                level = result:getDataInt("level"),
                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)
    }
    if(config.advancedFragList) then
        local result = "Frags gained today: " .. size.day .. "."
        if(size.day > 0) then
            for _, content in ipairs(contents.day) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        result = result .. "\nFrags gained this week: " .. (size.day + size.week) .. "."
        if(size.week > 0) then
            for _, content in ipairs(contents.week) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        result = result .. "\nFrags gained this month: " .. (size.day + size.week + size.month) .. "."
        if(size.month > 0) then
            for _, content in ipairs(contents.month) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        local skullEnd = getPlayerSkullEnd(cid)
        if(skullEnd > 0) then
            result = result .. "\nYour " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd)
        end

        doPlayerPopupFYI(cid, result)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You currently have " .. size.day .. " frags today, " .. (size.day + size.week) .. " this week and " .. (size.day + size.week + size.month) .. " this month.")
        if(size.day > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Last frag at " .. os.date("%d %B %Y %X", contents.day[1].date) .. " on level " .. contents.day[1].level .. " (" .. contents.day[1].name .. ").")
        end

        local skullEnd = getPlayerSkullEnd(cid)
        if(skullEnd > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd))
        end
    end

    return true
end
 
Last edited:
try removing:
Code:
local config = {
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler')),
    advancedFragList = getBooleanFromString(getConfigValue('advancedFragList'))
}

edit this part:
Code:
if(not config.useFragHandler) then
with:
Code:
    if(not checkExhausted(cid, 666, 10)) then
        return false
    end
    if(not getBooleanFromString(getConfigValue('useFragHandler'))) then

edit this:
Code:
    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")
with:
Code:
    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 `k`.`war` = 0 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
and this:
Code:
if(config.advancedFragList) then
with this:
Code:
if(getBooleanFromString(getConfigValue('advancedFragList'))) then
 
try removing:
Code:
local config = {
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler')),
    advancedFragList = getBooleanFromString(getConfigValue('advancedFragList'))
}

edit this part:
Code:
if(not config.useFragHandler) then
with:
Code:
    if(not checkExhausted(cid, 666, 10)) then
        return false
    end
    if(not getBooleanFromString(getConfigValue('useFragHandler'))) then

edit this:
Code:
    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")
with:
Code:
    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 `k`.`war` = 0 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
and this:
Code:
if(config.advancedFragList) then
with this:
Code:
if(getBooleanFromString(getConfigValue('advancedFragList'))) then


Will try later when I come home, thanks.
 
Just tested, still doesnt work :(

I get this error

Code:
[27/02/2017 15:33:38] [Error - TalkAction Interface] 
[27/02/2017 15:33:38] data/talkactions/scripts/frags.lua:onSay
[27/02/2017 15:33:38] Description: 
[27/02/2017 15:33:38] data/talkactions/scripts/frags.lua:3: attempt to call global 'checkExhausted' (a nil value)
[27/02/2017 15:33:38] stack traceback:
[27/02/2017 15:33:38]     data/talkactions/scripts/frags.lua:3: in function <data/talkactions/scripts/frags.lua:2>
 
Have you added all like I said?

Code:
function onSay(cid, words, param, channel)
	if(not checkExhausted(cid, 666, 10)) then
		return false
	end

	if(not getBooleanFromString(getConfigValue('useFragHandler'))) then
		return false
	end

	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 `k`.`war` = 0 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
	if(result:getID() ~= -1) then
		repeat
			local content = {
				name = result:getDataString("name"),
				level = result:getDataInt("level"),
				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)
	}

	if(getBooleanFromString(getConfigValue('advancedFragList'))) then
		local result = "Frags gained today: " .. size.day .. "."
		if(size.day > 0) then
			for _, content in ipairs(contents.day) do
				result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
			end

			result = result .. "\n"
		end

		result = result .. "\nFrags gained this week: " .. (size.day + size.week) .. "."
		if(size.week > 0) then
			for _, content in ipairs(contents.week) do
				result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
			end

			result = result .. "\n"
		end

		result = result .. "\nFrags gained this month: " .. (size.day + size.week + size.month) .. "."
		if(size.month > 0) then
			for _, content in ipairs(contents.month) do
				result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
			end

			result = result .. "\n"
		end

		local skullEnd = getPlayerSkullEnd(cid)
		if(skullEnd > 0) then
			result = result .. "\nYour " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd)
		end

		doPlayerPopupFYI(cid, result)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You currently have " .. size.day .. " frags today, " .. (size.day + size.week) .. " this week and " .. (size.day + size.week + size.month) .. " this month.")
		if(size.day > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Last frag at " .. os.date("%d %B %Y %X", contents.day[1].date) .. " on level " .. contents.day[1].level .. " (" .. contents.day[1].name .. ").")
		end

		local skullEnd = getPlayerSkullEnd(cid)
		if(skullEnd > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd))
		end
	end

	return true
end
 
Code:
[27/02/2017 15:58:24] [Error - TalkAction Interface] 
[27/02/2017 15:58:24] data/talkactions/scripts/frags.lua:onSay
[27/02/2017 15:58:24] Description: 
[27/02/2017 15:58:24] data/talkactions/scripts/frags.lua:2: attempt to call global 'checkExhausted' (a nil value)
[27/02/2017 15:58:24] stack traceback:
[27/02/2017 15:58:24]     data/talkactions/scripts/frags.lua:2: in function <data/talkactions/scripts/frags.lua:1>

Maybe i need to add something in my db? Dunno, im not an expert.
 
data/talkactions/scripts create new file and call it "frags" and add following code
Code:
local config = {
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler')),
    advancedFragList = getBooleanFromString(getConfigValue('advancedFragList'))
}

function onSay(cid, words, param, channel)
    if(not config.useFragHandler) then
        return false
    end

    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 = {
                name = result:getDataString("name"),
                level = result:getDataInt("level"),
                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)
    }
    if(config.advancedFragList) then
        local result = "Frags gained today: " .. size.day .. "."
        if(size.day > 0) then
            for _, content in ipairs(contents.day) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        result = result .. "\nFrags gained this week: " .. (size.day + size.week) .. "."
        if(size.week > 0) then
            for _, content in ipairs(contents.week) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        result = result .. "\nFrags gained this month: " .. (size.day + size.week + size.month) .. "."
        if(size.month > 0) then
            for _, content in ipairs(contents.month) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        local skullEnd = getPlayerSkullEnd(cid)
        if(skullEnd > 0) then
            result = result .. "\nYour " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd)
        end

        doPlayerPopupFYI(cid, result)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You currently have " .. size.day .. " frags today, " .. (size.day + size.week) .. " this week and " .. (size.day + size.week + size.month) .. " this month.")
        if(size.day > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Last frag at " .. os.date("%d %B %Y %X", contents.day[1].date) .. " on level " .. contents.day[1].level .. " (" .. contents.day[1].name .. ").")
        end

        local skullEnd = getPlayerSkullEnd(cid)
        if(skullEnd > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd))
        end
    end

    return true
end
Data/talkactions/talkactions.xml
Code:
<talkaction words="!frags" event="script" value="frags.lua"/>
For me it works :) so, I hope it will works for u too, im using tfs 0.3.6 same as you
 
data/talkactions/scripts create new file and call it "frags" and add following code
Code:
local config = {
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler')),
    advancedFragList = getBooleanFromString(getConfigValue('advancedFragList'))
}

function onSay(cid, words, param, channel)
    if(not config.useFragHandler) then
        return false
    end

    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 = {
                name = result:getDataString("name"),
                level = result:getDataInt("level"),
                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)
    }
    if(config.advancedFragList) then
        local result = "Frags gained today: " .. size.day .. "."
        if(size.day > 0) then
            for _, content in ipairs(contents.day) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        result = result .. "\nFrags gained this week: " .. (size.day + size.week) .. "."
        if(size.week > 0) then
            for _, content in ipairs(contents.week) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        result = result .. "\nFrags gained this month: " .. (size.day + size.week + size.month) .. "."
        if(size.month > 0) then
            for _, content in ipairs(contents.month) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        local skullEnd = getPlayerSkullEnd(cid)
        if(skullEnd > 0) then
            result = result .. "\nYour " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd)
        end

        doPlayerPopupFYI(cid, result)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You currently have " .. size.day .. " frags today, " .. (size.day + size.week) .. " this week and " .. (size.day + size.week + size.month) .. " this month.")
        if(size.day > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Last frag at " .. os.date("%d %B %Y %X", contents.day[1].date) .. " on level " .. contents.day[1].level .. " (" .. contents.day[1].name .. ").")
        end

        local skullEnd = getPlayerSkullEnd(cid)
        if(skullEnd > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd))
        end
    end

    return true
end
Data/talkactions/talkactions.xml
Code:
<talkaction words="!frags" event="script" value="frags.lua"/>
For me it works :) so, I hope it will works for u too, im using tfs 0.3.6 same as you
Still doesnt work :(
 
Last edited by a moderator:
Bumb!!!
Any new answer??!??!

Check if you got these lines in your config;
Lua:
useFragHandler = true
advancedFragList = false

That should fix the first error, checkExhausted isn't added;
Add this to your lib file (data/talkactions/lib/talkactions.lua I think) or global.lua if you got that.
Lua:
function checkExhausted(cid, storage, seconds)
    local v = exhaustion.get(cid, storage)
    if(not v) then
        exhaustion.set(cid, storage, seconds)
    else
        doPlayerSendCancel(cid, "Please wait " .. v .. " seconds before use that command again.")
        return false
    end

    return true
end
 
Back
Top