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

Lua Kazordoon Wagons - small problem

Galaxy

New Member
Joined
Feb 24, 2011
Messages
108
Reaction score
1
Location
Ireland/Carlow
Hey, I found a script on otland. BUT I have no idea how to add more wagons to that script ;( There is just a space for 1 wagon. ;(

Here is the script...
Code:
local positions = {
				--[[ Here is how it goes if player clicked the wagon which is on pos1 then he goes to that on pos2 and vice-versa]]--
					[1] = { pos1 = {x=94,y=114,z=7}, pos2 = {x=91,y=123,z=7} },   
					[2] = { pos1 = {x=94,y=119,z=7}, pos2 = {x=83,y=123,z=7} }
}
local days = 1182930 --empty storage, must be the same as the one in the npc file
 
function isWalkable(pos)
	if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
	for i = 0, 255 do
		pos.stackpos = i
		local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, 2) or hasProperty(tile.uid, 7) then
				return false
			end
		end
	end
	return true
end
function doTeleportToClosestFree(cid,pos, x, y)
	local places = getArea(pos, 1, 1)
	for i = 1,#places do
		if isWalkable(places[i],false,true) then return doTeleportThing(cid,places[i]) and doSendMagicEffect(places[i],10) and true end
	end
	return false
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local Teleport_to,p = false,toPosition
	if getPlayerStorageValue(cid,days) < os.time() then return doPlayerSendCancel(cid,getPlayerStorageValue(cid,days) > 0 and "Your subscription have ended." or "You havn't subscribed yet.") and doSendMagicEffect(p,2) end
	for k,v in pairs(positions) do
		if doComparePositions(p, v.pos1) or doComparePositions(p, v.pos2) then Teleport_to = doComparePositions(p, v.pos1) and v.pos2 or v.pos1 break end
	end
	if not Teleport_to then return doPlayerSendCancel(cid,"wagon is out of service.") and doSendMagicEffect(p,2) end	
	if not doTeleportToClosestFree(cid,Teleport_to, 1, 1) then return doPlayerSendCancel(cid,"You need to inform wagon master about this rail block.") and doSendMagicEffect(p,2) end
	return true
end

Thanks for support :)
 
Back
Top