• 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!

Need scripts... [Actions]

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
671
Hello,
I requesting to good souls guy to make me some scripts.

1) Three players stand at required 3 places and if put on the lever the players will be teleported (like annihilator but unlimited times (no storage)). Each player has been teleported to different place.

2) If we have 2 items on required places:
ID: 2086 on: x: 2034 y: 340 z: 7
ID: 2090 on: x: 2035 y: 340 z: 7
and we put lever the items dissapear and we got item: ID: 2087
and storage = 49506

3) NPC:
You must collect 3 items:
- 100x ID: 2159
- 50x ID: 2149
- 100x ID: 2151
after collect and say to npc: quest, we got reward: 3945 and storage.

4) NPC:
Thx to Summ



REP++ for all helpers :)
 
Last edited:
Here is the NPC with the questions. Just change the questions and add the right answer for each question.
Rep++ plax ;D

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

local config = {
	questions = {
		"What is green?",
		"What is blue?",
		"What is orange?",
		"What is red?",
		"What is purple?"
	},
	answers = {
		"Apple",
		"Color", 
		"Carrot", 
		"Blood",
		"Color"
	},
	right = {x=1000,y=1000,z=7},
	wrong = {x=998,y=998,z=7}
}

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser, state = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid, talkState[cid] and talkState[cid] or 0
	
	if state == 0 and msgcontains(msg, "quiz") then
		selfSay("The first question is: " .. config.questions[state+1], cid)
		talkState[cid] = 1
	else
		if msgcontains(msg, config.answers[state]) then
			if state == #config.questions then
				selfSay("Great! You answered all questions right.", cid)
				doSendMagicEffect(getThingPos(cid), 2)
				doTeleportThing(cid, config.right)
				doSendMagicEffect(config.right, 10)
				talkState[cid] = 0
			else
				selfSay("That was right. The next question is: " .. config.questions[state+1], cid)
				talkState[cid] = state+1
			end
		else
			selfSay("You answered wrong..", cid)
			
			doSendMagicEffect(getThingPos(cid), 2)
			doTeleportThing(cid, config.wrong)
			doSendMagicEffect(config.wrong, 10)
			talkState[cid] = 0
		end
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
First script (should work)
LUA:
local start = 
{
	{x = 100, y = 100, z = 7},
	{x = 102, y = 100, z = 7},
	{x = 104, y = 100, z = 7}
}

local destination =
{
	{x = 200, y = 100, z = 7},
	{x = 202, y = 100, z = 7},
	{x = 204, y = 100, z = 7}

}

local levers = {1945, 1946}

fucntion onUse(cid, item, fromPosition, itemEx, toPosition)

	if isInArray(levers, item.itemid) then
		if item.actionid = xxx then

			local players = {}
			for _, position in ipairs(start) do
			local pid = getTopCreature(position).uid

				if pid == 0 or not isPlayer(pid) then doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE) and return true end
			
				table.insert(players, pid)
			end

			for i, pid in ipairs(players) do
				doSendMagicEffect(start[i], CONST_ME_POFF)
				doTeleportThing(pid, destination[i], false)
				doSendMagicEffect(destination[i], CONST_ME_ENERGYAREA)
			end

			doTransformItem(item.itemid, (item.itemid == 1945 and 1946 or 1945))
			return true
		end
	end
end


SECOND SCRIPT (Should work too)

LUA:
--If ithe items in the first item in floor then stackpos = 1, else change the stackpos.
local t =
{
	{2086, {x = 2034, y = 340, z = 7, stackpos = 1},
	{2090, {x = 2035, y = 340, z = 7, stackpos = 1}
}
local levers = {1945, 1946}

local storage = 49506

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

	if isInArray(levers, item.itemid) then
		if item.actionid == xxx then
			if getCreatureStorage(cid, storage) < 1 then
				local success = 0
				for i = 1, table.maxn(t) do
					if getTileThingByPos(t[i][2]).itemid == t[i][1] then
						doRemoveItem(getTileThingByPos(t[i][2]).uid)
						doSendMagicEffect(t[i][1], CONST_ME_POFF)
						success = success + 1
					end
				end
			
				local reward = 2087
				if success >= table.maxn(t) then
					doPlayerAddItem(cid, reward, 1)
					doCreatureSetStorage(cid, storage, 1)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have obtained " .. getItemArticleById(reward) .. " " .. getItemNameById(reward) .. ".")
				end

				doTransformItem(item.uid, (item.itemid == 1945 and 1946 or 1945))
				return true
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already done this quest.")
				return false
			end
		end
	end
end

THIRD(NPC)

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
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



local items = 
{
	{2159, 100},
	{2149, 50},
	{2151, 100}
}

local storage = 65535

local t = 0
 
function creatureSayCallback(cid, type, msg)
 
	if(not npcHandler:isFocused(cid)) then
		return false
	end
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if msgcontains(msg, "quest") then

		local text = ""
 		local sep = ", "
		for i = 1, table.maxn(items) do
			if(i == table.maxn(items) - 1) then
					sep = "and "
			elseif i == table.maxn(items) then
				sep = ""
			end

			text = text .. items[i][2] .. "x " .. getItemNameById(items[i][1]) .. sep
		end
				
		selfSay("Are you sure that do you want to give me " .. text .. " for " .. getItemArticleById(3945) .. " " .. getItemnameById(3945) .. "?", cid)
		talkState[talkUser] = 1

	elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
		if getCreatureStorage(cid, 65535) < 1 then
			for item, count in ipairs(items) do
				if getPlayerItemCount(cid, item) >= count then
					t = t + 1
				end
			end
			if t == table.maxn(items) do
				for i = 1, table.maxn(items) do doPlayerRemoveItem(cid, items[i][1], items[i][2]) end
				doPlayerAddItem(cid, 3945, 1)
				doCreatureSetStorage(cid, 65535, 1)
				selfSay("Thank you, take this reward.", cid)
				talkState[talkUser] = 0
			else
				selfSay("You do not have the required items.", cid)
				talkState[talkUser] = 0
			end
		else
			selfSay("You already done this quest.", cid)
			talkState[talkuser] = 0
		end
	
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
2. Rep++
LUA:
local itemi = 2086
local pos1 = {x=2034, y=340, z=7}
local itemi2 = 2090
local pos2 = {x=2035, y=340, z=7}
local queststatus = getPlayerStorageValue(cid,49506)
function onUse(cid, item, frompos, item2, topos)
	local targetItem = getTileItemById(pos1, itemi).uid
		local targetItem2 = getTileItemById(pos2, itemi2).uid
		if queststatus == -1 then
if targetitem > 0 and targetitem2 > 0 then
doRemoveItem(targetItem)
doRemoveItem(targetItem2)
setPlayerStorageValue(cid,49506,1)
doPlayerAddItem(cid, 2087, 1)
doSendMagicEffect(pos1, CONST_ME_FIREAREA)
doSendMagicEffect(pos2, CONST_ME_FIREAREA)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
else
doCreatureSay(cid, "You have to put "..getItemNameById(itemi).." and "..getItemNameById(itemi2).." to the right places!", TALKTYPE_ORANGE_1)
end
else
doCreatureSay(cid, "You have already done this!", TALKTYPE_ORANGE_1)
end
return 1
end
 
Back
Top