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

Itutorial's Scripting Service TFS 0.3.6-0.4-1.x

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,339
Solutions
68
Reaction score
1,024
As the title says.

Format:
-Distro
-explination of code needed as detailed as possible
-Pictures if required of map set up for code

I don't usually mess with C++ but if I know I can do something that you request I will.
 
Change

Code:
if not isMoveable(getThingByPos(poslook)).uid then

to

Code:
if not isMoveable(getTileThingByPos(poslook)).uid then
 
Change

Code:
if not isMoveable(getThingByPos(poslook)).uid then

to

Code:
if not isMoveable(getTileThingByPos(poslook)).uid then
get this error:

[26/01/2018 08:03:17] [Error - Spell Interface]
[26/01/2018 08:03:17] In a timer event called from:
[26/01/2018 08:03:17] data/spells/scripts/test.lua:eek:nCastSpell
[26/01/2018 08:03:17] Description:
[26/01/2018 08:03:18] data/spells/scripts/test.lua:27: attempt to index a boolean value
[26/01/2018 08:03:18] stack traceback:
[26/01/2018 08:03:18] data/spells/scripts/test.lua:27: in function <data/spells/scripts/test.lua:23>
 
Code:
local damage = 20 -- dano que toma qnd bate em algum obstáculo
local speed = 910 -- velocidade do player ao usar o dash (vai de 0 a mil)
local pzprotect = true -- nao deixa entrar em pz com a spell
local distance = 15 -- quantos sqms anda

local function isWalkable(pos, creature, proj, pz)-- by Nord
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 3 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end

function onWalk(cid)
    if isCreature(cid) then
        local poslook = getCreatureLookPosition(cid)
        poslook.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
        if getThingByPos(poslook).uid then
            if not isMoveable(getThingByPos(poslook)).uid then
                return false
            end
        end
        if isWalkable(poslook, false, false, pzprotect) then
            if not isCreature(getTileThingfromPos(poslook).uid) then
                doMoveCreature(cid, getPlayerLookDirection(cid))
                doSendMagicEffect(getPlayerPosition(cid), 14)
            else
                doCreatureAddHealth(cid, -damage)
                doSendMagicEffect(getPlayerPosition(cid), 31)
                doSendAnimatedText(getPlayerPosition(cid), "-"..damage , 180)
            end
        else 
            doCreatureAddHealth(cid, -damage)
            doSendMagicEffect(getPlayerPosition(cid), 31)
            doSendAnimatedText(getPlayerPosition(cid), "-"..damage , 180)
        end
    end
return true
end

function onCastSpell(cid, var)
    for i = 0, distance do
        addEvent(onWalk, (1001- math.min(speed, 1000)) *i, cid)
    end
return true
end
 
Code:
local damage = 20 -- dano que toma qnd bate em algum obstáculo
local speed = 910 -- velocidade do player ao usar o dash (vai de 0 a mil)
local pzprotect = true -- nao deixa entrar em pz com a spell
local distance = 15 -- quantos sqms anda

local function isWalkable(pos, creature, proj, pz)-- by Nord
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 3 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end

function onWalk(cid)
    if isCreature(cid) then
        local poslook = getCreatureLookPosition(cid)
        poslook.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
        if getThingByPos(poslook).uid then
            if not isMoveable(getThingByPos(poslook)).uid then
                return false
            end
        end
        if isWalkable(poslook, false, false, pzprotect) then
            if not isCreature(getTileThingfromPos(poslook).uid) then
                doMoveCreature(cid, getPlayerLookDirection(cid))
                doSendMagicEffect(getPlayerPosition(cid), 14)
            else
                doCreatureAddHealth(cid, -damage)
                doSendMagicEffect(getPlayerPosition(cid), 31)
                doSendAnimatedText(getPlayerPosition(cid), "-"..damage , 180)
            end
        else
            doCreatureAddHealth(cid, -damage)
            doSendMagicEffect(getPlayerPosition(cid), 31)
            doSendAnimatedText(getPlayerPosition(cid), "-"..damage , 180)
        end
    end
return true
end

function onCastSpell(cid, var)
    for i = 0, distance do
        addEvent(onWalk, (1001- math.min(speed, 1000)) *i, cid)
    end
return true
end

get error getThingByPos (nil value), so i changed all getThingByPos to: getTileThingByPos, and get this error:

Code:
[26/01/2018 08:42:40] [Error - Spell Interface]
[26/01/2018 08:42:40] In a timer event called from:
[26/01/2018 08:42:40] data/spells/scripts/test.lua:onCastSpell
[26/01/2018 08:42:41] Description:
[26/01/2018 08:42:41] data/spells/scripts/test.lua:28: attempt to index a boolean value
[26/01/2018 08:42:41] stack traceback:
[26/01/2018 08:42:41]     data/spells/scripts/test.lua:28: in function <data/spells/scripts/test.lua:23>
 
Found bug here :)
rHL-rfbySymO2tFCsRDa-g.png
 
Fixed with another script is that possible to create something like that?
Code:
Next avaiable will be at: 19minutes and 40 second.

Here you're The script
Code:
    local creatures = {
        { name = "demon", pos = { x = 32468, y = 31717, z = 7} }
    }
    -- time in seconds til you can pull the switch again
    local time_ = 1200
    -- do not edit this
    local switch = {9825, 9826}
    local exhaust = true
    ---------------------
    function onUse(cid, item, frompos, item2, topos)
        local function resetSwitch()
             exhaust = true
        end
        if isInArray(switch, item.itemid) and exhaust then
            for i in ipairs(creatures) do
                doSummonCreature(creatures[i].name, creatures[i].pos)
            end
            exhaust = false
            addEvent(resetSwitch, time_ * 1000)
           setPlayerStorageValue(cid, 13540, time)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to wait 20 minutes to summon it again.")
        end
        doTransformItem(item.uid, (item.itemid == 9825) and item.itemid + 1 or item.itemid - 1)
        return true
    end
 
Format:
-Distro
1.3
-explination
I was wondering if its possible to make a condition which does damage to nearby creatures.
This condition should be made to be toggled. The damage type doesn't really matter i guess.
-Pictures
no pictures
 
Look through the different conditions that already exist. There are some condition like: poison that can be modified. No need to create a whole new one if the damage type doesn't matter.
 
I think he means that your player does damage to nearby creatures, and you can toggle it via spell. It should drain mana per second or hp per second. It may also apply an item to equip or deequip. Just like in some mobas.
 
Back
Top