function onUse(cid, item, fromPosition, itemEx, toPosition)
local cfg = {
pozycja_itemu = {x=463, y=358, z=7, stackpos=255}, -- ustawiasz gdzie kladziemy blood orb
id_itemu = 2363, -- id itemu ktory musimy polozyc
gdzie_teleportuje = {x=465, y=358, z=7} -- gdzie nas teleportuje
}
getitem = getThingFromPos(cfg.pozycja_itemu)
if getitem.itemid == cfg.id_itemu then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Zostajesz teleportowany na expowisko.")
doTeleportThing(cid, cfg.gdzie_teleportuje)
doSendMagicEffect(cfg.gdzie_teleportuje, 10)
doRemoveItem(getitem.uid)
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Poloz pierw "..getItemNameById(cfg.id_itemu)..".")
end
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cfg = {
pozycja_itemu = {x=163, y=372, z=7, stackpos=255}, -- ustawiasz gdzie kladziemy blood orb
id_itemu = 2363, -- id itemu ktory musimy polozyc
gdzie_teleportuje = {x=163, y=377, z=7} -- gdzie nas teleportuje
}
getitem = getThingFromPos(cfg.pozycja_itemu)
if getitem.itemid == cfg.id_itemu then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Zostajesz teleportowany na expowisko.")
doTeleportThing(cid, cfg.gdzie_teleportuje)
doSendMagicEffect(cfg.gdzie_teleportuje, 10)
doRemoveItem(getitem.uid)
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Poloz pierw "..getItemNameById(cfg.id_itemu)..".")
end
return true
end
getPlayerAccountId(cid) //TODO
getPlayerAccount(cid) //TODO
getPlayerIp(cid) //TODO
getPlayerFreeCap(cid)
getPlayerLight(cid)
getPlayerSlotItem(cid, slot)
Gdzie To mam Wklei??function doPlayerGiveItem(cid, itemid, count, charges)
local hasCharges = (isItemRune(itemid) == TRUE or isItemFluidContainer(itemid) == TRUE)
if(hasCharges and charges == nil) then
charges = 1
end
while count > 0 do
local tempcount = 1
if(hasCharges) then
tempcount = charges
end
if(isItemStackable(itemid) == TRUE) then
tempcount = math.min (100, count)
end
local ret = doPlayerAddItem(cid, itemid, tempcount)
if(ret == LUA_ERROR) then
ret = doCreateItem(itemid, tempcount, getPlayerPosition(cid))
end
if(ret ~= LUA_ERROR) then
if(hasCharges) then
count = count-1
else
count = count-tempcount
end
else
return LUA_ERROR
end
end
return LUA_NO_ERROR
end
function doPlayerTakeItem(cid, itemid, count)
if(getPlayerItemCount(cid,itemid) >= count) then
while count > 0 do
local tempcount = 0
if(isItemStackable(itemid) == TRUE) then
tempcount = math.min (100, count)
else
tempcount = 1
end
local ret = doPlayerRemoveItem(cid, itemid, tempcount)
if(ret ~= LUA_ERROR) then
count = count-tempcount
else
return LUA_ERROR
end
end
if(count == 0) then
return LUA_NO_ERROR
end
else
return LUA_ERROR
end
end
function doMovePlayerToPosition(cid, posx, posy, posz)
playerpos = getPlayerPosition(cid)
direction = NORTH
if playerpos.x == posx - 1 and playerpos.y == posy and playerpos.z == posz then
direction = EAST
elseif playerpos.x == posx + 1 and playerpos.y == posy and playerpos.z == posz then
direction = WEST
elseif playerpos.x == posx and playerpos.y == posy - 1 and playerpos.z == posz then
direction = SOUTH
elseif playerpos.x == posx and playerpos.y == posy + 1 and playerpos.z == posz then
direction = NORTH
elseif playerpos.x == posx - 1 and playerpos.y == posy - 1 and playerpos.z == posz then
direction = SOUTHEAST
elseif playerpos.x == posx + 1 and playerpos.y == posy + 1 and playerpos.z == posz then
direction = NORTHWEST
elseif playerpos.x == posx + 1 and playerpos.y == posy - 1 and playerpos.z == posz then
direction = SOUTHWEST
elseif playerpos.x == posx - 1 and playerpos.y == posy + 1 and playerpos.z == posz then
direction = NORTHEAST
end
doMovePlayer(cid,direction)
return 1
end
function getPlayerExhaust(player,number,time)
if os.difftime(os.time(), getPlayerStorageValue(player,number)) > 0 then
setPlayerStorageValue(player,number,os.time()+time)
return 1
else
return -1
end
end
function doPlayerAddMoney(cid, amount)
local crystals = math.floor(amount/10000)
amount = amount - crystals*10000
local platinum = math.floor(amount/100)
amount = amount - platinum*100
local gold = amount
local ret = 0
if(crystals > 0) then
ret = doPlayerGiveItem(cid, ITEM_CRYSTAL_COIN, crystals)
if(ret ~= LUA_NO_ERROR) then
return LUA_ERROR
end
end
if(platinum > 0) then
ret = doPlayerGiveItem(cid, ITEM_PLATINUM_COIN, platinum)
if(ret ~= LUA_NO_ERROR) then
return LUA_ERROR
end
end
if(gold > 0) then
ret = doPlayerGiveItem(cid, ITEM_GOLD_COIN, gold)
if(ret ~= LUA_NO_ERROR) then
return LUA_ERROR
end
end
return LUA_NO_ERROR
end
function doPlayerBuyItem(cid, itemid, count, cost, charges)
if(doPlayerRemoveMoney(cid, cost) == TRUE) then
return doPlayerGiveItem(cid, itemid, count, charges)
else
return LUA_ERROR
end
end
function doPlayerSellItem(cid, itemid, count, cost)
if(doPlayerTakeItem(cid, itemid, count) == LUA_NO_ERROR) then
if(doPlayerAddMoney(cid, cost) ~= LUA_NO_ERROR) then
error('Could not add money to ' .. getPlayerName(cid) .. '(' .. cost .. 'gp)')
end
return LUA_NO_ERROR
else
return LUA_ERROR
end
end
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
function isPremium(cid)
if isPlayer(cid) == TRUE and getPlayerPremiumDays(cid) > 0 then
return TRUE
end
return FALSE
end
function isPlayerOnPos(pos)
local pos2 = pos
pos2.stackpos = 253
local thing = getThingfromPos(pos2)
if(thing ~= nil and thing.itemid > 0) then
if(isPlayer(thing.uid)) then
return true
end
end
return false
end
function getLevelExperience(level)
local experience = (50 * level * level * level) / 3 - 100 * level * level + (850 * level) / 3 - 200
return experience
end
function doPlayerAddLevel(cid, newLevel)
local level = getPlayerLevel(cid)
local playerExp = getLevelExperience(level)
local newExp = getLevelExperience(level + newLevel)
local expToAdd = newExp - playerExp
doPlayerAddExp(cid, expToAdd)
return 1
end
function doRepeatMessage(cid, msg, delay, repeattimes)
function createMessage(parameters)
local cid = parameters.cid
local msg = parameters.msg
doPlayerSendTextMessage(cid, 22, msg)
end
repeat
local parameters = {cid = cid, msg = msg}
addEvent(createMessage, delay * repeattimes, parameters)
repeattimes = repeattimes - 1
until repeattimes == 0
end
function ucwords(words)
local wordsArray = nil
for word in string.gmatch(words, "%a+") do
newWord = string.upper(string.sub(word, 0, 1)) .. string.sub(word, 2)
if wordsArray then
wordsArray = wordsArray .. " " .. newWord
else
wordsArray = newWord
end
end
return wordsArray
end
function doPlayerAddSummon(cid, name, pos)
local MyCreature = doSummonCreature(name, pos)
doConvinceCreature(cid, MyCreature)
return MyCreature
end
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
local cfg = {
storage = 2452, -- zmien sobie
id_runy = 2263, -- id runki
cena = 100 -- cena runy w tym wypadku 100 gp
}
if msgcontains(msg, 'runa') then
if getPlayerStorageValue(cid, cfg.storage) == 1 then
if getPlayerMoney(cid) >= cfg.cena then
doPlayerAddItem(cid, cfg.id_runy)
selfSay("Otrzymujesz "..getItemNameById(cfg.id_runy)..".", cid)
doPlayerRemoveMoney(cid, cfg.cena)
elseif getPlayerMoney(cid) < cfg.cena then
selfSay("Aby zakupic rune potrzebujesz "..cfg.cena.."gp.", cid)
else
selfSay('Nie ukonczyles questu!', cid)
doPlayerSetStorageValue(cid, cfg.storage, 1)
end
end
return true
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
function onUse(cid, item, frompos, item2, topos)
local pos = getPlayerPosition(cid)
local door_id = [COLOR="Red"]2709[/COLOR] [COLOR="Red"][B]-----Prosz? o przerobienie na drzewo a nie na drzwi.[/B][/COLOR]
local door_uid = 59813
local strona_swiata = dol
local start_pos = {x=408,y=1025,z=7}
local numer_questa = 4321
local efekt = 12
if item.itemid == door_id and item.uid == door_uid then
if getPlayerStorageValue(cid,numer_questa) < 1 then
if item.actionid == 0 then
if os.time == 0 then
doSendMagicEffect(pos,efekt)
if strona_swiata == 'gora' then
doTeleportThing(cid,{x=pos.x,y=pos.y+2,z=pos.z})
elseif strona_swiata == 'dol' then
doTeleportThing(cid,{x=pos.x,y=pos.y-2,z=pos.z})
elseif strona_swiata == 'lewo' then
doTeleportThing(cid,{x=pos.x-2,y=pos.y,z=pos.z})
elseif strona_swiata == 'prawo' then
doTeleportThing(cid,{x=pos.x+2,y=pos.y,z=pos.z})
else
print('TimeQuest: Niepoprawna strona_swiata!')
end
doSendMagicEffect(pos,efekt)
setItemActionId(item.uid,1)
doPlayerSendTextMessage(cid,22,'Masz 10 minut!')
elseif os.time == 60 then
doPlayerSendTextMessage(cid,22,'Masz jeszcze 4 minuty!')
elseif os.time == 120 then
doPlayerSendTextMessage(cid,22,'Masz jeszcze 3 minuty!')
elseif os.time == 180 then
doPlayerSendTextMessage(cid,22,'Masz jeszcze 2 minuty!')
elseif os.time == 240 then
doPlayerSendTextMessage(cid,22,'Masz tylko 1 minute!')
elseif os.time == 600 then
doTeleportThing(cid,start_pos)
setItemActionId(item.uid,0)
end
else
doPlayerSendTextMessage(cid,22,'Ktos wlasnie robi tego
questa. Poczekaj az skonczy.')
end
else
doPlayerSendTextMessage(cid,22,'Wykonales juz tego questa!')
end
end
[23/06/2010 14:21:45] [Error - LuaScriptInterface::loadFile] data/actions/scripts/timequest.lua:49: 'end' expected (to close 'function' at line 4) near '<eof>'
[23/06/2010 14:21:45] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/timequest.lua)
[23/06/2010 14:21:45] data/actions/scripts/timequest.lua:49: 'end' expected (to close 'function' at line 4) near '<eof>'
-- By ErMex
-- http://tibia.net.pl/members/ermex.html
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cfg = {
czas = 10, -- podaj czas w minutach po ktorym ktos bedzie mogl wejsc do srodka
efekt = 2, -- efekt po nacisnieciu drzewka
gdzie_tp = {x=194, y=1941, z=7}, -- gdzie ma teleportowac osobe ktora jest aktualnie w srodku po skonczeniu sie czasu
global_storage = 3341 -- nie zmieniaj :P
}
local pos = getPlayerPosition(cid)
if getGlobalStorageValue(cfg.global_storage) == -1 then
doTeleportThing(cid,{x=pos.x,y=pos.y+2,z=pos.z})
setGlobalStorageValue(cfg.global_storage, 1)
addEvent(setGlobalStorageValue, cfg.czas * 60 * 1000, cfg.global_storage, -1)
addEvent(doTeleportThing, cfg.czas * 60 * 1000, cid, cfg.gdzie_tp)
doSendMagicEffect(pos, cfg.efekt)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Masz "..cfg.czas.." minut!")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Ktos wlasnie robi tego questa. Poczekaj az skonczy.")
end
return true
end