• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Usuwanie ścian

zabka229

New Member
Joined
Dec 30, 2009
Messages
147
Reaction score
0
Witam, mam problem z skryptem usuwającym ścianę. Otóż raz działa, a raz nie.
Czasami ściany się nie respią, a czasami zamiast jednej jest ich kilka.
PHP:
function onUse(cid, item, frompos, item2, topos)
gatepos = {x=389, y=274, z=8, stackpos=1}
getgate = getThingfromPos(gatepos)
local timetocreate = 15
if item.uid == 9908 and item.itemid == 1945 and getgate.itemid == 1025 then
doRemoveItem(getgate.uid,1)
doTransformItem(item.uid,item.itemid+1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You removed the wall.")
local function create(cid)
doCreateItem(1025, gatepos)
                          end
addEvent(create, timetocreate*1000*60, cid)
elseif item.uid == 9908 and item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"The wall is already removed.")
end
return 1
end
 
Code:
local cfg = {
	gatepos = {x=389, y=274, z=8},
	timetocreate = 15
}

function onUse(cid, item, frompos, item2, topos)
	local getgate = getThingfromPos(cfg.gatepos)
	if(item.itemid == 1945 and getgate.itemid == 1025)then --uid jest sprawdzane w actions.xml, pewnie
		doRemoveItem(getgate.uid,1)
		doTransformItem(item.uid,item.itemid+1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You removed the wall.")
		addEvent(doCreateItem, cfg.timetocreate*1000*60, 1025, cfg.gatepos)
	elseif(item.itemid == 1946)then
		doTransformItem(item.uid,item.itemid-1)
	else
		doPlayerSendCancel(cid,"The wall is already removed.")
	end

	return 1
end

?
 
Teraz nie usuwa ściany.
Ściana jest postawiona na mapie, skrypt ją ma usunąć i następnie ma ona wrócić po x minutach.
Uniqueid jest ustawione na dźwignie, sama ściana nie ma żadne actionid'a ani uniqueid'a.
 
Bardzo brzydko. Zamiast getThingfromPos daj getTileItemById(cfg.gatepos, 1025) w warunku nizej zamien getgate.itemid == 1025 na getgate.uid > 0
 
Postanowiłem zmienić skrypt na krótszy, bo miałem kilka takich ścian i do każdej inny skrypt.
Teraz mam taki:
(usuwa ścianę, robi się nowa, tyle że jak 3 raz przesunę dźwignię to zamienia się ona w jakąś ścianę zieloną, tak samo jak spróbuje 2 dżwignię przesunąć, tyle że nie usuwa już ściany a od razu zamienią się w jakąś ścianę)

PHP:
function onUse(cid, item, frompos, item2, topos)
local switchs = 
{
    [9908] = {{x=389, y=274, z=8, stackpos=1}, 1025,2},
    [9909] = {{x=391, y=274, z=8, stackpos=1}, 1025,2},
    [9910] = {{x=293, y=274, z=8, stackpos=1}, 1025,2}
}

    if(not switchs[item.uid]) then
        doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
        return TRUE
    end
    local pos = switchs[item.uid][1]
    local wall = getThingfromPos(pos)
    if(wall.itemid == switchs[item.uid][2]) then
        doRemoveItem(wall.uid, 1)
        doTransformItem(item.uid, item.itemid+1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You removed the wall.")
local function create(cid)
doCreateItem(switchs[item.uid][2], 1, switchs[item.uid][1])
 end
addEvent(create, switchs[item.uid][3]*1000*60, cid)	
    else
        doTransformItem(item.uid, item.itemid-1)
        doPlayerSendCancel(cid,"The wall is already removed.")
    end
    return TRUE
end
 
No pewnie na opak dales dzwignie i z 1946 robi Ci itemid 1947. Najprosciej dla Ciebie bedzie zamienic item.itemid+1 i -1 na to, co juz jest u gory, czyli item.itemid == 1945 and 1946 or 1945
 
To nie była wina dźwigni, w każdym razie zrobiłem to tak:
PHP:
function onUse(cid, item, frompos, item2, topos)
local switchs = 
{
    [9908] = {{x=389, y=274, z=8, stackpos=1}, 1025,2},
    [9909] = {{x=391, y=274, z=8, stackpos=1}, 1025,2},
    [9910] = {{x=393, y=274, z=8, stackpos=1}, 1025,2}
}

    if(not switchs[item.uid]) then
        doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
        return TRUE
    end
    local pos = switchs[item.uid][1]
    local wall = getThingfromPos(pos)
    if(wall.itemid == switchs[item.uid][2]) then
        doRemoveItem(wall.uid, 1)
        doTransformItem(item.uid, item.itemid+1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You removed the wall.")
local function create(cid)
doCreateItem(switchs[item.uid][2], 1, switchs[item.uid][1])
doTransformItem(item.uid, 1945)
end
addEvent(create, switchs[item.uid][3]*1000*60, cid)	
    else
        doPlayerSendCancel(cid,"The wall is already removed.")
    end
    return TRUE
end
Problem jest taki, że tworzy się tylko jedna ściana, ta która jako ostatnią usunęliśmy.
 
okej, dodałem tworzenie ściany, zaraz dodam też tworzenie wielu itemów naraz

- - - Updated - - -

sorry za flejm, tak z przyzwyczajenia

- - - Updated - - -

masz:

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

	local c = {
			[1] = {item_id = 1354, pozycja = {x=1050,y=5000,z=7}, ilosc = 1, efekt_create = 25, efekt_remove = 13},
			[2] = {item_id = 1354, pozycja = {x=1051,y=5000,z=7}, ilosc = 1, efekt_create = 25, efekt_remove = 13},
			[3] = {item_id = 1354, pozycja = {x=1052,y=5000,z=7}, ilosc = 1, efekt_create = 25, efekt_remove = 13},
			}

	local czas_tworzenia_scian = 60 * 1000 --<-- 60 * 1000 = 60 sekund
	local usuniete_sciany = 0
	local stworzone_sciany = 0
	
	local function stworz_sciany_po_czasie()
		for j = 1, #c do
			if getTileItemById(c[j].pozycja, c[j].item_id).uid > 0 then
				stworzone_sciany = stworzone_sciany + 1
				doCreateItem(c[j].item_id, c[j].pozycja)
				doSendMagicEffect(c[j].pozycja, c[j].efekt_create)
			end
		end
	end
	
	if item.itemid == 1945 then 
		for i = 1, #c do
			if getTileItemById(c[i].pozycja, c[i].item_id).uid > 0 then
				usuniete_sciany = usuniete_sciany + 1
				doRemoveThing(getTileItemById(c[i].pozycja, c[i].item_id).uid, c[i].ilosc)
				doSendMagicEffect(c[i].pozycja, c[i].efekt_remove)
			end
		end
		doCreatureSay(cid, "Przesuwajac dzwignie usunales ".. usuniete_sciany .." scian. Odnowia sie po ".. czas_tworzenia_scian/1000 .." sekundach.", TALKTYPE_MONSTER)
		doTransformItem(item.uid, 1946)
		tworzenie_na_nowo = addEvent(stworz_sciany_po_czasie(), czas_tworzenia_scian)
	elseif item.itemid == 1946 then 
		for k = 1, #c do
			if getTileItemById(c[k].pozycja, c[k].item_id).uid > 0 then
				stworzone_sciany = stworzone_sciany + 1
				doCreateItem(c[k].item_id, c[k].pozycja)
				doSendMagicEffect(c[k].pozycja, c[k].efekt_create)
			end
		end
		doCreatureSay(cid, "Przesuwajac dzwignie stworzyles ".. stworzone_sciany .." scian.", TALKTYPE_MONSTER)
		doTransformItem(item.uid, 1945)
		stopEvent(tworzenie_na_nowo)
	end

	return true
end
 
Dzięki, tyle że chodziło o to, że jeden skrypt obsługuje kilka dźwigni, zaś każda dźwignia inny obiekt.
Zrobiłem z twojego pierwszego skryptu, lecz wkradł ci się tam mały błąd z addevent'em.
 
Okey, teraz działa, skrypt:

Lua:
local c = {
                        [1] = {item_id = 1025, pozycja = {x=391,y=274,z=8}, ilosc = 1, efekt_create = 25, efekt_remove = 13},
                        [2] = {item_id = 1025, pozycja = {x=389,y=274,z=8}, ilosc = 1, efekt_create = 25, efekt_remove = 13},
                        [3] = {item_id = 1025, pozycja = {x=393,y=274,z=8}, ilosc = 1, efekt_create = 25, efekt_remove = 13},
                        }
local czas_tworzenia_scian = 5 * 1000 --<-- 60 * 1000 = 60 sekund
local usuniete_sciany = 0
local stworzone_sciany = 0
	function stworz_sciany_po_czasie()
		for j = 1, #c do
			if not(getTileItemById(c[j].pozycja, c[j].item_id).uid > 0) then
				stworzone_sciany = stworzone_sciany + 1
				doCreateItem(c[j].item_id, c[j].pozycja)
				doSendMagicEffect(c[j].pozycja, c[j].efekt_create)
			end
		end
		stworzone_sciany = 0
		return true
	end
	
	
function onUse(cid, item, fromPosition, itemEx, toPosition)

	if item.itemid == 1945 then 
		for i = 1, #c do
			if getTileItemById(c[i].pozycja, c[i].item_id).uid > 0 then
				usuniete_sciany = usuniete_sciany + 1
				doRemoveThing(getTileItemById(c[i].pozycja, c[i].item_id).uid, c[i].ilosc)
				doSendMagicEffect(c[i].pozycja, c[i].efekt_remove)
			end
		end
		doCreatureSay(cid, "Przesuwajac dzwignie usunales ".. usuniete_sciany .." scian. Odnowia sie po ".. czas_tworzenia_scian/1000 .." sekundach.", TALKTYPE_MONSTER)
		doTransformItem(item.uid, 1946)
		tworzenie_na_nowo = addEvent(stworz_sciany_po_czasie, czas_tworzenia_scian)
	elseif item.itemid == 1946 then 
		for k = 1, #c do
			if not(getTileItemById(c[k].pozycja, c[k].item_id).uid > 0) then
				stworzone_sciany = stworzone_sciany + 1
				doCreateItem(c[k].item_id, c[k].pozycja)
				doSendMagicEffect(c[k].pozycja, c[k].efekt_create)
			end
		end
		doCreatureSay(cid, "Przesuwajac dzwignie stworzyles ".. stworzone_sciany .." scian.", TALKTYPE_MONSTER)
		doTransformItem(item.uid, 1945)
		stopEvent(tworzenie_na_nowo)
	end
	stworzone_sciany = 0
	usuniete_sciany = 0
	return true
end
 
Back
Top