• 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 TFS 1.1 Old Functions Script Problem!

Xarly

Member
Joined
Mar 9, 2015
Messages
360
Reaction score
20
Hello guys im tryng to register on login.lua some things but the distro give me a error im tryng to do that on login.lua
registerCreatureEvent(cid, "Wyda")
registerCreatureEvent(cid, "Raging Mage")
registerCreatureEvent(cid, "Raging Mage2")
registerCreatureEvent(cid, "White Deer")
registerCreatureEvent(cid, "White Deer2")
registerCreatureEvent(cid, "Northern Pike")
registerCreatureEvent(cid, "Gaz'haragoth Heal")
registerCreatureEvent(cid, "Omrafir Explode")
registerCreatureEvent(cid, "Shlorg Tp")
registerCreatureEvent(cid, "Welter Egg")
registerCreatureEvent(cid, "The Pale Count Tp")
registerCreatureEvent(cid, "Test Heal")
registerCreatureEvent(cid, "Zavarash Hide")
registerCreatureEvent(cid, "Monster Heal")
registerCreatureEvent(cid, "Monster Heal2")
registerCreatureEvent(cid, "Nomad")

and im getting this error on the distro TFS 1.1:
2hsawt1.png


i hope someone can help me thanks guys
 
after:
'DropLoot'

add a , and start adding only the event names, like 'Wyda', 'Raging Mage'

that is so easy and self explanatory lol
 
or just add

function registerCreatureEvent(cid, name) local c = Creature(cid) return c ~= nil and c:registerEvent(name) or false end

to any lib file
 
well im rlly noob xd i tried adding it like 'Wyda', but the event don't work >.< http://pastebin.com/wvxdsgKw tat0s my login.lua bro if u can add it for me>.< because im tard for these things thank you so much bro

You can try this in login.lua:
Code:
-- ordered as in creaturescripts.xml
local events = {
    'TutorialCockroach',
    'ElementalSpheresOverlords',
    'BigfootBurdenVersperoth',
    'BigfootBurdenWarzone',
    'BigfootBurdenWeeper',
    'BigfootBurdenWiggler',
    'SvargrondArenaKill',
    'NewFrontierShardOfCorruption',
    'NewFrontierTirecz',
    'ServiceOfYalaharDiseasedTrio',
    'ServiceOfYalaharAzerus',
    'ServiceOfYalaharQuaraLeaders',
    'InquisitionBosses',
    'InquisitionUngreez',
    'KillingInTheNameOfKills',
    'MastersVoiceServants',
    'SecretServiceBlackKnight',
    'ThievesGuildNomad',
    'WotELizardMagistratus',
    'WotELizardNoble',
    'WotEKeeper',
    'WotEBosses',
    'WotEZalamon',
    'PlayerDeath',
    'AdvanceSave',
    'AdvanceRookgaard',
    'PythiusTheRotten',
    'DropLoot',
    'Wyda',
    'Raging Mage',
    'Raging Mage2',
    'White Deer',
    'White Deer2',
    'Northern Pike',
    "Gaz'haragoth Heal",
    'Omrafir Explode',
    'Shlorg Tp',
    'Welter Egg',
    'The Pale Count Tp',
    'Test Heal',
    'Zavarash Hide',
    'Monster Heal',
    'Monster Heal2',
    'Nomad',
   
}
   
local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendTutorial(1)
    else
        if loginStr ~= '' then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local staminaTable = Game.getStorageValue("stamina")
    staminaTable[player.uid] = 0

    for i = 1, #events do
        player:registerEvent(events[i])
    end

    if player:getStorageValue(Storage.combatProtectionStorage) <= os.time() then
        player:setStorageValue(Storage.combatProtectionStorage, os.time() + 10)
        onMovementRemoveProtection(player.uid, player:getPosition(), 10)
    end
    return true
end
 
You can try this in login.lua:
Code:
-- ordered as in creaturescripts.xml
local events = {
    'TutorialCockroach',
    'ElementalSpheresOverlords',
    'BigfootBurdenVersperoth',
    'BigfootBurdenWarzone',
    'BigfootBurdenWeeper',
    'BigfootBurdenWiggler',
    'SvargrondArenaKill',
    'NewFrontierShardOfCorruption',
    'NewFrontierTirecz',
    'ServiceOfYalaharDiseasedTrio',
    'ServiceOfYalaharAzerus',
    'ServiceOfYalaharQuaraLeaders',
    'InquisitionBosses',
    'InquisitionUngreez',
    'KillingInTheNameOfKills',
    'MastersVoiceServants',
    'SecretServiceBlackKnight',
    'ThievesGuildNomad',
    'WotELizardMagistratus',
    'WotELizardNoble',
    'WotEKeeper',
    'WotEBosses',
    'WotEZalamon',
    'PlayerDeath',
    'AdvanceSave',
    'AdvanceRookgaard',
    'PythiusTheRotten',
    'DropLoot',
    'Wyda',
    'Raging Mage',
    'Raging Mage2',
    'White Deer',
    'White Deer2',
    'Northern Pike',
    "Gaz'haragoth Heal",
    'Omrafir Explode',
    'Shlorg Tp',
    'Welter Egg',
    'The Pale Count Tp',
    'Test Heal',
    'Zavarash Hide',
    'Monster Heal',
    'Monster Heal2',
    'Nomad',
  
}
  
local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendTutorial(1)
    else
        if loginStr ~= '' then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local staminaTable = Game.getStorageValue("stamina")
    staminaTable[player.uid] = 0

    for i = 1, #events do
        player:registerEvent(events[i])
    end

    if player:getStorageValue(Storage.combatProtectionStorage) <= os.time() then
        player:setStorageValue(Storage.combatProtectionStorage, os.time() + 10)
        onMovementRemoveProtection(player.uid, player:getPosition(), 10)
    end
    return true
end
okay thanks mate! i think that work now the only problem are my scripts i think they are buged-.,-" xD
 
You can try this in login.lua:
Code:
-- ordered as in creaturescripts.xml
local events = {
    'TutorialCockroach',
    'ElementalSpheresOverlords',
    'BigfootBurdenVersperoth',
    'BigfootBurdenWarzone',
    'BigfootBurdenWeeper',
    'BigfootBurdenWiggler',
    'SvargrondArenaKill',
    'NewFrontierShardOfCorruption',
    'NewFrontierTirecz',
    'ServiceOfYalaharDiseasedTrio',
    'ServiceOfYalaharAzerus',
    'ServiceOfYalaharQuaraLeaders',
    'InquisitionBosses',
    'InquisitionUngreez',
    'KillingInTheNameOfKills',
    'MastersVoiceServants',
    'SecretServiceBlackKnight',
    'ThievesGuildNomad',
    'WotELizardMagistratus',
    'WotELizardNoble',
    'WotEKeeper',
    'WotEBosses',
    'WotEZalamon',
    'PlayerDeath',
    'AdvanceSave',
    'AdvanceRookgaard',
    'PythiusTheRotten',
    'DropLoot',
    'Wyda',
    'Raging Mage',
    'Raging Mage2',
    'White Deer',
    'White Deer2',
    'Northern Pike',
    "Gaz'haragoth Heal",
    'Omrafir Explode',
    'Shlorg Tp',
    'Welter Egg',
    'The Pale Count Tp',
    'Test Heal',
    'Zavarash Hide',
    'Monster Heal',
    'Monster Heal2',
    'Nomad',
  
}
  
local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendTutorial(1)
    else
        if loginStr ~= '' then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local staminaTable = Game.getStorageValue("stamina")
    staminaTable[player.uid] = 0

    for i = 1, #events do
        player:registerEvent(events[i])
    end

    if player:getStorageValue(Storage.combatProtectionStorage) <= os.time() then
        player:setStorageValue(Storage.combatProtectionStorage, os.time() + 10)
        onMovementRemoveProtection(player.uid, player:getPosition(), 10)
    end
    return true
end
idk if u know but mate u know how to fix that thing? i getting problem with zao teleport because i pasted the zao teleport script from tfs 1.0 to tfs 1.1 so not work
2412w6o.png
T_T
 
Code:
local positions = {
   [60093] = Position(32941, 31593, 8),
   [60094] = Position(33142, 31528, 2)
}

function onStepIn(creature, item, position, fromPosition)
     if not creature:isPlayer() then
         return true
     end

     local x = positions[item.uid]
     if x then
         position:sendMagicEffect(CONST_ME_TELEPORT)
         creature:teleportTo(x, false)
         x:sendMagicEffect(CONST_ME_TELEPORT)
     end
     return true
end
 
Code:
local positions = {
   [60093] = Position(32941, 31593, 8),
   [60094] = Position(33142, 31528, 2)
}

function onStepIn(creature, item, position, fromPosition)
     if not creature:isPlayer() then
         return true
     end

     local x = positions[item.uid]
     if x then
         position:sendMagicEffect(CONST_ME_TELEPORT)
         creature:teleportTo(x, false)
         x:sendMagicEffect(CONST_ME_TELEPORT)
     end
     return true
end
Thanks limos! worked for me, i got another thing more last problem! if u can help please xd im getting error when kill raging mage :
Lua Script error: [CreatureScripts Inferface]
data/creaturescipts/raging mage.lua:eek:nDeath
data/creaturescipts/raging mage.lua:2: atempt to index global 'creature' <a nil value>
data/creaturescipts/raging mage2:lua:OnDeath
data/creaturescipts/raging mage2:lua:2: attempt to call global 'doCreatureSay' < a nil value>
stack traceback
[C]: in function 'doCreatureSay'
data/creaturescipts/raging mage2:lua:2 in function data/creaturescipts/raging mage2:lua1>
the script its
raging mage http://pastebin.com/0kW6Pac3
raging mage2 http://pastebin.com/CKysvhC1
thanks for your help limos!^^
 
https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L113
https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L467

Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
     local chance, pos, pos2 = math.random(1, 100), creature:getPosition(), Position(33143, 31527, 2)

     if chance < 11 then
         creature:say("MWAAAHAHAAA!! NO ONE!! NO ONE CAN DEFEAT MEEE!!!", TALKTYPE_MONSTER_YELL, false, nil, pos2)
         Game.createMonster("Raging Mage", pos)
     else
         creature:say("MWAAAHAHAAA!! NO ONE!! NO ONE CAN DEFEAT MEEE!!!", TALKTYPE_MONSTER_YELL, false, nil, pos2)
         Game.createMonster("Energized Raging Mage", pos)
     end
     return true
end
 
https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L113
https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua#L467

Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
     local chance, pos, pos2 = math.random(1, 100), creature:getPosition(), Position(33143, 31527, 2)

     if chance < 11 then
         creature:say("MWAAAHAHAAA!! NO ONE!! NO ONE CAN DEFEAT MEEE!!!", TALKTYPE_MONSTER_YELL, false, nil, pos2)
         Game.createMonster("Raging Mage", pos)
     else
         creature:say("MWAAAHAHAAA!! NO ONE!! NO ONE CAN DEFEAT MEEE!!!", TALKTYPE_MONSTER_YELL, false, nil, pos2)
         Game.createMonster("Energized Raging Mage", pos)
     end
     return true
end
Added the code on raging mage
and added too on ragingmage2 i got error raging mage 2, then solved thee error adding that on raging magr2: creature:say and creature so that
function onDeath(creature, corpse, deathList)
creature:say(cid, "I WILL RETURN!! My death will just be a door to await my homecoming, my physical hull will be... my... argh...", TALKTYPE_ORANGE_2)
end

but not don't work and havent error on distro >.<
 
Edit: okey if i kill energized raging mage get the Msg correctly on the portal but they still spawning energized raging mage 1000 time s>.< and if i summon raging mage and kill them the portal not colapse and no msg and no error on distro >.<
so i never get this msg creature:say(cid, "I WILL RETURN!! My death will just be a door to await my homecoming, my physical hull will be... my... argh...", TALKTYPE_ORANGE_2)
i only get that
creature:say("MWAAAHAHAAA!! NO ONE!! NO ONE CAN DEFEAT MEEE!!!", TALKTYPE_MONSTER_YELL, false, 0, pos2)
Game.createMonster("Energized Raging Mage", pos)


>.< with raging mage too only that maybe there is problem missing any file about the zao portal ?
 
Post the error you got. Btw, you can also just do it like this.
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
     creature:say("MWAAAHAHAAA!! NO ONE!! NO ONE CAN DEFEAT MEEE!!!", TALKTYPE_MONSTER_YELL, false, nil, Position(33143, 31527, 2))
     Game.createMonster(math.random(1, 10) == 1 and "Raging Mage" or "Energized Raging Mage", creature:getPosition())
     return true
end
Don't use cid.
 
Post the error you got. Btw, you can also just do it like this.
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
     creature:say("MWAAAHAHAAA!! NO ONE!! NO ONE CAN DEFEAT MEEE!!!", TALKTYPE_MONSTER_YELL, false, nil, Position(33143, 31527, 2))
     Game.createMonster(math.random(1, 10) == 1 and "Raging Mage" or "Energized Raging Mage", creature:getPosition())
     return true
end
Don't use cid.
if i use the last script you gived me, no one mosnter talks >.< no errors on distro :S
i added to the zao collapse portal creaturescript and when i kill the raging mage, it don't say anything and no errors on distro :S
 
Post the error you got. Btw, you can also just do it like this.
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
     creature:say("MWAAAHAHAAA!! NO ONE!! NO ONE CAN DEFEAT MEEE!!!", TALKTYPE_MONSTER_YELL, false, nil, Position(33143, 31527, 2))
     Game.createMonster(math.random(1, 10) == 1 and "Raging Mage" or "Energized Raging Mage", creature:getPosition())
     return true
end
Don't use cid.
if u want limos can use teamwiever if u want bro >.<
 
Do you reload creaturescripts or restart the server? if you reload, try to restart it.
Btw that script is a short version of http://pastebin.com/0kW6Pac3

For the other one.
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
     creature:say("I WILL RETURN!! My death will just be a door to await my homecoming, my physical hull will be... my... argh...", TALKTYPE_MONSTER_YELL)
end
 
Back
Top