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

Solved [SPELL] Swap

tnecniiv

scripter to be
Joined
Jan 6, 2012
Messages
294
Solutions
3
Reaction score
23
local combat = createCombatObject()

local config = {
notAllowed = {"training monk", "Slaktaren", "Admin"},
exhaustStorage = 1338,
exhaustTime = 5, -- Seconds
slowStorage = 1339,
slowTime = 3, -- Seconds
slowSpeed = 100, -- Speed will be set to 100 when swaping for slowTime seconds.
}

function effect(cid, var, targetpos, mypos, target)
doSendMagicEffect(mypos, CONST_ME_ENERGYHIT)
doSendMagicEffect(targetpos, CONST_ME_ENERGYHIT)
end

function slowed(cid, speed)
doChangeSpeed(cid, getPlayerStorageValue(cid, config.slowStorage) - getCreatureSpeed(cid))
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
end

function onCastSpell(cid, var)
setPlayerStorageValue(cid, config.slowStorage, getCreatureSpeed(cid))
local mypos = getCreaturePosition(cid)
local target = getCreatureTarget(cid)
local targetpos = getCreaturePosition(target)
if not exhaustion.get(cid, config.exhaustStorage) then
for _,v in ipairs(config.notAllowed) do
if string.find(getCreatureName(target):lower(), v) then
doPlayerSendCancel(cid, "You can't swap " .. getCreatureName(target) .. "!")
doSendMagicEffect(mypos, CONST_ME_POFF)
return false
else
doTeleportThing(cid, targetpos)
doTeleportThing(target, mypos)
doChangeSpeed(cid, -getCreatureSpeed(cid)+config.slowSpeed)
doSendDistanceShoot(mypos, targetpos, CONST_ANI_ENERGYBALL)
doSendDistanceShoot(targetpos, mypos, CONST_ANI_ENERGYBALL)
addEvent(effect, 150, cid, var, targetpos, mypos, target)
addEvent(slowed, config.slowTime * 1000, cid, speed)
exhaustion.set(cid, config.exhaustStorage, config.exhaustTime)
end
end
else
doPlayerSendCancel(cid, "You have to wait " .. exhaustion.get(cid, config.exhaustStorage) .. " seconds to swap positions again!")
return false
end
doCombat(cid, combat, var)
return true
end
_______________________
<instant name="Swap Position" words="swap" lvl="16" mana="20" prem="1" range="3" needtarget="1" blockwalls="1" exhaustion="100" needlearn="0" event="script" value="support/swap.lua">
<vocation id="1"/>
<vocation id="2"/>
<vocation id="3"/>
<vocation id="4"/>
<vocation id="5"/>
<vocation id="6"/>
<vocation id="7"/>
<vocation id="8"/>
</instant>

this spell is not registering i get no errors in my console but it does not work any help would be nice
im using tfs 0.2.14
 
That is for TFS 0.3/0.4, It's different in TFS 0.2
Code:
<instant group="support" spellid="122" name="Swap Position" words="swap" lvl="16" mana="20" prem="1" range="3" needtarget="1" blockwalls="1" cooldown="100" groupcooldown="100" needlearn="0" script="support/swap.lua">
   <vocation name="Sorcerer"/>
   <vocation name="Druid"/>
   <vocation name="Paladin"/>
   <vocation name="Knight"/>
   <vocation name="Master Sorcerer"/>
   <vocation name="Elder Druid"/>
   <vocation name="Royal Paladin"/>
   <vocation name="Elite Knight"/>
</instant>

If you don't have the exhaustion function, add this in global.lua.
Code:
exhaustion =
{
   check = function (cid, storage)
     return getPlayerStorageValue(cid, storage) >= os.time(t)
   end,

   get = function (cid, storage)
     local exhaust = getPlayerStorageValue(cid, storage)
     if(exhaust > 0) then
       local left = exhaust - os.time(t)
       if(left >= 0) then
         return left
       end
     end

     return false
   end,

   set = function (cid, storage, time)
     setPlayerStorageValue(cid, storage, os.time(t) + time)
   end,

   make = function (cid, storage, time)
     local exhaust = exhaustion.get(cid, storage)
     if(not exhaust) then
       exhaustion.set(cid, storage, time)
       return true
     end

     return false
   end
}
 
Back
Top