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

StepIn, removecreature (Help)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,858
Reaction score
96
Location
Brazil
I need a script that:
1. When stepin player get teleport to a room and create a monster inside this room if have storage.(If player haven't storage he back to 'fromposition').
2. After 10mins IF player is in room yet he get teleported to a position.
3. Player can't enter if other player inside room.
4. If monster is alive inside he must be removed. (Maybe other player dead inside).

PS.:player must have storage to getin.

I made this script but it's not working.
Lua:
function onStepIn(cid, item, pos, fromPos)

	if isPlayer(cid) and getCreatureStorage(cid, 65911) < 0 then 
			doTeleportThing(cid, {x=32442, y=31993, z=9})
                        doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
                        setPlayerStorageValue(cid,75911,1)
			doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
		else
			doTeleportThing(cid, fromPosition, CONST_ME_NONE)
		end
	end


	if isPlayer(cid) and getCreatureStorage(cid, 75911) == 1 then 
			doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
end
end
end
 
Last edited:
I'm not 100% sure it will work since I have some doubt about a part in my function, but test it, also you need to change {fromX, toX, fromY, toY, z} to their appropriate positions.
Lua:
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getCreatureStorage(cid, 65911) < 0 then 
		doTeleportThing(cid, {x=32442, y=31993, z=9})
		doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
		setPlayerStorageValue(cid,75911,1)
		doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
		addEvent(moveCreatureFromArea, 10*60*1000, cid, fromX, toX, fromY, toY, z, true, fromPosition) 
	else
		doTeleportThing(cid, fromPosition, true)
		doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
	end
end
function moveCreatureFromArea(uid, fromX, toX, fromY, toY, z, teleport, position)
local list = {}
	for x = fromX, toX do
		for y = fromY, toY do
			v = getThingFromPosition(x, y, z)
			table.insert(list, v)
			local pid = v[uid]
			break
			if pid then
				if teleport then
					doTeleportThing(pid, position)
				else
					doRemoveItem(pid)
				end
			else
				return print('Creature not found.')
			end
		end
	end
end
Also I do not know what are you using for scripting but I would advice you to use Notepad++ and always press tab to space the functions and stuff.
 
Last edited:
Didn't understand this {fromX, toX, fromY, toY, z}
I made this but don't works:
Lua:
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getCreatureStorage(cid, 65911) < 0 then 
		doTeleportThing(cid, {x=32442, y=31993, z=9})
		doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
		setPlayerStorageValue(cid,75911,1)
		doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
		addEvent(moveCreatureFromArea, 10*60*1000, cid, 32435, 32448, 31989, 32002, 9, true, fromPosition) 
	else
		doTeleportThing(cid, fromPosition, true)
		doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
	end
end
function moveCreatureFromArea(uid, 32435, 32448, 31989, 32002, 9, teleport, position)
local list = {}
	for x = fromX, toX do
		for y = fromY, toY do
			v = getThingFromPosition(x, y, z)
			table.insert(list, v)
			local pid = v[uid]
			break
			if pid then
				if teleport then
					doTeleportThing(pid, position)
				else
					doRemoveItem(pid)
				end
			else
				return print('Creature not found.')
			end
		end
	end
end
 
Does it teleport the player to where the boss is?
Does it remove the player after 10 minutes?

Please specify what have you done so I can help you.
 
ok I'm assuming that the storage value of the player is in 0 which is what you need to get in, you had it like this if Pstorage < 0 then, the problem was < since you have 0 so I changed it to ==
Lua:
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getCreatureStorage(cid, 65911) == 0 then 
		doTeleportThing(cid, {x=32442, y=31993, z=9})
		doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
		setPlayerStorageValue(cid,75911,1)
		doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
		addEvent(moveCreatureFromArea, 10*60*1000, cid, 32435, 32448, 31989, 32002, 9, true, fromPosition) 
	else
		doTeleportThing(cid, fromPosition, true)
		doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
	end
end
function moveCreatureFromArea(uid, fromX, toX, fromY, toY, z, teleport, position)
local list = {}
	for x = fromX, toX do
		for y = fromY, toY do
			v = getThingFromPosition(x, y, z)
			table.insert(list, v)
			local pid = v[uid]
			break
			if pid then
				if teleport then
					doTeleportThing(pid, position)
				else
					doRemoveItem(pid)
				end
			else
				return print('Creature not found.')
			end
		end
	end
end

Edited the script
 
I don't think so. There is problem:
Lucas changed this line (but shouldn't)

Code:
function moveCreatureFromArea(uid, fromX, toX, fromY, toY, z, teleport, position)
 
imagem.jpg


I will test, w8.
 
ok I'm assuming that the storage value of the player is in 0 which is what you need to get in, you had it like this if Pstorage < 0 then, the problem was < since you have 0 so I changed it to ==
Lua:
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getCreatureStorage(cid, 65911) == 0 then 
		doTeleportThing(cid, {x=32442, y=31993, z=9})
		doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
		setPlayerStorageValue(cid,75911,1)
		doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
		addEvent(moveCreatureFromArea, 10*60*1000, cid, 32435, 32448, 31989, 32002, 9, true, fromPosition) 
	else
		doTeleportThing(cid, fromPosition, true)
		doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
	end
end
function moveCreatureFromArea(uid, fromX, toX, fromY, toY, z, teleport, position)
local list = {}
	for x = fromX, toX do
		for y = fromY, toY do
			v = getThingFromPosition(x, y, z)
			table.insert(list, v)
			local pid = v[uid]
			break
			if pid then
				if teleport then
					doTeleportThing(pid, position)
				else
					doRemoveItem(pid)
				end
			else
				return print('Creature not found.')
			end
		end
	end
end

Edited the script



imagem.jpg
 
removed break
Lua:
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getCreatureStorage(cid, 65911) == 0 then 
		doTeleportThing(cid, {x=32442, y=31993, z=9})
		doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
		setPlayerStorageValue(cid,65911,1)
		doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
		addEvent(moveCreatureFromArea, 10*60*1000, cid, 32435, 32448, 31989, 32002, 9, true, fromPosition) 
	else
		doTeleportThing(cid, fromPosition, true)
		doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
	end
end
function moveCreatureFromArea(uid, fromX, toX, fromY, toY, z, teleport, position)
local list = {}
	for x = fromX, toX do
		for y = fromY, toY do
			v = getThingFromPosition(x, y, z)
			table.insert(list, v)
			local pid = v[uid]
			if pid then
				if teleport then
					doTeleportThing(pid, position)
				else
					doRemoveItem(pid)
				end
			else
				return print('Creature not found.')
			end
		end
	end
end
 
3 bugs:
1. It is not removing the creature inside (player died and monster is in).
2. Player can enter if another player is in.
3. Player is not getting teleported to out. (Position: [X: 32452] [Y: 31989] [Z: 9].)

Lua:
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getCreatureStorage(cid, 65911) >= 1 and getCreatureStorage(cid, 75911) == -1 then 
		doTeleportThing(cid, {x=32442, y=31993, z=9})
		doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
		 setPlayerStorageValue(cid,75911,1)
		doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
		addEvent(moveCreatureFromArea, 10*60*1000, cid, 32435, 32448, 31989, 32002, 9, true, fromPosition) 
	else
		doTeleportThing(cid, fromPosition, true)
		doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
	end
end
function moveCreatureFromArea(uid, fromX, toX, fromY, toY, z, teleport, position)
local list = {}
	for x = fromX, toX do
		for y = fromY, toY do
			v = getThingFromPosition(x, y, z)
			table.insert(list, v)
			local pid = v[uid]
			if pid then
				if teleport then
					doTeleportThing(pid, position)
				else
					doRemoveItem(pid)
				end
			else
				return print('Creature not found.')
			end
		end
	end
end
 
Last edited:
Yea I have to check if that function if well made, but I made a small change to the function and added another event to find the monster and remove it, I will see what I can do about other players getting in.
Lua:
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getCreatureStorage(cid, 65911) == 0 then 
		doTeleportThing(cid, {x=32442, y=31993, z=9})
		doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
		setPlayerStorageValue(cid,65911,1)
		doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
		addEvent(moveCreatureFromArea, 10*60*1000, cid, 32435, 32448, 31989, 32002, 9, true, fromPosition) 
		addEvent(moveCreatureFromArea, 10*60*1000, cid = getCreatureByName('The Horned Fox'), 32435, 32448, 31989, 32002, 9, false)
	else
		doTeleportThing(cid, fromPosition, true)
		doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
	end
end
function moveCreatureFromArea(uid, fromX, toX, fromY, toY, z, teleport, position)
local list = {}
	for x = fromX, toX do
		for y = fromY, toY do
			v = getThingFromPosition(x, y, z).uid
			table.insert(list, v)
			local pid = v[uid]
			if pid then
				if teleport then
					doTeleportThing(pid, position)
				else
					doRemoveItem(pid)
				end
			else
				return print('Creature not found.')
			end
		end
	end
end
 

My bad :p
Lua:
function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) and getCreatureStorage(cid, 65911) == 0 then 
		doTeleportThing(cid, {x=32442, y=31993, z=9})
		doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
		setPlayerStorageValue(cid,65911,1)
		doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
		addEvent(moveCreatureFromArea, 10*60*1000, cid, 32435, 32448, 31989, 32002, 9, true, fromPosition) 
		addEvent(moveCreatureFromArea, 10*60*1000, getCreatureByName('The Horned Fox'), 32435, 32448, 31989, 32002, 9, false)
	else
		doTeleportThing(cid, fromPosition, true)
		doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
	end
end
function moveCreatureFromArea(uid, fromX, toX, fromY, toY, z, teleport, position)
local list = {}
	for x = fromX, toX do
		for y = fromY, toY do
			v = getThingFromPosition(x, y, z).uid
			table.insert(list, v)
			local pid = v[uid]
			if pid then
				if teleport then
					doTeleportThing(pid, position)
				else
					doRemoveItem(pid)
				end
			else
				return print('Creature not found.')
			end
		end
	end
end
 
Bug found:
1. When player enter with boss inside, it's not removed and another will be created. Player will have to fight with 2 bosses.
2. Player is not being kicket after 10min
 
Last edited:
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if isPlayer(cid) then
		if getStorage(68944) <= 0 then
			if getCreatureStorage(cid, 65911) <= 0 then 
				doTeleportThing(cid, {x=32442, y=31993, z=9})
				doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
				doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
				
				doCreatureSetStorage(cid, 65911, 1)
				doSetStorage(68944, 1)
				
				addEvent(moveCreatureFromArea, 10*60*1000, 32435, 32448, 31989, 32002, 9, {x=32452, y=31989, z=9})
				addEvent(doSetStorage, 10*60*1000, 68944, -1)
			else
				doTeleportThing(cid, lastPosition)
				doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
			end
		else
			doTeleportThing(cid, lastPosition)
			doCreatureSay(cid, "Someone is in room. Wait for your turn.", TALKTYPE_ORANGE_1)
		end
	end
end

function moveCreatureFromArea(fromX, toX, fromY, toY, z, position)
	for x = fromX, toX do
		for y = fromY, toY do
			local v = getThingFromPos({x, y, z}).uid
			if isPlayer(v) then
				doTeleportThing(v, position)
			elseif isMonster(v) then
				doRemoveCreature(v)
			end
		end
	end
end
 
Last edited:
@VirrageS,
Your script is not removing creatures inside.
I changed somethings about storages.

Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if isPlayer(cid) then
		if getCreatureStorage(cid, 75911) == -1 then
			if getCreatureStorage(cid, 65911) > 0 then 
				doTeleportThing(cid, {x=32442, y=31993, z=9})
				doCreateMonster('The Horned Fox', {x=32440, y=31996, z=9})
				doCreatureSay(cid, "You have ten minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
 
				doSetStorage(68944, 1)
                                setPlayerStorageValue(cid,75911,1)

 
				addEvent(moveCreatureFromArea, 10*60*1000, 32435, 32448, 31989, 32002, 9, {x=32452, y=31989, z=9})
				addEvent(doSetStorage, 10*60*1000, 68944, -1)
			else
				doTeleportThing(cid, lastPosition)
				doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
			end
		else
			doTeleportThing(cid, lastPosition)
			doCreatureSay(cid, "Someone is in room. Wait for your turn.", TALKTYPE_ORANGE_1)
		end
	end
end
 
function moveCreatureFromArea(fromX, toX, fromY, toY, z, position)
	local list = {}
	for x = fromX, toX do
		for y = fromY, toY do
			v = getThingFromPosition(x, y, z).uid
			if isPlayer(v) then
				doTeleportThing(v, position)
			elseif isMonster(v) then
				doRemoveCreature(v)
			end
		end
	end
end

Do not removing creatures inside.
I will test if it remove player inside after 10min.


EDIT:
Do not remove player after 10min in room.
 
Last edited:
Back
Top