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

Action (OnStepIn) Advanced script

cordis

Member
Joined
Jun 22, 2008
Messages
31
Reaction score
8
Location
Brasil
hello guys, im a mapper with some long time in mapping but none in scripting, im learning scripting now but there are some that i don't know yet, some advanced.
I need a script that:
When you step on a tile(Id:426) a boss will be summoned and a wall will appear in (pos x:1027, pos y:1002, pos z:4)
and if possible in the same script when the boss it's killed the wall desappear.

So the overall it's like that you walk in the boss chamber step on the tile the chamber will be closed and the boss will be summoned, you kill the boss the wall disappears and you get the prize.
 
I'm new to scripting so i don't know, but it didn't show any errors in the console:
Code:
function onStepIn(cid, item, position, fromPosition)
if item.actionid == 105 then
doSummonMonster(Demon, 1028, 1002, 4)
      doCreateItem(WALLID, 1, 1027, 1002, 4)
   else
       doPlayerSendTextMessage(cid, MessageClasses, Error)
   end
 return true
end
 
If i understood i need to put an action id: 105 on the tile. i did and made the action.xml
but didn't work, no errors on console, but didn't work
 
It's a movement, action is function onUse (things you click use on).

Lua:
function onStepIn(cid, item, position, fromPosition)

local config = {
	wallid = 1026, -- wall id
	wallpos = {x=1027,y=1002,z=4}, -- wall position
	monsterpos = {x=1000,y=1000,z=7}, -- where the monster spawns
	monstername = "Boss" -- name of the boss
}

	if not isPlayer(cid) then
		return true
	end

	if getTileItemById(config.wallpos, config.wallid).uid < 1 then
		doSummonCreature(config.monstername, config.monsterpos)
		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
		doCreateItem(config.wallid,1,config.wallpos)
	end
        return true
end

The other (the kill part) is a creaturescript.

creaturescripts.xml
XML:
<event type="kill" name="Boss" event="script" value="bosskill.lua"/>

Add this to login.lua
Lua:
registerCreatureEvent(cid, "Boss")

bosskill.lua
Lua:
function onKill(cid, target)
 
local config = {
	["boss"] = {wallpos = {x=1027,y=1002,z=4}, wallid = 1026}
}
 
local monster = config[getCreatureName(target):lower()]
 
	if(isPlayer(target)) or not monster then
		return true
	end
 
	if getTileItemById(monster.wallpos, monster.wallid).uid > 0 then
		doRemoveItem(getTileItemById(monster.wallpos,monster.wallid).uid,1)
		doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Congratulations, you have killed "..getCreatureName(target)..". You can now take your reward.")
	end
	return true
end
 
Last edited:
Worked, Ty Limos, one last thinh that i forgot i need the function OnStepIn to create a storagevalue on player, cause this is a on time only quest, and in the script you can summon how many boss you want D: and i don't want that =P
 
Last edited:
Lua:
function onStepIn(cid, item, position, fromPosition)
 
local config = {
	wallid = 1026, -- wall id
	wallpos = {x=1027,y=1002,z=4}, -- wall position
	monsterpos = {x=1000,y=1000,z=7}, -- where the monster spawns
	monstername = "Boss", -- name of the boss
	storage = 9567
}
 
	if not isPlayer(cid) or getPlayerStorageValue(cid, config.storage) == 1 then
		return true
	end
 
	if getTileItemById(config.wallpos, config.wallid).uid < 1 then
		doSummonCreature(config.monstername, config.monsterpos)
		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
		doCreateItem(config.wallid,1,config.wallpos)
            	setPlayerStorageValue(cid, config.storage, 1) 
	end
        return true
end
 
Back
Top