• 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
129
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...
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
 
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
 
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
 
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
 
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.

 
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
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
he is working well
There is one problem
Lua:
[Error - mysql_real_query] Query: UPDATE `player_kills` SET `time` = 1 WHERE `pl
ayer_id` = 94
Message: Table 'abdo123456.player_kills' doesn't exist
How do I fix this error?
 
he is working well
There is one problem
Lua:
[Error - mysql_real_query] Query: UPDATE `player_kills` SET `time` = 1 WHERE `pl
ayer_id` = 94
Message: Table 'abdo123456.player_kills' doesn't exist
How do I fix this error?
SQL:
CREATE TABLE `player_kills` (
  `player_id` int(11) NOT NULL,
  `date` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
  `target` int(11) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
Back
Top