• 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 player move

Kjhgfd

New Member
Joined
Dec 25, 2016
Messages
63
Reaction score
1
i need script for
if player move = die
but not need stepin need function check if move or no

tfs 0.4
 
i need script for
if player move = die
but not need stepin need function check if move or no

tfs 0.4
do an onThink(), add this

checkPos(cid, getCreaturePosition(cid))

Code:
function checkPos(cid, prevPos)
local playerPos = getCreaturePosition(cid)
--if positions are different.
if(playerPos~=prevPos)then
--kill player
doPlayerAddHealth(cid, -500)
else
--if they arent different check in 200 MS again
addEvent(checkPos, 200, cid, playerPos)
end
return true
end
 
i need script for
if player move = die
but not need stepin need function check if move or no

tfs 0.4
Why not use movement script? Since you are going to just kill the player if he moves and not register any attempts of moving under x time, it seems to me that there is no point in not using the movement interface:
Lua:
function onStepOut(cid, item, toPosition, fromPosition)
    if getPlayerStorageValue(cid, 500) == 1 then
        local damage = getCreatureHealth(cid) + getCreatureMana(cid)
        doTargetCombatHealth(0, cid, COMBAT_PHYSICALDAMAGE, -damage, -damage, 18)
    end
    return true
end
 
Last edited:
Why not use movement script? Since you are going to just kill the player if he moves and not register any attempts of moving under x time, it seems to me that there is no point in not using the movement interface:
Lua:
function onStepOut(cid, item, toPosition, fromPosition)
    if getPlayerStorageValue(cid, 500) == 1 then
        local damage = getCreatureMaxHealth(cid) + getCreatureMaxMana(cid)
        doTargetCombatHealth(0, cid, COMBAT_PHYSICALDAMAGE, -damage, -damage, 18)
    end
    return true
end
Movements are registered for one or more ids that you step on, so if his script has to work on any id, then movements are useless.
 
Movements are registered for one or more ids that you step on, so if his script has to work on any id, then movements are useless.
I suppose you are right.
Lua:
local config = {
    duration = 5 * 60,
    storage = 500,
    interval = 200,
}

local function check(cid, pos)
    if not isPlayer(cid) or getPlayerStorageValue(cid, config.storage) <= 0 then
        return
    end 
    return pos ~= getThingPos(cid) and doCreatureAddHealth(cid, -getCreatureHealth(cid)) or addEvent(check, config.interval, cid, pos)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    --[[
    if item.itemid == some_item_id then
        -- doSomething()
    end
    --]]
    return addEvent(check, config.interval, cid, getThingPos(cid)), setPlayerStorageValue(cid, config.storage, os.time() + config.duration)
end

However I would be wary of having too many players queue timers like the example above. Might lag your server pretty bad.
 
Back
Top