What's new

Skrypty & Kody Zamiast zamiany, by mia? usuwa?

Status
Not open for further replies.

mial123

Advanced User
Joined
Apr 2, 2009
Messages
307
Reaction score
24
Witam, jak przerobi? ten skryp ?eby zamiast zamiany usuwa? dany obiekt? + dodanie do niego czas?wki, naprzyk??d musisz odczeka? 5sec ?eby zn?w poci?gna? dzwignie. [LUA]function onUse(cid, item, fromPosition, itemEx, toPosition)

--USTAWIENIA--

local most = 7594 -- id itemu kratki mostu. // trawa

local item = 7594 -- id itemu kratki transformacji po danym czasie. // woda


local czas = 2*1000 -- czas po ktorym ma zniknac most // 30*1000 = 30 sec - 1*60*1000 = 1 min

local pos = {{x = 986, y = 1029, z = 7}, {x = 986, y = 1030, z = 7}, {x = 086, y = 1028, z = 7}} -- pozycja mostu mozna dodawac nowe: ", {x = 1010, y = 1017, z = 6}".

--KONIEC USTAWIEN--

for i = 1, #pos do

doCreateItem(most, pos)
addEvent(doCreateItem, czas, item, pos)

for b = 2, 3 do

doSendMagicEffect(pos, b)

addEvent(doSendMagicEffect, czas, pos, b)

end

end

return true

end

[/LUA]
 

misztrz440

Banned
Joined
Dec 15, 2012
Messages
1,032
Reaction score
39
Odp: Zamiast zamiany, by mia? usuwa?

Na usuwanie takie co? :
[LUA] doRemoveItem(most.uid, pos)[/LUA]

Co do czasu to trzeba "exhausted" zrobi? z innego skryptu wzi??.
 

mial123

Advanced User
Joined
Apr 2, 2009
Messages
307
Reaction score
24
Odp: Zamiast zamiany, by mia? usuwa?

Jakby to by?o takie proste :D Mam b?ad: attempt to index local 'most' (a number value)
 

kamioool

Active User
Joined
Oct 18, 2008
Messages
102
Reaction score
5
Odp: Zamiast zamiany, by mia? usuwa?

http://otland.net/threads/removing-walls-with-time.55737/
 

mial123

Advanced User
Joined
Apr 2, 2009
Messages
307
Reaction score
24
Odp: Zamiast zamiany, by mia? usuwa?

Wmiare, ogarna?em, i mam jedno pytanie, czy da si? na niego na?o?y? zabezpieczenie przeciw przesuwaniu d?wigni, poniewa? error bedzie wyskakiwa? jak klikniemy 2x
PHP:
function del(pos, id)
	local thing = getTileItemById(pos, id).uid
	if thing > 0 then
		doRemoveItem(thing)
	end
end

function reset_walls(pos, id)
	local thing = getTileItemById(pos, id).uid
	if thing < 1 then
		doCreateItem(id, 1, pos)
	end
end

function reset_lever(pos)
	local lev = getTileItemById(pos, 1946).uid
	if lev > 0 then
		doTransformItem(lev, 1945)
	end
end

local eventLever = 0
local eventDel = {}
local eventReset = {}

local pause = 1000 -- 5 sec.
local reset_after = 60 * 1000 -- 60 seconds
local wall_id = 1304 -- itemid of the walls
local walls = { -- wall positions
	{x=1007, y=1007, z=7},
	{x=1006, y=1008, z=7}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		doTransformItem(item.uid, 1946)
		for i  = 1, #walls do
			eventDel[i] = addEvent(del, pause * i, walls[i], wall_id)
			eventReset[i] = addEvent(reset_walls, reset_after + pause * i, walls[i], wall_id)
		end
		eventLever = addEvent(reset_lever, reset_after + pause * #walls, fromPosition)
	elseif item.itemid == 1946 then
		stopEvent(eventLever)
		for i = 1, #eventDel do
			stopEvent(eventDel[i])
		end
		for i = 1, #eventReset do
			stopEvent(eventReset[i])
		end
		for i = 1, #walls do
			reset_walls(walls[i], id)
		end
		doTransformItem(item.uid, 1945)
	end
	return true
end

---------- Tre?? dodana o 16:29 ----------

Znalaz?em inny do?? prosty skrypt, da?o by rade doda? do niego czas po kt?rym kamie? pojawia si? automatycznie?
[LUA]function onUse(cid, item, fromPosition, itemEx, toPosition)
local gatePosition = {x=1007, y=1007, z=7, stackpos=1}
local getgate = getThingfromPos(gatePosition)
if(item.uid == 10204 and item.itemid == 1945 and getgate.itemid == 1304) then
doRemoveItem(getgate.uid, 1)
doTransformItem(item.uid, item.itemid+1)
elseif(item.uid == 10204 and item.itemid == 1946 and getgate.itemid == 0) then
doCreateItem(1304, 1, gatePosition)
doTransformItem(item.uid, item.itemid-1)
else
doPlayerSendCancel(cid, "Sorry not possible.")
end
return TRUE
end
[/LUA]

---------- Tre?? dodana o 16:44 ----------

Mam pasuj?cy mi skrpt, jak doda? do niego kod z czekaniem 5sec na poci?gni?cie d?wigni?
[lua]local event=0

local function reset(p)
doCreateItem(1304, 1, {x=1007, y=1007, z=7})
doTransformItem(getTileItemById(p, 1946).uid, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1945 then
doRemoveItem(getTileItemById({x=1007, y=1007, z=7}, 1304).uid)
doTransformItem(item.uid, 1946)
event=addEvent(reset, 1800, fromPosition)
else
stopEvent(event)
reset(fromPosition)
end
return true
end
[/lua]
 
Last edited:

DanJ93

ElfBot Helper
Joined
Jan 18, 2009
Messages
2,631
Reaction score
200
Odp: Zamiast zamiany, by mia? usuwa?

[lua] if getPlayerStorageValue(cid, 2700) <= os.time() then
local kk = os.time()+2
setPlayerStorageValue(cid, 2700, kk)
[...]
else
doPlayerSendCancel(cid, "You are exhausted.")
doSendMagicEffect(getCreaturePosition(cid), 2)
end[/lua]
 

Ciamciaj Bigos

&#3585;&#3657;&#3657;&#3657;&#3657;&#3657;&#3657;&
Joined
Jun 6, 2013
Messages
2,081
Reaction score
192
Odp: Zamiast zamiany, by mia? usuwa?

[lua]local event=0

local function reset(p)
doCreateItem(1304, 1, {x=1007, y=1007, z=7})
doTransformItem(getTileItemById(p, 1946).uid, 1945)
end

local storage = 6969
local time = 5
local function Exh(cid, storage)
if(os.time() > getPlayerStorageValue(cid, storage)) then
return false
end
return true
end

local function addExh(cid, storage, time)
setPlayerStorageValue(cid, storage, os.time() + time)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(Exh(cid, storage)) then
return doPlayerSendCancel(cid, "You are exhausted.") and false
end
addExh(cid, storage, time)
if item.itemid == 1945 then
doRemoveItem(getTileItemById({x=1007, y=1007, z=7}, 1304).uid)
doTransformItem(item.uid, 1946)
event=addEvent(reset, 1800, fromPosition)
else
stopEvent(event)
reset(fromPosition)
end
return true
end[/lua]
 

DanJ93

ElfBot Helper
Joined
Jan 18, 2009
Messages
2,631
Reaction score
200
Odp: Zamiast zamiany, by mia? usuwa?

[lua]local event=0

local function reset(p)
doCreateItem(1304, 1, {x=1007, y=1007, z=7})
doTransformItem(getTileItemById(p, 1946).uid, 1945)
end

local storage = 6969
local time = 5
local function Exh(cid, storage)
if(os.time() > getPlayerStorageValue(cid, storage)) then
return false
end
return true
end

local function addExh(cid, storage, time)
setPlayerStorageValue(cid, storage, os.time() + time)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(Exh(cid, storage)) then
return doPlayerSendCancel(cid, "You are exhausted.") and false
end
addExh(cid, storage, time)
if item.itemid == 1945 then
doRemoveItem(getTileItemById({x=1007, y=1007, z=7}, 1304).uid)
doTransformItem(item.uid, 1946)
event=addEvent(reset, 1800, fromPosition)
else
stopEvent(event)
reset(fromPosition)
end
return true
end[/lua]
Niepotrzebnie pisa? funkcj? kt?ra zostanie u?yta tylko raz.
 

mial123

Advanced User
Joined
Apr 2, 2009
Messages
307
Reaction score
24
Odp: Zamiast zamiany, by mia? usuwa?

Dzieki dzia?a, a istnieje mo?liwo?? dodania ?e nie da si? ruszy? d?wigni? przez ten czas?
 
Last edited:

Khuznath

Active User
Joined
Jun 26, 2014
Messages
69
Reaction score
7
Odp: Zamiast zamiany, by mia? usuwa?

Wystarczy da? return true w funkcji onUse to si? ruszy lub return false to si? nie ruszy, proste.
 
Status
Not open for further replies.
Top