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

Need an Script for removing stone

alekito

Archlord - Retired
Joined
Oct 21, 2008
Messages
150
Reaction score
29
Location
Sweden
Hiho im searching for an script that does this:

if an player got an certain item then pressing a lever it spawns 1 monster and when monster is dead it removes an stone from a certain position and removes the item from the players backpack.


Rep ++ if you can help me out.

:D:D

- - - Updated - - -

Anyone?
 
Give me 30 min and i will make to you

- - - Updated - - -

Okay mate, is a regular script, you need to do somethings

first level.lua

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local monster = {x=421, y=228, z=5} --Place where the monster will be spawmed
local name = "wolf" --Exact name of the monster
local item = xxxx --ItemID of the item that you need to activate the lever
local unique = xxxx --UniqueID of the lever
local failmessage = "You need an item to pull this lever" --Message showed up when you didnt got the item to pull the lever

if item.itemid == 1945 and item.uid == unique and doPlayerRemoveItem(cid, item, 1) == TRUE then
	doTransformItem(item.uid, item.itemid+1)
	doSummonCreature(name, monster)
	doSendMagicEffect(monster, 10)
 else
	doPlayerSendCancel(cid, failmessage) 
 end
 if item.itemid == 1946 then
	doTransformItem(item.uid, item.itemid+1)
	doSummonCreature(name, monster)
	doSendMagicEffect(monster, 10)
else
	doPlayerSendCancel(cid, failmessage) 
 end

return TRUE
end

and add this line to actions

Code:
<action uniqueid="xxxx" event="script" value="lever.lua"/>

remember to put correctly teh unique id in the xxxx, both in script and in that line

now, pay attention mate, you need to mate a specific monsters with an specific name, why?, because for example, in the script i write "wolf" as a monster, but when you kill any wolf the script will get activate so you should create your own monster with an original name like "lever guardian" i don't know

now in creature scripts do this script

killmonster.lua

Code:
function onKill(cid, target) 
local message = "You kill teh monster, well done" --Message showed up when you kill the monster
local monster = "wolf" --Name of the monster, put the same as the other script
local wall = {x=75,y=92,z=7} --wall posistion
local tempo = 1 --time in seconds to reappear the wall, right now the wall appear again after 1 second
local id = xxxx --ItemId of the wall

function create()
 local x = getTileItemById(wall, id)
 doCreateItem(id, 1, wall)
 end

if getCreatureName(target) == monster then
	local x = getTileItemById(wall, id)
	doRemoveItem(x.uid, 1) 
    doCreatureSay(cid, "The wall will appears in "..tempo.." seconds.", 1) 
    addEvent(create, tempo*1000) 

end
return true
end

and add to creaturescripts.xml

Code:
<event type="kill" name="Killmonster" event="script" value="killmonster.lua"/>

remember to change the name of the file if you don't put that

and the last, add this line before the "return true" on the login.lua

Code:
registerCreatureEvent(cid, "KillMonster")

any errors post it, if you are a beginner and don't undertand try to learn a little using the search function
 
humm got this error

13 18:24:10] [Error - Action Interface]
[20/05/2013 18:24:10] data/actions/scripts/quests/first level.lua:eek:nUse
[20/05/2013 18:24:10] Description:
[20/05/2013 18:24:10] data/actions/scripts/quests/first level.lua:9: attempt to index local 'item' (a number value)
[20/05/2013 18:24:10] stack traceback:
[20/05/2013 18:24:10] data/actions/scripts/quests/first level.lua:9: in function <data/actions/scripts/quests/first level.lua:1>




and this is the script

function onUse(cid, item, fromPosition, itemEx, toPosition)

local monster = {x=1339, y=1021, z=7} --Place where the monster will be spawmed
local name = "Elder Bug" --Exact name of the monster
local item = 2346 --ItemID of the item that you need to activate the lever
local unique = 30016 --UniqueID of the lever
local failmessage = "You need an item to pull this lever" --Message showed up when you didnt got the item to pull the lever

if item.itemid == 1945 and item.uid == unique and doPlayerRemoveItem(cid, item, 1) == TRUE then
doTransformItem(item.uid, item.itemid+1)
doSummonCreature(name, monster)
doSendMagicEffect(monster, 10)
else
doPlayerSendCancel(cid, failmessage)
end
if item.itemid == 1946 then
doTransformItem(item.uid, item.itemid+1)
doSummonCreature(name, monster)
doSendMagicEffect(monster, 10)
else
doPlayerSendCancel(cid, failmessage)
end

return TRUE
end
 
Is only a bad use of a constant

use this script

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local monster = {x=1339, y=1021, z=7} --Place where the monster will be spawmed
local name = "Elder Bug" --Exact name of the monster
local id = 2346 --ItemID of the item that you need to activate the lever
local unique = 30016 --UniqueID of the lever
local failmessage = "You need an item to pull this lever" --Message showed up when you didnt got the item to pull the lever

if item.itemid == 1945 and item.uid == unique and doPlayerRemoveItem(cid, id, 1) == TRUE then
doTransformItem(item.uid, item.itemid+1)
doSummonCreature(name, monster)
doSendMagicEffect(monster, 10)
else
doPlayerSendCancel(cid, failmessage) 
end
if item.itemid == 1946 then
doTransformItem(item.uid, item.itemid+1)
doSummonCreature(name, monster)
doSendMagicEffect(monster, 10)
else
doPlayerSendCancel(cid, failmessage) 
end

return TRUE
end
 
works rep for you Raiden ty :D



Just 1 problem now the monster gets spawned when im clicking the lever and it removes an item just as planned but the stone that should be removed when killing Elder Bug is not moving.. what can be wrong?
 
Last edited:
Bring me you creaturescript lua and your monster file to see what happen

also put your login.lua and your creaturescript.xml to see if i find why it didn't works
 
creaturescript.xml

Lua:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
	<event type="login" name="PlayerLogin" event="script" value="login.lua"/>
	<event type="look" name="RebirthDescription" event="script" value="rebirthdescription.lua"/>
	<event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
	<event type="receivemail" name="Mail" event="script" value="mail.lua"/>
	<event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>
	<event type="kill" name="Killmonster" event="script" value="killmonster.lua"/>
	<event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>

	<event type="think" name="Idle" event="script" value="idle.lua"/>
	<event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
	<event type="advance" name="SpellUp" event="script" value="spellup.lua"/>
	<event type="combat" name="partyAndGuildProtection" event="script" value="partyAndGuildProtection.lua"/>
</creaturescripts>

creaturescript/scripts/login.xml

Lua:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
		doPlayerSetLossPercent(cid, PLAYERLOSS_ITEMS, 0)
		doPlayerSetLossPercent(cid, PLAYERLOSS_CONTAINERS, 0) 		
	end

	local accountManager = getPlayerAccountManager(cid)
	if(accountManager == MANAGER_NONE) then
		local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
		if(lastLogin > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
			str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
		else
			str = str .. " Please choose your outfit."
			doPlayerSendOutfitWindow(cid)
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	elseif(accountManager == MANAGER_NAMELOCK) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
	elseif(accountManager == MANAGER_ACCOUNT) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
	end

	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	end
	registerCreatureEvent(cid, "Mail")
	registerCreatureEvent(cid, "GuildMotd")
	registerCreatureEvent(cid, "RebirthDescription")
	registerCreatureEvent(cid,'SpellUp')
	registerCreatureEvent(cid, "partyAndGuildProtection")

	registerCreatureEvent(cid, "Idle")
	if(config.useFragHandler) then
		registerCreatureEvent(cid, "SkullCheck")
	end
	registerCreatureEvent(cid, "KillMonster")
	registerCreatureEvent(cid, "ReportBug")
	registerCreatureEvent(cid, "AdvanceSave")
	return true
end


creaturescript/scripts/killmonster.lua

Lua:
 function onKill(cid, target) 
local message = "You kill teh monster, well done" --Message showed up when you kill the monster
local monster = "Elder Bug" --Name of the monster, put the same as the other script
local wall = {x=1339, y=1025, z=7} --wall posistion
local tempo = 1 --time in seconds to reappear the wall, right now the wall appear again after 1 second
local id = 9791 --ItemId of the wall

function create()
 local x = getTileItemById(wall, id)
 doCreateItem(id, 1, wall)
 end

if getCreatureName(target) == monster then
	local x = getTileItemById(wall, id)
	doRemoveItem(x.uid, 1) 
    doCreatureSay(cid, "The wall will appears in "..tempo.." seconds.", 10) 
    addEvent(create, tempo*1000) 

end
return true
end



monster/Elder Bug.xml

Lua:
<?xml version="1.0" encoding="utf-8"?>
<monster name="Elder Bug" namedescription="a Elder Bug" race="venom" experience="900" speed="800" manacost="0">
	<health now="50000000" max="50000000"/>
	<look type="352" corpse="12619"/>
	<targetchange interval="2000" chance="5"/>
	<strategy attack="100" defense="0"/>
	<flags>
		<flag summonable="0"/>
		<flag attackable="1"/>
		<flag hostile="1"/>
		<flag illusionable="0"/>
		<flag convinceable="0"/>
		<flag pushable="0"/>
		<flag canpushitems="0"/>
		<flag canpushcreatures="0"/>
		<flag targetdistance="1"/>
		<flag staticattack="90"/>
		<flag runonhealth="0"/>
	</flags>
	<attacks>
		<attack name="melee" interval="1000" min="-59400000" max="-80900000"/>
		<attack name="speed" interval="2000" chance="75" range="7" speedchange="-600" duration="5000">
			<attribute key="shootEffect" value="earth"/>
			<attribute key="areaEffect" value="smallplants"/>
		</attack>	
	</attacks>
	<defenses armor="15" defense="35"/>
	<elements>
		<element firePercent="85"/>
		<element icePercent="85"/>
		<element holyPercent="85"/>
		<element energyPercent="85"/>
		<element physicalPercent="85"/>
		<element deathPercent="85"/>
	</elements>
	<immunities>
		<immunity lifedrain="1"/>
		<immunity invisible="1"/>
	</immunities>
		<voices interval="2000" chance="10">
		<voice sentence="Chrrr!"/>
	</voices>
	<loot>
	    <item id="2165" chance="750" /><!-- stealth ring -->
		<item id="2148" countmax="100" chance="39550" /><!-- gold coin -->
		<item id="2148" countmax="94" chance="39550" /><!-- gold coin -->
		<item id="7588" chance="8780" /><!-- strong health potion -->
		<item id="11226" chance="14925" /><!-- sulphurous stone-->
		<item id="12619" chance="6525" /><!-- brimstone fangs -->
		<item id="7589" chance="8780" /><!-- strong mana potion -->
		<item id="12620" chance="10280" /><!-- brimstone shell -->
		<item id="11216" chance="20000" /><!-- lump of earth -->
		<item id="2149" countmax="4" chance="1802" /><!-- small emerald -->
		<item id="10556" chance="49280" /><!-- poisonous slime -->
		<item id="2152" chance="190" /><!-- platinum amulet -->
	</loot>
</monster>
 
Well, everything seems correctly except one thing, change this line on creaturescripts.xml

Code:
<event type="kill" name="Killmonster" event="script" value="killmonster.lua"/>

TO:

Code:
<event type="kill" name="KillMonster" event="script" value="killmonster.lua"/>

And check if it works... what was wrong? on login.lua you register the event "KillMonster" and in creaturescript you have "Killmonster", i think that thas is why the server don't recognize your event, try one more time
 
works now 100% thanks so much Raiden. im mainly an mapper so not very good in scripting although im going to learn it in due time :D
 
Back
Top