johnsamir
Banned User
Hi
the error is this
full error in console:
the scipt is this and is placed at data/scripts/movements/teleport
added this at global.lua and at data/lib/core/player.lua in order to work but it did not fix the error
i used to use this instead but it was causing erors too maybe because it was taken from an old datapack
ideas?
regards
Solution: remove all other codes related to vocations and replace with this one
the error is this
Lua:
attempt to index global 'VOCATION' (a nil value)
Code:
Lua Script Error: [Scripts Interface]
C:\Users\jhon\Desktop\TFS-1.5-7.X\data\scripts\movements\teleport\sorcerer_guild_thais.lua:callback
data/global.lua:305: attempt to index global 'VOCATION' (a nil value)
stack traceback:
[C]: in function '__index'
data/global.lua:305: in function 'isSorcerer'
...data\scripts\movements\teleport\sorcerer_guild_thais.lua:9: in function <...data\scripts\movements\teleport\sorcerer_guild_thais.lua:3>
Code:
local sorcererGuildThais = MoveEvent()
function sorcererGuildThais.onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
if player:isSorcerer() then
return true
end
player:teleportTo(Position(32308, 32267, 7))
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
return true
end
sorcererGuildThais:type("stepin")
sorcererGuildThais:aid(5555)
sorcererGuildThais:register()
added this at global.lua and at data/lib/core/player.lua in order to work but it did not fix the error
Code:
function Player.isSorcerer(self)
return table.contains({VOCATION.ID.SORCERER, VOCATION.ID.MASTER_SORCERER}, self:getVocation():getId())
end
function Player.isDruid(self)
return table.contains({VOCATION.ID.DRUID, VOCATION.ID.ELDER_DRUID}, self:getVocation():getId())
end
function Player.isKnight(self)
return table.contains({VOCATION.ID.KNIGHT, VOCATION.ID.ELITE_KNIGHT}, self:getVocation():getId())
end
function Player.isPaladin(self)
return table.contains({VOCATION.ID.PALADIN, VOCATION.ID.ROYAL_PALADIN}, self:getVocation():getId())
end
function Player.isMage(self)
return table.contains({VOCATION.ID.SORCERER, VOCATION.ID.MASTER_SORCERER, VOCATION.ID.DRUID, VOCATION.ID.ELDER_DRUID},
self:getVocation():getId())
end
Code:
--function isSorcerer(cid)
-- if(isPlayer(cid) == false) then
-- debugPrint("isSorcerer: Player not found.")
-- return false
-- end
-- return (isInArray({1,5}, getPlayerVocation(cid)) == true)
--end
--function isDruid(cid)
-- if(isPlayer(cid) == false) then
-- debugPrint("isDruid: Player not found.")
-- return false
-- end
-- return (isInArray({2,6}, getPlayerVocation(cid)) == true)
--end
--function isPaladin(cid)
-- if(isPlayer(cid) == false) then
-- debugPrint("isPaladin: Player not found.")
-- return false
-- end
-- return (isInArray({3,7}, getPlayerVocation(cid)) == true)
--end
--function isKnight(cid)
-- if(isPlayer(cid) == false) then
-- debugPrint("isKnight: Player not found.")
-- return false
-- end
-- return (isInArray({4,8}, getPlayerVocation(cid)) == true)
--end
ideas?
regards
Post automatically merged:
Solution: remove all other codes related to vocations and replace with this one
Lua:
function Player.isSorcerer(self)
return self:getVocation():getId() == 1 or self:getVocation():getId() == 5
end
function Player.isDruid(self)
return self:getVocation():getId() == 2 or self:getVocation():getId() == 6
end
function Player.isPaladin(self)
return self:getVocation():getId() == 3 or self:getVocation():getId() == 7
end
function Player.isKnight(self)
return self:getVocation():getId() == 4 or self:getVocation():getId() == 8
end
function Player.isPremium(self)
return self:getPremiumDays() > 0 or configManager.getBoolean(configKeys.FREE_PREMIUM)
end
Last edited: