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

Lua Script of 1.1 to 1.0

Wake

Member
Joined
Oct 1, 2012
Messages
130
Reaction score
12
Location
São Paulo - Brazil
Hello friends!! can help me? i need this script of adventurers stone of printer datapack
this scripts is 1.1 .. i need 1.0 help me?

local config = {
{fromPos = Position(32953, 32072, 7), toPos = Position(32963, 32081, 7), townId = 1},
{fromPos = Position(32364, 32231, 7), toPos = Position(32374, 32243, 7), townId = 2},
{fromPos = Position(32642, 31921, 11), toPos = Position(32656, 31929, 11), townId = 3},
{fromPos = Position(32356, 31775, 7), toPos = Position(32364, 31787, 7), townId = 4},
{fromPos = Position(32718, 31628, 7), toPos = Position(32736, 31639, 7), townId = 5},
{fromPos = Position(32313, 32818, 7), toPos = Position(32322, 32830, 7), townId = 7},
{fromPos = Position(32590, 32740, 7), toPos = Position(32600, 32750, 7), townId = 8},
{fromPos = Position(33188, 32844, 8), toPos = Position(33201, 32857, 8), townId = 9},
{fromPos = Position(33210, 32450, 1), toPos = Position(33217, 32457, 1), townId = 10},
{fromPos = Position(33208, 31803, 8), toPos = Position(33225, 31819, 8), townId = 11},
{fromPos = Position(32207, 31127, 7), toPos = Position(32218, 31138, 7), townId = 12},
{fromPos = Position(32785, 31274, 7), toPos = Position(32789, 31279, 7), townId = 13},
{fromPos = Position(33018, 31514, 11), toPos = Position(33032, 31531, 11), townId = 14},
{fromPos = Position(33442, 31312, 9), toPos = Position(33454, 31326, 9), townId = 28},
{fromPos = Position(33510, 32360, 6), toPos = Position(33516, 32366, 6), townId = 29}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerPos, isInTemple, temple, townId = player:getPosition(), false
for i = 1, #config do
temple = config
if isInRange(playerPos, temple.fromPos, temple.toPos) then
if Tile(playerPos):hasFlag(TILESTATE_PROTECTIONZONE) then
isInTemple, townId = true, temple.townId
break
end
end
end

if not isInTemple then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Try to move more to the center of a temple to use the spiritual energy for a teleport.')
return true
end

player:setStorageValue(Storage.AdventurersGuild.Stone, townId)
playerPos:sendMagicEffect(CONST_ME_TELEPORT)

local destination = Position(32210, 32300, 6)
player:teleportTo(destination)
destination:sendMagicEffect(CONST_ME_TELEPORT)
return true
end

Thanks o/
 
try
local playerPos, isInTemple, temple, townId = Player(player):getPosition(), false
instead of
local playerPos, isInTemple, temple, townId = player:getPosition(), false
 
Replace:
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerPos, isInTemple, temple, townId = player:getPosition(), false

With:
Code:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local player = Player(cid)
local playerPos, isInTemple, temple, townId = player:getPosition(), false

The thing is that in 1.1 the userdata is pushed as a parameter to the function, while in 1.0 it still pushed uids, like 0.3/0.4 etc.
So if you run into this problem again you have to compile it using the Player(uid) function.
 
Replace:
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerPos, isInTemple, temple, townId = player:getPosition(), false

With:
Code:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local player = Player(cid)
local playerPos, isInTemple, temple, townId = player:getPosition(), false

The thing is that in 1.1 the userdata is pushed as a parameter to the function, while in 1.0 it still pushed uids, like 0.3/0.4 etc.
So if you run into this problem again you have to compile it using the Player(uid) function.

not work http://prntscr.com/6gsk12
 
CANT be same error. because in my version there is no "player" i have Player(player)
unless you changed the function parameter "player" into "cid" and tried my fix with combined WibbenZ fix.. (does not work like dat bro)

Or you failed to save script before opening server.

Either way after you realize what parameter you want to use:
next error fix is:
Player(player):setStorageValue(20000, townId)
instead of
player:setStorageValue(Storage.AdventurersGuild.Stone, townId)

***Storage.AdventurersGuild.Stone - is some kind of number value from global table.
(use any number you want, i used 20000 as example)

Incase you use Wibbenz local player Player(cid), then:
player:setStorageValue(20000, townId)
 
CANT be same error. because in my version there is no "player" i have Player(player)
unless you changed the function parameter "player" into "cid" and tried my fix with combined WibbenZ fix.. (does not work like dat bro)

Or you failed to save script before opening server.

Either way after you realize what parameter you want to use:
next error fix is:
Player(player):setStorageValue(20000, townId)
instead of
player:setStorageValue(Storage.AdventurersGuild.Stone, townId)

***Storage.AdventurersGuild.Stone - is some kind of number value from global table.
(use any number you want, i used 20000 as example)

Incase you use Wibbenz local player Player(cid), then:
player:setStorageValue(20000, townId)

He could use Player(player), that won't thrown an error: https://github.com/otland/forgottenserver/blob/master/src/luascript.cpp#L8251
All it will do is recompile the class.

But now when I read the error image again I noticed the line number, if he dosen't have the storage table thingi then that will be an issue.
I get why the orts~ project made that, to be able to keep track of storages etc. But if you ask me it will just create a mess.
And he should use the variable to store the userdata since the script uses it more the once.
 
Back
Top