What's new

Support Scripts - naprawiamy / tworzymy

Status
Not open for further replies.

Eturl

We shall know no fear!
Joined
May 21, 2008
Messages
2,280
Reaction score
463
Age
32
Odp: Support Scripts - naprawiamy / tworzymy

Temat otwieram na pro?b? autora i przy okazji od?wie?am ;p
 

Loyal The Best

Active User
Joined
Jan 29, 2011
Messages
91
Reaction score
0
Odp: Support Scripts - naprawiamy / tworzymy

Skrypt: Skrypt na " Po lewej stronie jest dzwignia po dr?giej items wajhle przes?wam i teleportuje mnie na dane miejsce oto SCREEN
mlmf07.jpg

I naciskam na wajhle a w konsoli wyskakuje :
rwkym0.jpg

Skrypt:
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

Opis skryptu: Nie teleportuje,
Dodatkowe: Silnik SQL 8.1 B-FoX
 

ErMex

Egzekucja
Joined
Dec 1, 2010
Messages
574
Reaction score
181
Odp: Support Scripts - naprawiamy / tworzymy

#Loyal The Best
Napisa?em, ?e nie robi? skrypt?w pod silniki 8.11+ (Oskar pod te robi?. Ja robi? tylko i wy??cznie pod 8.50+!). Wszystkie twoje pro?by b?d? i tak robi? pod TFS'a.
PHP:
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
Mo?e gdybym mia? funkcje B-FoX... ale nie mam :p

@Down
Ja nie b?d? wyodr?bnia? funkcji, kt?re zosta?y u?yte w jakim? skrypcie...
Ma by? tak ?adniutko:
Code:
	getPlayerAccountId(cid) //TODO
	getPlayerAccount(cid) //TODO
	getPlayerIp(cid) //TODO
	getPlayerFreeCap(cid)
	getPlayerLight(cid)
	getPlayerSlotItem(cid, slot)
 
Last edited:

Loyal The Best

Active User
Joined
Jan 29, 2011
Messages
91
Reaction score
0
@ UP @
Chcesz functions to masz !>
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
Gdzie To mam Wklei??
 
Last edited by a moderator:

dennisek78

Active User
Joined
Oct 6, 2009
Messages
93
Reaction score
1
Odp: Support Scripts - naprawiamy / tworzymy

Typ: Talkactions
Potrzebuj? skryptu gdy tutor i wy?sze rangi napisz? !muted 10 xxx
dzia?a?o by to tak ?e gracz nie m?g?by pisa? nic na helpie przez okre?lony czas lecz tylko na helpie na default by m?g?.
Skrypt jest pod Tibi? 8.54 ;D
Z g?ry dzi?kuje za pomoc ;d
 

ErMex

Egzekucja
Joined
Dec 1, 2010
Messages
574
Reaction score
181
Odp: Support Scripts - naprawiamy / tworzymy

#Loyal The Best
Nie spamuj mi w temacie plax.

#dennisek78
Je?li znajdziesz funkcje daj?c? mute na dany channel oraz na okre?lony czas to podaj i niema problemu - zrobi? Ci. Mo?esz grzeba? nawet w source.
 

Grabek980

Active User
Joined
Nov 17, 2009
Messages
147
Reaction score
5
Odp: Support Scripts - naprawiamy / tworzymy

Rune mo?na kupi? u npc dopiero po zrobieniu questa, dodatkowo chcia?bym ?eby tej runie usuwa?y sie chargesy(w configu ustawione mam ?e sie nie usuwa) i mo?na j? by?o u?ywa? co 20 sekund
 

ErMex

Egzekucja
Joined
Dec 1, 2010
Messages
574
Reaction score
181
Odp: Support Scripts - naprawiamy / tworzymy

#Grabek980

Co do czasu to szczerze Ci powiem, ?e jeszcze w ?adnym skrypcie tym si? nie bawi?em. Tak samo jak usuwaniem run. Prosz? NPC'a:
PHP:
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())
 
Last edited:

tollaks

Advanced User
Joined
Jul 29, 2009
Messages
231
Reaction score
9
Age
30
Odp: Support Scripts - naprawiamy / tworzymy

Typ: Actions
Skrypt polega na tym , ?e gdy naci?niemy na drzewo o ID:2709 przenosi nas na wsp??rz?dne za???my 1000,1000,7, ale chce , aby tylko 1 osoba mog?a przej?? przez te drzewo i ma na wykonanie questu 10min (jest to demon oak).
Pod tfs'a 0.3.6
Albo poprawienie skryptu:
Code:
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
Wywala b??d :
[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>'
 
Last edited:

ErMex

Egzekucja
Joined
Dec 1, 2010
Messages
574
Reaction score
181
Odp: Support Scripts - naprawiamy / tworzymy

#tollaks

Robi?em to pod Demon Oaka czyli gracz musi sta? 1 kratk? nad drzewem.
PHP:
-- 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
Je?li zale?y Ci na wiadomo?ci typu "Zosta?o Ci xx czasu" to napisz. Po prostu nie zrobi?em tego bo nie mia?em z tym jeszcze do czynienia.
 
Status
Not open for further replies.
Top