Kod PHP:
-- By Tako Dako AKA Avixu
-- Wersja finalna
local config = {
-- Teleportacja tylko pod warunkiem, ze nie ma battle
-- 0 = Nie, 1 = Tak
teleportOnlyIfNoBattle = 1,
-- Teleportacja do temple (jesli nie, podaj pozycje nizej)
-- 0 = Nie, 1 = Tak
teleportToTemple = 1,
-- Teleportacja do okreslonej pozycji
teleportPosition = { x=95, y=95, z=7 },
-- Czy ma sie konczyc
-- 0 = Nie, 1 = Tak
removeItem = 1,
-- Efekt magiczny w miejscu uzycia
-- Numerek lub nazwa z constanta
startMagicEffect = 2,
-- Efekt magiczny w miejscu przeteleportowania
-- Numerek lub nazwa z constanta
destinationMagicEffect = 10,
-- Wiadomosc przy probie teleportacji z battle
-- Numerek lub nazwa z constanta albo wlasna
-- wiadomosc (musi byc w cudzyslowiach)
errorMessage = "You may not use teleportation while you have battle!"
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if config.teleportOnlyIfNoBattle == 1 then -- jesli ma teleportowac tylko bez battle
if getCreatureCondition(cid, 1024) == FALSE then -- jesli nie ma battle
if config.teleportToTemple == 1 then -- jesli ma teleportowac do temple
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) -- teleportuj do temple
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), config.destinationMagicEffect) -- daj efekt na miejscu
doSendMagicEffect(toPosition, config.startMagicEffect) -- daj efekt na poczatku
elseif config.teleportToTemple == 0 then -- jesli ma teleportowac w okreslone miejsce
doTeleportThing(cid, config.teleportPosition) -- teleportuj do temple
doSendMagicEffect(getCreaturePosition(cid), config.destinationMagicEffect) -- daj efekt na miejscu
doSendMagicEffect(toPosition, config.startMagicEffect) -- daj efekt na poczatku
end -- koniec 'jesli ma teleportowac do temple'
if config.removeItem == 1 then -- jesli ma sie konczyc
doRemoveItem(item.uid, 1) -- usun item
else -- inaczej
return FALSE -- nie rob nic
end -- koniec 'jesli ma sie konczyc'
elseif getCreatureCondition(cid, 1024) == TRUE then -- jesli ma battle
doPlayerSendCancel(cid, config.errorMessage) -- wyslij graczowi komunikat o bledzie
end -- koniec jesli ma battle
elseif config.teleportOnlyIfNoBattle == 0 then -- jesli ma teleportowac zawsze
if config.teleportToTemple == 1 then -- jesli ma teleportowac do temple
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) -- teleportuj do temple
doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), config.destinationMagicEffect) -- daj efekt na miejscu
doSendMagicEffect(toPosition, config.startMagicEffect) -- daj efekt na poczatku
elseif config.teleportToTemple == 0 then -- jesli ma teleportowac w okreslone miejsce
doTeleportThing(cid, config.teleportPosition) -- teleportuj do pozycji
doSendMagicEffect(getCreaturePosition(cid), config.destinationMagicEffect) -- daj efekt na miejscu
doSendMagicEffect(toPosition, config.startMagicEffect) -- daj efekt na poczatku
end -- koniec jesli ma teleportowac zawsze
if config.removeItem == 1 then -- jesli ma sie konczyc
doRemoveItem(item.uid, 1) -- usun item
else -- inaczej
return FALSE -- nie rob nic
end -- koniec 'jesli ma sie konczyc'
end -- koniec 'jesli ma teleportowac tylko bez battle'
end -- koniec funkcji onUse
O wiele krótsza i łatwiejsza do edycji.
Kod PHP:
-- Item teleporting to temple by Avixu
-- Dedicated for TFS 0.3.5PL2
local config = {
teleportOnlyIfNoBattle = 1,
teleportToTemple = 1, -- set on 0 if you want to use own position (teleportPosition)
teleportPosition = { x=95, y=95, z=7 },
removeItem = 1,
startMagicEffect = 2,
destinationMagicEffect = 10,
haveBattleMessage = "You may not use teleportation while you have battle!",
minLevel = 100, -- set on 0 to disable
levelTooLowMessage = "Your level is too low."
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if config.teleportOnlyIfNoBattle == 1 then
if getCreatureCondition(cid, 1024) == TRUE then
doPlayerSendCancel(cid, config.haveBattleMessage)
return FALSE
end
end
if config.minLevel > 0 then
if getPlayerLevel(cid) < config.minLevel then
doPlayerSendCancel(cid, config.levelTooLowMessage)
return FALSE
end
end
if config.teleportToTemple == 1 then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
else
doTeleportThing(cid, config.teleportPosition)
end
doSendMagicEffect(getCreaturePosition(cid), config.destinationMagicEffect)
doSendMagicEffect(toPosition, config.startMagicEffect)
if config.removeItem == 1 then
doRemoveItem(item.uid, 1)
end
end
Zakładki