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

Requesting two scripts !

Swansoft

New Member
Joined
Apr 13, 2013
Messages
49
Reaction score
0
HI IM USING 0.3.6 crying damson

i need a script witch you step onto a tile and it takes 40 Frag Soils off you ITEMID (8298) then it tps you to possion x y z




2nd script


I want a NPC that trades one item for another item?

again for 0.3.6
 
Last edited:
XML:
<movevent type="StepIn" uniqueid="2020" event="script" value="script.lua"/>
Lua:
local SOIL = {8298, 40}


function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)


	if not doPlayerRemoveItem(cid, SOIL[1], SOIL[2]) then
		doPlayerSendCancel(cid, 'You need ' .. SOIL[2] .. ' ' .. getItemPluralNameById(SOIL[1]) .. ' to pass through here!')
		return doTeleportThing(cid, fromPosition)
	end
	
	return doTeleportThing(cid, {x = 1000, y = 1000, z = 7})
end
--
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)


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 turn = {}
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)


local trade =
	{					--id, amount
		['player_item'] = {1212, 1},
		['npc_item'] = {1515, 1},
	}


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


	local pid = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
	if msgcontains(msg, 'trade') or msgcontains(msg, 'offer') then
		selfSay('Do you want to trade your '.. getItemNameById(trade['player_item'][1]) ..' for my '..getItemNameById(trade['npc_item'][1])..'?', cid)
		turn[pid] = 'trade'
	elseif (turn[pid] == 'trade') and msgcontains(msg, 'yes') then
		if not doPlayerRemoveItem(cid, trade['player_item'][1], trade['player_item'][2]) then
			turn[pid] = nil
			return selfSay('But you don\'t have the item...', cid)
		end
		
		doPlayerAddItem(cid, trade['npc_item'][1], trade['npc_item'][2])
		turn[pid] = nil
		return selfSay('Thanks!', cid)
	end
	return true
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)        
npcHandler:addModule(FocusModule:new())
 
Back
Top Bottom