• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Is it possible to create a vocation that "tp" when hitting someone

leokart7

New Member
Joined
Mar 19, 2015
Messages
46
Reaction score
0
So like a few years ago I played tibia a lot. I remember playing an OtServer that had a vocation named "Ninja", and this guy whenever he hitted someone with an attack he teleported around the guy.

Meaning:
SUPPOSE X IS MONSTER AND Y IS NINJA

1st attack:
O O O
O X O
O Y O

2nd attack:

O O O
O X Y
O O O

3rd attack

Y O O
O X O
O O O

I do know it's possible but I have no idea how to do so. Or instead of making a vocation a weapon or something. THANK YOU! :)
 
Code:
function onCombat(cid, target)
     if getPlayerVocation(cid) == 9 and getCreatureTarget(cid) == target then
         if not exhaustion.check(cid, 38475) then
             doTeleportThing(cid, getClosestFreeTile(cid, getThingPosition(target)), false)
             exhaustion.set(cid, 38475, 1)
         end
     end
     return true
end
 
@Limos yes,
Creaturescript:
Code:
  <event type="login" name="Vocationscript" event="script" value="vocationscript.lua"/>

Login:
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    if (getConfigValue("accountManager") == FALSE and getCreatureName(cid) == "Account Manager") then
        return false
    end

    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid,'SpellUp')


    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    return true
end

function onCombat(cid, target)
     if getPlayerVocation(cid) == 9 and getCreatureTarget(cid) == target then
         if not exhaustion.check(cid, 38475) then
             doTeleportThing(cid, getClosestFreeTile(cid, getThingPosition(target)), false)
             exhaustion.set(cid, 38475, 1)
         end
     end
     return true
end

I wasnt really sure how to add it in the login lua
 
You have to register it in login.lua.
Code:
registerCreatureEvent(cid, "Vocationscript")
You need to register all creaturescripts for players in login.lua except login and logout scripts.
 
@Limos I did everything correctly, but now when I execute TFS it gives me the following error in the script. [21/03/2015 18:04:00] [Warning - Event::loadScript] Event onLogin not found (data/creaturescripts/scripts/vocationscript.lua)
 
@Limos ok, now I have no clue why its not working.

vocationscript.lua:
Code:
function onCombat(cid, target)
     if getPlayerVocation(cid) == 9 and getCreatureTarget(cid) == target then
         if not exhaustion.check(cid, 38475) then
             doTeleportThing(cid, getClosestFreeTile(cid, getThingPosition(target)), false)
             exhaustion.set(cid, 38475, 1)
         end
     end
     return true
end

login.lua:
Code:
registerCreatureEvent(cid, "vocationscript")

creaturescript.lua:
Code:
    <event type="combat" name="Ninja" event="script" value="ninja.lua"/>
 
It's still not working! i change the name of everything to ninja to become easier.. and I even tried to change the vocation to see if it would help, but no. I have created in the login.lua the event Ninja, in the creaturescript lua it's also the correct one and I renamed the function file to Ninja.lua as well. And for the moment im trying to make it work in a knight. @Limos do you have any clue why isnt it working?
 
Back
Top