• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TFS 1.2 Frag remover doesnt remove stored kills

Tbol

Active Member
Joined
Apr 7, 2019
Messages
421
Reaction score
45
Hello
using action script that should remove all of my kills and my current white skull or red skull if i have one. It removes white skull fine (didnt tested with red skull) but it doesnt remove my stored kills that i have
Code:
You currently have 1 frags today, 1 this week and 1 this month.
and after using my frag remover it stays the same
but it should set all of my kills to 0, day, week, month, but it doesnt remove shitt

This is action script.
Lua:
local cooldown = 5 --time in seconds
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getExhaustion(Storage.FragRemoverCooldown) then
        player:sendCancelMessage("You are on cooldown.")
        return false
    end

    if player:getSkull() ~= SKULL_NONE then
        player:setSkull(SKULL_NONE)
    end

    player:setPlayerKillerEnd(0)
    player:setExhaustion(Storage.FragRemoverCooldown, cooldown)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your frags has been removed!")
    db.query("UPDATE `player_deaths` SET `unjustified` = 0 WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(player:getName()))
    item:remove(1)
    return true
end

Info from src that maybe might help idk
C++:
 for (auto kill : player->kills) {
        query.str(std::string());
        query << "INSERT INTO `player_kills` (`player_id`, `victim_id`, `time`) VALUES (" << player->getGUID() << "," << std::get<0>(kill) << "," << std::get<1>(kill) << ");";
        if (!db->executeQuery(query.str())) {
            return false;
        }
    }
C++:
 //load kills
    query.str(std::string());
    query << "SELECT `victim_id`,`time` FROM `player_kills` WHERE `player_id` = " << player->getGUID();
    if ((result = db->storeQuery(query.str()))) {
        do {
            player->kills.push_back(std::make_pair(result->getNumber<uint32_t>("victim_id"), result->getNumber<uint64_t>("time")));
        } while (result->next());
    }
 
Solution
Lua:
local cooldown = 5 --time in seconds
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getExhaustion(Storage.FragRemoverCooldown) then
        player:sendCancelMessage("You are on cooldown.")
        return false
    end

    if player:getSkull() ~= SKULL_NONE then
        player:setSkull(SKULL_NONE)
    end

    player:setPlayerKillerEnd(0)
    player:setExhaustion(Storage.FragRemoverCooldown, cooldown)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your frags has been removed!")
    item:remove(1)
    local playerId = player:getGuid();
    player:remove()
    addEvent(db.query, 10, "DELETE FROM `player_kills` WHERE `player_id` =...
OP
OP
Tbol

Tbol

Active Member
Joined
Apr 7, 2019
Messages
421
Reaction score
45
Lua:
player:setSkullTime(0)
150981285d1acfdaf03f8c422cda2a5e.png
 

Rombadr

Premium User
Premium User
Joined
Jan 19, 2020
Messages
329
Solutions
37
Reaction score
212
I mean, if you actually want them to be removed from the database you could use
Lua:
local cooldown = 5 --time in seconds
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getExhaustion(Storage.FragRemoverCooldown) then
        player:sendCancelMessage("You are on cooldown.")
        return false
    end

    if player:getSkull() ~= SKULL_NONE then
        player:setSkull(SKULL_NONE)
    end

    player:setPlayerKillerEnd(0)
    player:setExhaustion(Storage.FragRemoverCooldown, cooldown)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your frags has been removed!")
    db.query("DELETE FROM `player_deaths` WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(player:getName()))
    item:remove(1)
    return true
end
 
OP
OP
Tbol

Tbol

Active Member
Joined
Apr 7, 2019
Messages
421
Reaction score
45
I mean, if you actually want them to be removed from the database you could use
Lua:
local cooldown = 5 --time in seconds
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getExhaustion(Storage.FragRemoverCooldown) then
        player:sendCancelMessage("You are on cooldown.")
        return false
    end

    if player:getSkull() ~= SKULL_NONE then
        player:setSkull(SKULL_NONE)
    end

    player:setPlayerKillerEnd(0)
    player:setExhaustion(Storage.FragRemoverCooldown, cooldown)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your frags has been removed!")
    db.query("DELETE FROM `player_deaths` WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(player:getName()))
    item:remove(1)
    return true
end
Nop still same
before
18:51 You currently have 1 frags today, 1 this week and 4 this month.
and after using this
18:51 You currently have 1 frags today, 1 this week and 4 this month.
frags are still the same
 

Rombadr

Premium User
Premium User
Joined
Jan 19, 2020
Messages
329
Solutions
37
Reaction score
212
hmm probably works after relogging, so player:setSkullTime(0) should do the trick... but looks like you don't have that function (or it doesn't exist?)
 
OP
OP
Tbol

Tbol

Active Member
Joined
Apr 7, 2019
Messages
421
Reaction score
45
hmm probably works after relogging, so player:setSkullTime(0) should do the trick... but looks like you don't have that function (or it doesn't exist?)
tried relogging still same. Yea i dont have player:setSkullTime(0) function, checked source and there is nothing about it.
 

Rombadr

Premium User
Premium User
Joined
Jan 19, 2020
Messages
329
Solutions
37
Reaction score
212
This would kick the player, so maybe check if player is currently pzlocked before being able to use the item
Lua:
local cooldown = 5 --time in seconds
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getExhaustion(Storage.FragRemoverCooldown) then
        player:sendCancelMessage("You are on cooldown.")
        return false
    end

    if player:getSkull() ~= SKULL_NONE then
        player:setSkull(SKULL_NONE)
    end

    player:setPlayerKillerEnd(0)
    player:setExhaustion(Storage.FragRemoverCooldown, cooldown)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your frags has been removed!")
    item:remove(1)
    local playerName = player:getName();
    player:remove()
    addEvent(db.query, 10, "DELETE FROM `player_deaths` WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(playerName))
    return true
end
 
OP
OP
Tbol

Tbol

Active Member
Joined
Apr 7, 2019
Messages
421
Reaction score
45
This would kick the player, so maybe check if player is currently pzlocked before being able to use the item
Lua:
local cooldown = 5 --time in seconds
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getExhaustion(Storage.FragRemoverCooldown) then
        player:sendCancelMessage("You are on cooldown.")
        return false
    end

    if player:getSkull() ~= SKULL_NONE then
        player:setSkull(SKULL_NONE)
    end

    player:setPlayerKillerEnd(0)
    player:setExhaustion(Storage.FragRemoverCooldown, cooldown)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your frags has been removed!")
    item:remove(1)
    local playerName = player:getName();
    player:remove()
    addEvent(db.query, 10, "DELETE FROM `player_deaths` WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(playerName))
    return true
end
Still doesnt remove
 

Rombadr

Premium User
Premium User
Joined
Jan 19, 2020
Messages
329
Solutions
37
Reaction score
212
Lua:
local cooldown = 5 --time in seconds
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getExhaustion(Storage.FragRemoverCooldown) then
        player:sendCancelMessage("You are on cooldown.")
        return false
    end

    if player:getSkull() ~= SKULL_NONE then
        player:setSkull(SKULL_NONE)
    end

    player:setPlayerKillerEnd(0)
    player:setExhaustion(Storage.FragRemoverCooldown, cooldown)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your frags has been removed!")
    item:remove(1)
    local playerName = player:getName();
    player:remove()
    addEvent(db.query, 10, "DELETE FROM `player_deaths` WHERE `killed_by` = " .. db.escapeString(playerName))
    return true
end
 

Boy67

Veteran OT User
Joined
Jul 4, 2007
Messages
419
Solutions
23
Reaction score
340
Location
England
Your sources are updating/fetching from "player_kills" db, but in your LUA script you're deleting from the "player_deaths" db.
 

Rombadr

Premium User
Premium User
Joined
Jan 19, 2020
Messages
329
Solutions
37
Reaction score
212
Lua:
local cooldown = 5 --time in seconds
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getExhaustion(Storage.FragRemoverCooldown) then
        player:sendCancelMessage("You are on cooldown.")
        return false
    end

    if player:getSkull() ~= SKULL_NONE then
        player:setSkull(SKULL_NONE)
    end

    player:setPlayerKillerEnd(0)
    player:setExhaustion(Storage.FragRemoverCooldown, cooldown)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your frags has been removed!")
    item:remove(1)
    local playerId = player:getGuid();
    player:remove()
    addEvent(db.query, 10, "DELETE FROM `player_kills` WHERE `player_id` = " .. playerId)
    return true
end
 
Solution
Top