• 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:
Bugs:
1. Players can enter if another player inside.
2. Do not removing creature inside (player will fight with 2).
3. Player is not beeing removed after 10min.
 
Last edited:
Still don't works

Bugs:
1. Players can enter if another player inside.
2. Do not removing creature inside (player will fight with 2).
3. Player is not beeing removed after 10min.
 
Lua:
local config = {
	checkRoomStorage = 68944, -- free global storage
	playerStorage = 65911, -- free player storage
	
	bossName = "The Horned Fox", 
	bossCreatePos = {x=32440, y=31996, z=9},
	
	teleportPos = {x=32442, y=31993, z=9},
	kickPosition = {x=32452, y=31989, z=9},
	killTime = 10 -- in minutes
}

local room = {
	fromPos = {x=32435, y=31989, z=9},
	toPos = {x=32448, y=32002, z=9}
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if isPlayer(cid) then
		if getCreatureStorage(cid, config.playerStorage) <= 0 then 
			if getStorage(config.checkRoomStorage) <= 0 then

				doTeleportThing(cid, config.teleportPos)
				doCreateMonster(config.bossName, config.bossCreatePos)
				doCreatureSay(cid, "You have ".. config.killTime .." minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
 
				doCreatureSetStorage(cid, config.playerStorage, 1)
				doSetStorage(config.checkRoomStorage, 1)
 
				addEvent(moveCreatureFromArea, config.killTime * 60 * 1000, room.fromPos.x, room.toPos.x, room.fromPos.y, room.toPos.y, room.fromPos.z, config.kickPosition)
				addEvent(doSetStorage, config.killTime * 60 * 1000, config.checkRoomStorage, -1)
			else
				doTeleportThing(cid, lastPosition)
				doCreatureSay(cid, "Someone is in room. Wait for your turn.", TALKTYPE_ORANGE_1)
			end
		else
			doTeleportThing(cid, lastPosition)
			doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
		end
	end
	return true
end
 
function moveCreatureFromArea(fromX, toX, fromY, toY, z, position)
	for x = fromX, toX do
		for y = fromY, toY do
			local v = getThingFromPos({x=x, y=y, z=z, stackpos=253}).uid
			if isPlayer(v) then
				doTeleportThing(v, position)
			elseif isMonster(v) then
				doRemoveCreature(v)
			end
		end
	end
end

For me working.
 
Lua:
local config = {
	checkRoomStorage = 68944, -- free global storage
	playerStorage = 65911, -- free player storage
	
	bossName = "The Horned Fox", 
	bossCreatePos = {x=32440, y=31996, z=9},
	
	teleportPos = {x=32442, y=31993, z=9},
	kickPosition = {x=32452, y=31989, z=9},
	killTime = 10 -- in minutes
}

local room = {
	fromPos = {x=32435, y=31989, z=9},
	toPos = {x=32448, y=32002, z=9}
}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if isPlayer(cid) then
		if getCreatureStorage(cid, config.playerStorage) <= 0 then 
			if getStorage(config.checkRoomStorage) <= 0 then

				doTeleportThing(cid, config.teleportPos)
				doCreateMonster(config.bossName, config.bossCreatePos)
				doCreatureSay(cid, "You have ".. config.killTime .." minutes to kill and loot this boss, else you will lose that chance and will be kicked out.", TALKTYPE_ORANGE_1)
 
				doCreatureSetStorage(cid, config.playerStorage, 1)
				doSetStorage(config.checkRoomStorage, 1)
 
				addEvent(moveCreatureFromArea, config.killTime * 60 * 1000, room.fromPos.x, room.toPos.x, room.fromPos.y, room.toPos.y, room.fromPos.z, config.kickPosition)
				addEvent(doSetStorage, config.killTime * 60 * 1000, config.checkRoomStorage, -1)
			else
				doTeleportThing(cid, lastPosition)
				doCreatureSay(cid, "Someone is in room. Wait for your turn.", TALKTYPE_ORANGE_1)
			end
		else
			doTeleportThing(cid, lastPosition)
			doCreatureSay(cid, "You already entered this room before.", TALKTYPE_ORANGE_1)
		end
	end
	return true
end
 
function moveCreatureFromArea(fromX, toX, fromY, toY, z, position)
	for x = fromX, toX do
		for y = fromY, toY do
			local v = getThingFromPos({x=x, y=y, z=z, stackpos=253}).uid
			if isPlayer(v) then
				doTeleportThing(v, position)
			elseif isMonster(v) then
				doRemoveCreature(v)
			end
		end
	end
end

For me working.

rep for helping me spot what I was doing wrong in my function!
Thanks!
 
No one will help if there isn't any problem. Beacuse I have the same TFS like you and for me is working perfectly but for you it isn't working. So problem isn't in script but somewhere else.
 
Back
Top