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

MoveEvent Amazing Hunting Room, Much Features in 1 Script

do you like this thread


  • Total voters
    8
  • Poll closed .

Slave Ots

LUA Newbie™
Joined
Jan 19, 2012
Messages
114
Reaction score
32
Location
/goto Slave Ots
hi otlanders
Slave Ots Present a hunting room full systems + some features in one script
in this script
*when you enter a room it gets clean automaticlly
*it have 3 ways to check that you are in room or now and kicks you if your time is up
*noway to get 1 bug inside it
*very very very easy configs {beginners and newbies can use this script}
*every line have its own guides so that you don't need to get back to this thread;
*each line have got a comments on how to use or what this code/s do
*you will only edit 12 ~ 18 values or lines and script will be working
[only configurations]
** and much more.. Dont Forget to REP++ please
-------------------------------------------------------------------------------------------------------

now in data / movements / scripts add;
Code:
function onStepIn(cid, item, pos, fromPosition)
-- all credits for slave ots @ otland.net
-- use the following AIDs
-- for enter teleprot --> 55xx
-- for exit teleprot --> 44xx 
-- for summon sqm --> 33xx
--you can relocate this area valuis for empty storages
local InRoom = 12345  -- for players only. keep the same in all scripts
local Exhaust = 12346 -- for magic effects dont edit. keep the same for all scripts
local onexit = 12347 -- when exit he maynot enter after 30 sec. keep it for all rooms
local playerpos = getPlayerPosition(cid) -- player position for magic effects
local onsummon = 12344    -- when player summon this makes exhauste
local onsummontime = os.date("%S seconds", getPlayerStorageValue(cid, onsummon)  - os.time())  -- dont change
local onexittime = os.date("%S seconds", getPlayerStorageValue(cid, onexit)  - os.time())  -- dont change
--------------------------------------------------------------------------------------------------------------------
-- all creadits to 7I7A and Admin Slave <$>
local RoomID = 5501			 --  55xx where xx = room id  for enter
local ExitID =  4401		-- 44xx where xx = room id   for exit
local SummonID =  3301	    -- 33xx wher xx = room id for summon monster
local reqcoins = 20 -- required coins to enter with id 6527
local pos = {from = {x=717, y=898, z=10}, to = {x=726, y=908, z=10}}  -- for each room
local exitpos = {x=729, y=903, z=10}  				 -- for each room
local startpos = {x=724, y=903, z=10} 				 -- for each room
local monsterpos = {x=722, y=907, z=10}  --on blood 	 -- for each room
local teleportpos = {x=728, y=903, z=10}  -- enter teleport for timer
local monster = 'Demon'  -- monster name , dont remove ''
local xtime = 600000  -- 1 minutes  milleseconds / huntting
local duration = 600  -- 10 minutes for exhaust storage . seconds 
local mon = getCreatureByName(monster)
local mons = getMonstersInRange(pos.from, pos.to)  -- check numbers of creatures in room
--local mons = getCreatureInRange(mon, pos.from, pos.to, count)
--------------- end of configs -----------
------------------
-- summond sqm aid 33xx
if item.actionid == SummonID then  
 if isPlayer(cid) then	
if getGlobalStorageValue(RoomID) > 0 and getCreatureStorage(cid, InRoom) == RoomID and getPlayerStorageValue(cid, Exhaust) > os.time() then  
-- this means that player have hunt time, if he haven't he will be kicked out
          if (table.maxn(mons) >= 1) then
		  doSendMagicEffect(playerpos, 2)
  return doPlayerSendCancel(cid, 'sorry, you monster is already summoned.') and doTeleportThing(cid, fromPosition) and true
  
  if getPlayerStorageValue(cid, onsummon) > os.time() then
 doPlayerSendCancel(cid, ' you must wait ' .. onsummontime .. ' before summon another monster.')
 doSendMagicEffect(playerpos, 2)
 doTeleportThing(cid, fromPosition)
return 1
end
            return true 
			else
		  doTeleportThing(cid, exitpos)
		    setPlayerStorageValue(cid, onexit, os.time()+30)
		  	doSendMagicEffect(exitpos, 10)
			    setGlobalStorageValue(RoomID, -1) 
	setPlayerStorageValue(cid, InRoom, -1)
	return true
	end
return true
end
end
end
-------------------------------- enter teleprot
if item.actionid == RoomID then  
 if not isPlayer(cid) then
 return 1
 end
if getPlayerStorageValue(cid, onexit) > os.time() then
doPlayerSendCancel(cid, 'you must wait ' .. onexittime .. ' .')
doTeleportThing(cid, fromPosition)
return 1
end
if getGlobalStorageValue(RoomID) < 0 and getCreatureStorage(cid, InRoom) < 0 then
if doPlayerRemoveItem(cid,6527, reqcoins) == TRUE then
  	doSendAnimatedText(playerpos, "welcome", 247)
    doPlayerSendTextMessage(cid, 25, 'you have 10 minutes of huntting!') 
    setGlobalStorageValue(RoomID, 1) 
	setPlayerStorageValue(cid, InRoom, RoomID)
	 setPlayerStorageValue(cid, Exhaust, os.time() + duration) 
    doTeleportThing(cid, startpos) 
	doAreaClean(pos.from, pos.to)		  
    return addEvent(
	function() 
        if isPlayer(cid) and getGlobalStorageValue(RoomID) > 0 or getCreatureStorage(cid, InRoom) == RoomID then
 --setPlayerStorageValue(cid, onexit, os.time()+10)		--  
            doTeleportThing(cid, exitpos) 
            doPlayerSendTextMessage(cid, 25, 'times up!') 
			 setPlayerStorageValue(cid, InRoom, -1)
			  setPlayerStorageValue(cid, Exhaust, 0)
			  setPlayerStorageValue(cid, DoubleSpawn, -1)
			  doSendMagicEffect(exitpos, 10)
                return setGlobalStorageValue(RoomID, -1) 
                    end end, 
					  xtime, cid)--, RoomID) auto kicker
					else
					doPlayerSendCancel(cid, 'you dont have ' .. reqcoins .. ' game tokens!') 
					doTeleportThing(cid, fromPosition) 
					doSendMagicEffect(playerpos, 2)
  return 1 
  end
else 
    doTeleportThing(cid, fromPosition) 
	doSendMagicEffect(playerpos, 2)
    return doPlayerSendCancel(cid, 'Somebody is already in the room.')
end 
return true 
end  
--------------------------
 --exit teleport aid = 44xx
if item.actionid == ExitID then 
  if isPlayer(cid) then	
             doTeleportThing(cid, exitpos) 
			 setPlayerStorageValue(cid, onexit, os.time()+30)
            doPlayerSendTextMessage(cid, 25, 'you went out!') 
			 setPlayerStorageValue(cid, Exhaust, -1)
			 setPlayerStorageValue(cid, InRoom, -1)
			 doSendMagicEffect(exitpos, 10)
                return setGlobalStorageValue(RoomID, -1) 
				end
				return true
				end
				return true
				end
----------------------------
in data / movements / movements.xml add;
Code:
<movevent type="StepIn" actionid="5501;4401;3301" event="script" value="xxxx"/>
in data / lib / 050-function add this two functions:(they are not mine)
Code:
**function getMonstersInRange(fromPosition, toPosition) 
    local creatures = getCreaturesInRange(fromPosition, toPosition) 
    local monsters = {} 
    for _, creature in ipairs(creatures) do 
        if(isMonster(creature)) then 
            table.insert(monsters, creature) 
        end 
    end 
	
    return monsters 
end



function isCleanAbleArea(pos)
	pos.stackpos = 0
	local tile = getThingfromPos(pos, false)
	if tile ~= 0 and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not isCreature(getTopCreature(pos).uid) then
		return true
	end
end
 
function doAreaClean(frompos, topos)
 for x = frompos.x, topos.x do
	for y = frompos.y, topos.y do
		for z = frompos.z, topos.z do
	local p = {x=x,y=y,z=z}
     if isCleanAbleArea(p) or created_by_otswe == true then 
        doCleanTile(p,false)
        end
      end
   end
   end
 end
hope you like it
its 100% for me. 100% tested on TFS 0.3.6 and 100% worked. dont change credits
i think i deserve REP++
King Regards
Note: it only have 1 problem. that if you summoned a creatureutevo res " fire elemental it will not summon a monster in the room.. iam working on it and ill update this post later
Slave Ots
 
Last edited:
im not understand if you can let me understand how to add to my ots

- - - Updated - - -
 
Last edited:
Ok Well one thing i see that i duno about is the locations. Could you enter them into an array... like
Code:
[COLOR=#333333]local pos = {from = {x=717, y=898, z=10}, to = {x=726, y=908, z=10}}  -- for each room[/COLOR]
[COLOR=#333333]local exitpos = {x=729, y=903, z=10}                   -- for each room[/COLOR]
[COLOR=#333333]local startpos = {x=724, y=903, z=10}                  -- for each room[/COLOR]
[SIZE=2][COLOR=#333333]local monsterpos = {x=722, y=907, z=10}  --on blood [/COLOR][/SIZE][SIZE=2][COLOR=#333333] -- for each room
[/COLOR][/SIZE]

Turning them into arrays, so that you dont have to have millions of scripts... like
Code:
Code:
[COLOR=#333333]local pos = {{from = {x=717, y=898, z=10}, to = {x=726, y=908, z=10}}, [FONT=Verdana]{from = {x=[COLOR=#ff0000]#[/COLOR], y=[COLOR=#ff0000]#[/COLOR], z=[COLOR=#ff0000]#[/COLOR]}, to = {x=[COLOR=#ff0000]#[/COLOR], y=[COLOR=#ff0000]#[/COLOR], z=[COLOR=#ff0000]#[/COLOR]}}[/FONT][FONT=Verdana]   }  -- for each room[/FONT][/COLOR]
[SIZE=2][COLOR=#333333]local exitpos = {{x=729, y=903, z=10},{x = [/COLOR][/SIZE][COLOR=#FF0000]#[/COLOR][SIZE=2][COLOR=#333333], y = [/COLOR][/SIZE][COLOR=#FF0000]#[/COLOR][SIZE=2][COLOR=#333333], z = [/COLOR][/SIZE][COLOR=#FF0000]#[/COLOR][SIZE=2][COLOR=#333333]}}[/COLOR][/SIZE][SIZE=2][COLOR=#333333]      -- for each room
[/COLOR][/SIZE]


Unless it's already like this... How else would you go about adding tons of rooms?... other then tons of scripts..

If its not like this then you would also have to turn alot of the id's into arrays...



ALSO with such a small script why not just add those functions into the main script and leave off the lib file?..... Unless it comes in some ot's and not in others... or something i guess...

Also whats up with line 92 and 93.....
Code:
[/COLOR][/SIZE]end end, 
xtime, cid)--, RoomID) auto kicker
 
Last edited:
thanks i put this on my server and it shi**ed up all my server and now anything doesn't work! i have to get new engine , thanks again! -- this sux doesnt work on tfs rev 3884 i think.......
 
@lasek,

You do realize he said "100% tested on TFS 0.3.6" - meanwhile you use 3884 which is 0.4. Could be why it messed up, although I haven't tried the script. Good luck.
 
Like it!
Im glad to see that easy to config script!
Is there any possibility to convert it to 1.2 ?
 
Back
Top