• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Jak z tego dobrze korzystać

The_Hide

Banned User
Joined
Dec 11, 2012
Messages
389
Reaction score
10
Okey, np. mamy actions i pick i jest:

LUA:
function onUse(...)
	return TOOLS.PICK(...)
end

to się odnosi do actions/lib

LUA:
TOOLS = {}

TOOLS.PICK = function(cid, item, fromPosition, itemEx, toPosition)
	errors(false)
	local ground = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_GROUND})
	errors(true)
	if(isInArray(SPOTS, ground.itemid) and isInArray({354, 355}, itemEx.itemid)) then
		doTransformItem(itemEx.uid, 392)
		doDecayItem(itemEx.uid)

		doSendMagicEffect(toPosition, CONST_ME_POFF)
		return true
	end

	if(itemEx.itemid == 7200) then
		doTransformItem(itemEx.uid, 7236)
		doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
		return true
	end

	return false
end



Czy w podobny sposób mógłbym zaimplantować kod do npc? Tylko nie chcę całego npc'a tylko chodzi mi o fragment kodu, jak to zrobić.

Np.:


LUA:
if(msgcontains(msg, 'soft') or msgcontains(msg, 'boots')) then
		selfSay('Do you want to repair your worn soft boots for 10000 gold coins?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(getPlayerItemCount(cid, 6530) >= 1) then
			if(doPlayerRemoveMoney(cid, 10000)) then
				local item = getPlayerItemById(cid, true, 6530)
				doTransformItem(item.uid, 6132)
				selfSay('Here you are.', cid)
			else
				selfSay('Sorry, you don\'t have enough gold.', cid)
			end
		elseif(getPlayerItemCount(cid, 10021) >= 1) then
			if(doPlayerRemoveMoney(cid, 10000)) then
				local item = getPlayerItemById(cid, true, 10021)
				doTransformItem(item.uid, 6132)
				selfSay('Here you are.', cid)
			else
				selfSay('Sorry, you don\'t have enough gold.', cid)
			end
		else
			selfSay('Sorry, you don\'t have the item.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
	end


Chciałbym ten kod mieć w wielu NPC, ale każdy NPC miałby też inne rozmowy i funkcje... i pytanie czy mogę zrobić tak:


NPC_TABLICZKA = {}

NPC_TABLICZKA.SOFT_BOOTS = {

i tutaj skrypt powyżej dany

}


to potem mogę w skrypcie npc'ta zrobić

NPC_TABLICZKA.SOFT_BOOTS(...)


?? tylko jak zrobić poprawnie, bo nie tylko ma działać na 1 rzecz jak pick, tylko na parę ;/
 
Zalezy w jaki sposob to chcesz wykonywac, jezeli jako funkcje to przekaz msg i cida do niej i reszte operacji tam wykonaj, poza tym definiowanie talkUser jest chyba troche zbedne skoro i tak nikt nie korzysta z kolejkowej rozmowy z NPC i tak :p
 
Back
Top