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

Frags/skull remover

zapo

Member
Joined
Nov 10, 2020
Messages
128
Solutions
3
Reaction score
11
The scenario removes the skulla, but the frags remain, namely when he kills one person immediately a red skull

Frags are not removed after use.
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
 
Solution
I killed until I got the red skull, after using the item if I kill one more player, I get redskull again, it doesn't reset the skull window.

Ok!, i will share my system
libs.lua add
Lua:
dofile('data/lib/custom/scriptname.lua')
lib/custom/scriptname.lua
Lua:
function removefrags(player)
       playerid = player:getGuid()
    player:remove()
    db.query('UPDATE `player_kills` SET `time` = 1 WHERE `player_id` = '..playerid..'')
    return true
end
action

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
        return...

_M4G0_

Well-Known Member
Joined
Feb 6, 2016
Messages
463
Solutions
15
Reaction score
81
The scenario removes the skulla, but the frags remain, namely when he kills one person immediately a red skull

Frags are not removed after use.
View attachment 53245
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
create a lib with the functions by removing the player before running in db, then create the action
 

rubraon

New Member
Joined
Aug 29, 2016
Messages
12
Reaction score
1
Lua Script Error: [Test Interface]
data/actions/scripts/other/frag_remover.lua
data/actions/scripts/other/frag_remover.lua:1: attempt to call global 'Action' (a nil value)
stack traceback:
[C]: in function 'Action'
data/actions/scripts/other/frag_remover.lua:1: in main chunk
[C]: in function 'reload'
data/talkactions/scripts/reload.lua:76: in function <data/talkactions/scripts/reload.lua:59>
[Warning - Event::checkScript] Can not load script: scripts/other/frag_remover.lua
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,112
Solutions
218
Reaction score
4,026
Lua Script Error: [Test Interface]
data/actions/scripts/other/frag_remover.lua
data/actions/scripts/other/frag_remover.lua:1: attempt to call global 'Action' (a nil value)
stack traceback:
[C]: in function 'Action'
data/actions/scripts/other/frag_remover.lua:1: in main chunk
[C]: in function 'reload'
data/talkactions/scripts/reload.lua:76: in function <data/talkactions/scripts/reload.lua:59>
[Warning - Event::checkScript] Can not load script: scripts/other/frag_remover.lua
script should go on data/scripts folder and NOT on data/actions/scripts folder, its a revscriptsys
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,112
Solutions
218
Reaction score
4,026
I don't use revscript in this case (data / scripts /), I don't have it on my server ... would there be any other solution?
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 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
 

rubraon

New Member
Joined
Aug 29, 2016
Messages
12
Reaction score
1
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 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
I killed until I got the red skull, after using the item if I kill one more player, I get redskull again, it doesn't reset the skull window.

 

_M4G0_

Well-Known Member
Joined
Feb 6, 2016
Messages
463
Solutions
15
Reaction score
81
I killed until I got the red skull, after using the item if I kill one more player, I get redskull again, it doesn't reset the skull window.

Ok!, i will share my system
libs.lua add
Lua:
dofile('data/lib/custom/scriptname.lua')
lib/custom/scriptname.lua
Lua:
function removefrags(player)
       playerid = player:getGuid()
    player:remove()
    db.query('UPDATE `player_kills` SET `time` = 1 WHERE `player_id` = '..playerid..'')
    return true
end
action

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
        return true
    end
    if(not getTileInfo(player:getPosition()).protection) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can only use in protection zone.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    
    player:setSkull(0)
    player:setSkullTime(0)
    item:remove(1)
    removefrags(player)
    return true
end
 
Solution
Top