What's new

Skrypty & Kody Problem ze skryptem teleportacji

Status
Not open for further replies.

Cebal

Active User
Joined
Dec 23, 2008
Messages
62
Reaction score
0
Witam wszystkich. Od pewnego czasu posiadam skrypt polegaj?cy na teleportacji postaci jak i celu w pewne miejsce, jednak?e w silniku pojawiaj? si? b??dy i skrypt ten nie dzia?a tak jak powinien. Zak?adaj?c ten temat licze, ?e uda znale?? mi si? jakie? rozwi?zanie. By?bym naprawd? wdzi?czny za pomoc z Waszej strony.
Skrypt i b??dy podaj? poni?ej.

Skrypt wygl?da tak:
Code:
function onCastSpell(cid, words, param)
local waittime = 5 -- exhaust time
local storage = 5560
local pos = getCreaturePosition(cid)
from = {x=pos.x, y=pos.y, z=pos.z}
to = {x = 1235, y = 772, z = 7} -- where tp (players)
to1 = {x = 1235, y = 773, z = 7} -- where tp(caster)
area1 = {x = 1231, y = 769, z = 7} -- top edge
area2 = {x = 1239, y = 775, z = 7} -- lower edge
level = 10 -- Level needed
ppos = getCreaturePosition(cid)
pl1 = {x=ppos.x-7, y=ppos.y-5, z=ppos.z}
pl2 = {x=ppos.x+7, y=ppos.y+5, z=ppos.z}

if getPlayerLevel(cid) < level then
doPlayerSendCancel(cid, "U need lvl.")
return true
end


function back(cid)
if isInArea(getCreaturePosition(cid), area1, area2) then
doTeleportThing(cid, from)
end
end

function go(cid)
if isInArea(getCreaturePosition(cid), pl1, pl2) then
doTeleportThing(cid, to)
end
end

function gos(cid)
if isInArea(getCreaturePosition(cid), from, from) then
doTeleportThing(cid, to1)
end
end

if exhaustion.check(cid, storage) == false then
for _, pid in ipairs(getPlayersOnline()) do
addEvent(back, 5000, pid) -- time to return to the place that used spell
addEvent(go, 200, pid)
addEvent(gos, 1, pid)
doSendMagicEffect(getCreaturePosition(pid), 63)
doCreatureSay(pid, "now u telep!", TALKTYPE_MONSTER) --- Mensagem
addEvent(setPlayerStorageValue, 10000, pid, 1634, -1) 
end

exhaustion.set(cid, storage, waittime)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "you must wait  " .. exhaustion.get(cid, storage) .. " second to use it again.")
end
return true
end


B??dy po u?yciu spella:
Code:
[18/11/2014 19:43:53] [Error - Spell Interface] 
[18/11/2014 19:43:53] In a timer event called from: 
[18/11/2014 19:43:53] data/spells/scripts/attack/tp.lua:onCastSpell
[18/11/2014 19:43:53] Description: 
[18/11/2014 19:43:53] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value)
[18/11/2014 19:43:53] stack traceback:
[18/11/2014 19:43:53] 	data/lib/032-position.lua:2: in function 'isInArea'
[18/11/2014 19:43:53] 	data/spells/scripts/attack/tp.lua:34: in function <data/spells/scripts/attack/tp.lua:33>

[18/11/2014 19:43:53] [Error - Spell Interface] 
[18/11/2014 19:43:53] In a timer event called from: 
[18/11/2014 19:43:53] data/spells/scripts/attack/tp.lua:onCastSpell
[18/11/2014 19:43:53] Description: 
[18/11/2014 19:43:53] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value)
[18/11/2014 19:43:53] stack traceback:
[18/11/2014 19:43:53] 	data/lib/032-position.lua:2: in function 'isInArea'
[18/11/2014 19:43:53] 	data/spells/scripts/attack/tp.lua:28: in function <data/spells/scripts/attack/tp.lua:27>

[18/11/2014 19:43:58] [Error - Spell Interface] 
[18/11/2014 19:43:58] In a timer event called from: 
[18/11/2014 19:43:58] data/spells/scripts/attack/tp.lua:onCastSpell
[18/11/2014 19:43:58] Description: 
[18/11/2014 19:43:58] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value)
[18/11/2014 19:43:58] stack traceback:
[18/11/2014 19:43:58] 	data/lib/032-position.lua:2: in function 'isInArea'
[18/11/2014 19:43:58] 	data/spells/scripts/attack/tp.lua:22: in function <data/spells/scripts/attack/tp.lua:21>

Pozdrawiam.
 

Ciamciaj Bigos

&#3585;&#3657;&#3657;&#3657;&#3657;&#3657;&#3657;&
Joined
Jun 6, 2013
Messages
2,081
Reaction score
192
Odp: Problem ze skryptem teleportacji

a co ty chcesz dokonac?:D
czar ktory teleportuje wszystkich online do pewnego miejsca?XD
 

Cebal

Active User
Joined
Dec 23, 2008
Messages
62
Reaction score
0
Odp: Problem ze skryptem teleportacji

Przenie?? siebie i cel w 1 miejsce, po 2 sekundach powr?ci? do miejsca, z kt?rego u?y?em spella. Tak to ma dzia?a?.
 

Ciamciaj Bigos

&#3585;&#3657;&#3657;&#3657;&#3657;&#3657;&#3657;&
Joined
Jun 6, 2013
Messages
2,081
Reaction score
192
Odp: Problem ze skryptem teleportacji

[lua]local function back(cid, oldPos, ToldPos, target)
doTeleportThing(cid, oldPos)
doTeleportThing(target, ToldPos)
return true
end

function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
local pos = {x=1000, y=1000, z=7}
local Tpos = {x=1001, y=1001, z=7}
local oldPos = getCreaturePosition(cid)
local ToldPos = getCreaturePosition(target)
doTeleportThing(cid, pos)
doTeleportThing(target, Tpos)
addEvent(back, 5000, cid, oldPos, ToldPos, target)
return true
end[/lua]
 
Status
Not open for further replies.
Top