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

Skull/frags remover

zapo

Member
Joined
Nov 10, 2020
Messages
113
Solutions
3
Reaction score
11
Skrypt usuwa skulla, ale fragi pozostają, mianowicie gdy zabije jedną osobę od razu red skull

Po użyciu nie usuwają się fragi.
Adnotacja 2021-01-03 183343.png
Lua:
    function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
if not tile then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must be in protection zone to use this item.")
    return true
end
if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
    player:setSkull(SKULL_NONE)
    player:setSkullTime(0)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
    db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
    --db.query("UPDATE `players` SET `skulltime` = 0 WHERE `id` = " .. player:getGuid())
    item:remove(1)
    player:remove()
else
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
    player:getPosition():sendMagicEffect(CONST_ME_POFF)
end
    return true
end
 

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,731
Solutions
17
Reaction score
410
Location
Poland
GitHub
FreshyPeshy
Jesteś pewien, że pozostają też server-side?
Jeśli używasz OTC to możliwe, że w module który jest odpowiedzialny za pokazywanie fragów po prostu się nie odświeżają w momencie gdy używasz frag removera.
 
OP
OP
zapo

zapo

Member
Joined
Nov 10, 2020
Messages
113
Solutions
3
Reaction score
11
Jesteś pewien, że pozostają też server-side?
Jeśli używasz OTC to możliwe, że w module który jest odpowiedzialny za pokazywanie fragów po prostu się nie odświeżają w momencie gdy używasz frag removera.
Zauważyłem, że fragi usuwają się ale po około 10h... czyli faktycznie odświeżanie musi być źle ustawione. Wiesz może jak to zmienić?
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,952
Solutions
203
Reaction score
3,780
execute the queries after removing the players or they wont be executed, also you will need to wait a little after the player logout so use AddEvent, something like this:
 
OP
OP
zapo

zapo

Member
Joined
Nov 10, 2020
Messages
113
Solutions
3
Reaction score
11
Tak jak kolega wyżej pisze gracz musi zostać usunięty a dopiero potem wykonujesz zapytania do bazy, dodatkowo brakuje ci zapytania do usuwania fragów.
Jak wygląda to zapytanie?
Post automatically merged:

execute the queries after removing the players or they wont be executed, also you will need to wait a little after the player logout so use AddEvent, something like this:
This code remove player but dont remove frags and skull
Lua:
local skull = Action()
 
 function skull.onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
if not tile then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must be in protection zone to use this item.")
    return true
end
if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
    player:remove()
    addEvent(db.query, 1, "UPDATE player_deaths SET unjustified = 0 WHERE unjustified = 1 AND killed_by = " ..  db.escapeString(player:getName()))
    player:setSkull(SKULL_NONE)
    player:setSkullTime(0)
    item:remove(9969)
    player:save()
else
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
    player:getPosition():sendMagicEffect(CONST_ME_POFF)
end
    return true
end

skull:id(9969)
skull:register()
 
Last edited:

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,952
Solutions
203
Reaction score
3,780
something like this:
Lua:
local skull = Action()

function skull.onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
    if not tile then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must be in protection zone to use this item.")
        return true
    end
    if table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
        player:setSkull(SKULL_NONE)
        player:setSkullTime(0)
        item:remove(1)
        local name = player:getName()
        player:remove()
        addEvent(db.query, 2, "UPDATE player_deaths SET unjustified = 0 WHERE unjustified = 1 AND killed_by = " ..  db.escapeString(name))
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

skull:id(9969)
skull:register()
 
Last edited:

slaw

Developer
Joined
Aug 27, 2007
Messages
3,282
Solutions
101
Reaction score
766
Location
Germany
GitHub
slawkens
something like this:
Lua:
local skull = Action()

function skull.onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
    if not tile then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must be in protection zone to use this item.")
        return true
    end
    if table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
        player:setSkull(SKULL_NONE)
        player:setSkullTime(0)
        item:remove(1)
        local name = player:getName()
        player:remove()
        addEvent(db.query, 2, "UPDATE player_deaths SET unjustified = 0 WHERE unjustified = 1 AND killed_by = " ..  db.escapeString(name))
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

skull:id(9969)
skull:register()

Why are you doing it with addEvent? As far as I know TFS is not async = )

so just after player:remove() is finished it should call db.query
 
OP
OP
zapo

zapo

Member
Joined
Nov 10, 2020
Messages
113
Solutions
3
Reaction score
11
Still not working, skull removes but frags remain. Sometimes when I close client and relog it doesn't show frags, but when I kill I get rs
i database unjustifield change to 0...
 

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
38
Solutions
1
Reaction score
3
something like this:
Lua:
local skull = Action()

function skull.onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
    if not tile then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must be in protection zone to use this item.")
        return true
    end
    if table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
        player:setSkull(SKULL_NONE)
        player:setSkullTime(0)
        item:remove(1)
        local name = player:getName()
        player:remove()
        addEvent(db.query, 2, "UPDATE player_deaths SET unjustified = 0 WHERE unjustified = 1 AND killed_by = " ..  db.escapeString(name))
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

skull:id(9969)
skull:register()
this work to me. thanks <3

FLP
 
Top