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

Spell: Drop weapon from target player

mmoussa

New Member
Joined
Jul 11, 2011
Messages
37
Reaction score
0
Hi, I'm trying to make a spell that will drop a target player's weapon. Or at least move it out of his hand to belt or backpack. How can I do this, is it even possible?

Thanks
 
Here's the code I came up with, but I'm getting a "Thing not found" error. Any ideas?

Code:
function onCastSpell(cid, var)
   
    local tid = getCreatureTarget(cid)
    local pos = getCreaturePosition(cid)
    local targetName = getCreatureName(tid)
    local target = getPlayerByName(targetName)
    local slot1 = getPlayerSlotItem(target, CONST_SLOT_RIGHT)
    local slot2 = getPlayerSlotItem(target, CONST_SLOT_LEFT)
   
        if slot1.itemid == 7735 then
            doTeleportThing(slot1, pos)
            elseif slot2.itemid == 7735 then
                doTeleportThing(slot2, pos)
            end
       


return true
end
 
Fixed the error! But the "pos" is my pos not the target :/ I want the item to fall under the target. Or into their backpack.

Code:
function onCastSpell(cid, var)
   
    local tid = getCreatureTarget(cid)
    local pos = getCreaturePosition(cid)
    local targetName = getCreatureName(tid)
    local target = getPlayerByName(targetName)
    local slot1 = getPlayerSlotItem(target, CONST_SLOT_RIGHT)
    local slot2 = getPlayerSlotItem(target, CONST_SLOT_LEFT)
   
        if slot1.itemid == 7735 then
            doTeleportThing(slot1.uid, pos)
            elseif slot2.itemid == 7735 then
                doTeleportThing(slot2.uid, pos)
            end
       


return true
end
 
Item now drops infront of target. Have no idea how to move it to backpack though :/ ideas?

Code:
function onCastSpell(cid, var)
   
    local tid = getCreatureTarget(cid)
    local targetName = getCreatureName(tid)
    local target = getPlayerByName(targetName)
    --local pos = getThingPos(target)
    local pos = getPlayerLookPos(target)
    local slot1 = getPlayerSlotItem(target, CONST_SLOT_RIGHT)
    local slot2 = getPlayerSlotItem(target, CONST_SLOT_LEFT)
   
        if slot1.itemid == 7735 then
            doTeleportThing(slot1.uid, pos)
            elseif slot2.itemid == 7735 then
                doTeleportThing(slot2.uid, pos)
            end
       


return true
end
 
Eh, i do not actually support TFS 0.3. But i thougt the idea was fun. So i gave it a try. It's not been tested:
Code:
local function isWeapon(uid)
    if isInArray({WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE, WEAPON_DIST, WEAPON_WAND}, getItemWeaponType(uid)) then
        return true
    end
   
    return false
end

function onCastSpell(cid, var)
    local target = getCreatureTarget(cid)
    if not target then
        return true
    end
   
    local backpackSlot = getPlayerSlotItem(target, CONST_SLOT_BACKPACK)
    if not backpackSlot then
        doPlayerAddItem(target, 1988, 1, true, CONST_SLOT_BACKPACK)
    end

    local rightSlot, leftSlot = getPlayerSlotItem(target, CONST_SLOT_RIGHT), getPlayerSlotItem(target, CONST_SLOT_LEFT)
    local storeWeapon
    if isWeapon(rightSlot.uid) then
        storeWeapon = doCopyItem(rightSlot, true)
        if storeWeapon then
            doPlayerRemoveItem(target, rightSlot.uid, 1, false, backpackSlot)
            doPlayerAddItemEx(target, storeWeapon.uid)
        end
    elseif isWeapon(leftSlot.uid) then
        storeWeapon = doCopyItem(leftSlot, true, false, backpackSlot)
        if storeWeapon then
            doPlayerRemoveItem(target, leftSlot.uid, 1)
            doPlayerAddItemEx(target, storeWeapon.uid)
        end   
    end

    return true
end
 
Better is when Disarm spell is 'Removing' weapon+shield from the game. Storing IDs in two storages. Then adds these items back after X seconds or after reloging (ex. after death).
 
Better is when Disarm spell is 'Removing' weapon+shield from the game. Storing IDs in two storages. Then adds these items back after X seconds or after reloging (ex. after death).

What about if that item has certain attributes that are unique to that item, then of course you would need to save this data as well. I like andu's idea, it's better implementation in my opinion, would be more of a truly disarm, but I would also recommend checking when a player tries to equip an item, if they have an item already stored, then if so, keep the user from equipping any weapon to that slot
 
Back
Top