function onUse(cid, item, fromPosition, itemEx, toPosition)
local level = getPlayerLevel(cid)
local mag = getPlayerMagLevel(cid)
local manamin = (level/2.5)+(mag*2)
local manamax = (level/2)+(mag*2)
local mana_add = math.random(manamin, manamax)
if (getPlayerVocation(cid) == 1 or 5) then
doPlayerAddMana(cid, mana_add)
doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
else
doPlayerSendCancel(cid, "You cannot use this rune")
doSendMagicEffect(topos, CONST_ME_POFF)
end
return FALSE
end
"You must kill the monster to open the box."
Code:function onUse(cid, item, fromPosition, itemEx, toPosition) -- Script by BomBa if getPlayerGroupId(cid) <= 1 then if getPlayerStorageValue(cid, 026610) <= 0 then if ((getCreatureName(cid) == "Ghoul") and (isInRange(getCreaturePosition(cid), {x=90, y=149, z=8}, {x=96, y=155, z=8}) == TRUE)) then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must kill the monster to open the box.") else doPlayerAddItem(cid, 2661, 1) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You opened the box and won an amulet.") setPlayerStorageValue(cid, 026610, 1) end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This is empty.") end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are not a common player.") end return TRUE -- Script by BomBa end
The problem is:
I can open the box without killing the monster. The monster is alive and still I can open the box to receive the amulet.
I think I have to replace the 'cid' by another function. But what?
Added to first post, will complete soon.
Any error messages? More info please.
[24/06/2009 02:12:28] Lua Script Error: [Spell Interface]
[24/06/2009 02:12:28] data/spells/scripts/whirlwind exori.lua:onCastSpell
[24/06/2009 02:12:28] data/spells/scripts/whirlwind exori.lua:10: attempt to call global 'getWeaponType' (a nil value)
[24/06/2009 02:12:28] stack traceback:
[24/06/2009 02:12:28] data/spells/scripts/whirlwind exori.lua:10: in function <data/spells/scripts/whirlwind exori.lua:9>
talkactions/talkactions.xml:
Code:<talkaction words="power" event="script" value="angelpower.lua"/>
talkactions/scripts/angelpower.lua
Lua:function onSay(cid, words, param, channel) if(getPlayerStorageValue(cid, 63452) == 1) then setPlayerStorageValue(cid, 63452, 2) --can't do again-- doPlayerAddSpentMana(cid, getPlayerRequiredMana(cid, getPlayerMagLevel(cid, ignoreBuffs))) --recieving power-- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have recieved my power.") --recieving message return true else return false end end
movements/movements.xml
NOTE: there is already an action for 426, please combine both the scripts or choose another tile.Code:<movevent type="StepIn" itemid="426" event="script" value="angelpower.lua"/> <movevent type="StepOut" itemid="426" event="script" value="angelpower.lua"/>
movements/angelpower.lua
Lua:function onStepIn(cid, item, pos) if(item.actionid == 5435) then if(isPlayer(cid) and getPlayerStorageValue(cid, 63452) < 1) then setPlayerStorageValue(cid, 63452, 1) --tile storage-- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "If you require my power please say \"power\".") --talkaction message-- end if(isPlayer(cid) and getPlayerStorageValue(cid, 63452) == 2) then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Away with you! You have recieved my power already!") --Already completed message-- end return true end end function onStepOut(cid, item, pos) if(isPlayer(cid) and getPlayerStorageValue(cid, 63452) < 2) then setPlayerStorageValue(cid, 63452, 0) --left without answering-- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "I see. Come back to harness my power another time!") end return true end
Not exactly as requested but its close and I'm tired. Its poorly written but I tested in 3.4pl2 and it works.
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerGroupId(cid) < 1 then
if getPlayerStorageValue(cid, 026610, -1) then
if (getCreatureName(cid) == "Ghoul") and (isInRange(getCreaturePosition(cid), {x = 90, y = 149, z = 8}, {x = 96, y = 155, z = 8}) == TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must kill the monster to open the box.")
else
doPlayerAddItem(cid, 2661, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You opened the box and won an amulet.")
setPlayerStorageValue(cid, 026610, 1)
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This is empty.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are not a common player.")
end
return TRUE
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
firstID = ITEMID -- id of the first item
secondID = ITEMID -- id of the second item
newPOS = {xxx,yyy,z} -- player teleported too...
local piece1pos = {
x = xxx,
y = yyy, -- Poition of the first item
z = z,
stackpos=1}
local piece2pos = {
x = xxx,
y = yyy, -- Poition of the second item
z = z,
stackpos=1}
local getpiece1 = getThingfromPos(piece1pos)
local getpiece2 = getThingfromPos(piece2pos)
local playerpos = getPlayerPosition(cid)
if getpiece1.itemid == firstID and getpiece2.itemid == secondID or getpiece1.itemid == secondID and getpiece2.itemid == firstID then
if item.itemid == 1945 then
doTransformItem(item.uid,item.itemid+1)
elseif item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
end
doRemoveItem(getpiece1.uid,1)
doRemoveItem(getpiece2.uid,1)
doSendMagicEffect(piece1pos,2)
doSendMagicEffect(piece2pos,2)
doTeleportThing(cid, newPOS)
doSendMagicEffect(playerpos, CONST_ME_TELEPORT)
end
else
doPlayerSendTextMessage(cid, 22, "You need " .. getItemArticleById(firstID) .. " "..getItemNameById(firstID).." and " .. getItemArticleById(secondID) .. " "..getItemNameById(secondID)..".")
return TRUE
end
Type of Script: action
Priority: normal
Reason of Request: The problem is: I can open the box without killing the monster. The monster is alive and still I can open the box to receive the amulet.
Description: You must kill the monster to open the box.
*Public
function onKill(cid, target)
local config = {
monstername = "Custom Ghoul name", -- monster name
needeedkills = 1, -- kills needed to complete quest
finalstorage = 10002, -- storage of completed quest
}
if(isMonster(target) == TRUE) then
if getCreatureName(target) == config.monstername then
if getPlayerStorageValue(cid, config.finalstorage) == 1 then
doSendMagicEffect(toPos, 12)
else
doCreatureSay(cid, "You killed "..config.monstername..", Your now able to get your award.", TALKTYPE_ORANGE_1)
setPlayerStorageValue(cid,config.finalstorage,1)
end
return TRUE
end
end
end
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, 10002) == -1 then
doPlayerSendTextMessage(cid,22,"You have found a Scarf.")
doPlayerAddItem(cid,2661,1)
setPlayerStorageValue(cid, 10002,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
function doPlayerAddSummon(cid, name, pos)
local MyCreature = doSummonCreature(name, pos)
doConvinceCreature(cid, MyCreature)
end
doPlayerAddSummon(cid, param, getCreaturePosition(cid))
function doPlayerAddSummon(cid, name, pos)
local MyCreature = doSummonCreature(name, pos)
doConvinceCreature(cid, MyCreature)
end
function onSay(cid, words, param, channel)
local level = 30
local mana = 200
local vocsCanUse = {1, 2, 3, 4, 5, 6, 7,8}
local condition = CONDITION_DRUNK
local canBeSummoned = {"Dog", "Troll", "Bug", "Fire Devil", "Fire Elemental"}
if getPlayerLevel(cid) < level then
doPlayerSendCancel(cid, "Your level is too low.")
return TRUE
end
if getCreatureMana(cid) < mana then
doPlayerSendCancel(cid, "You do not have enough mana.")
return TRUE
end
if(not isInArray(vocsCanUse, getPlayerVocation(cid))) then
doPlayerSendCancel(cid, "Your vocation cannot use this spell.")
return TRUE
end
if getCreatureCondition(cid, condition) == FALSE then
doPlayerSendCancel(cid, "You need to be drunked to use this spell.")
return TRUE
end
if(not isInArray(canBeSummoned, param)) then
doPlayerSendCancel(cid, "You cannot summon this creature.")
return TRUE
end
doPlayerAddSummon(cid, param, getCreaturePosition(cid))
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
return TRUE
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- Script by BomBa
local ITEM_ = getThingfromPos({x=102, y=148, z=8, stackpos=STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
local ITEM__ = getThingfromPos({x=105, y=150, z=8, stackpos=STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
local ITEM___ = getThingfromPos({x=102, y=153, z=8, stackpos=STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
if itemEx.uid == 36150 then
if ((ITEM_.itemid == 2047) and (ITEM__.itemid == 2320) and (ITEM___.itemid == 2041)) then
doRemoveItem(ITEM__.uid, 1)
doTransformItem(ITEM_.uid, 2048, 1)
doTransformItem(ITEM___.uid, 2042, 1)
doTeleportThing(cid, {x=96, y=152, z=8}, TRUE)
setPlayerStorageValue(cid, 126610, 1)
else
doPlayerSendCancel(cid, "Put the items in the correct places.")
end
end
return TRUE
-- Script by BomBa
end
<action uniqueid="39410" event="script" value="other/fluid_of_blood.lua"/>
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
if getCreatureName(cid) == "Undead Man" then
doCreatureSay(cid, "Ahhh! do not open the boxes!!!", TALKTYPE_ORANGE_1)
local target = getPlayerByNameWildcard(getCreatureName(mostDamageKiller))
setPlayerStorageValue(target, 226610, 1)
end
return TRUE
end
registerCreatureEvent(cid, "UndeadManBox")
<event type="death" name="UndeadManBox" event="script" value="undead_man__box.lua"/>
<script>
<event name="UndeadManBox"/>
</script>
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, 226610) == 1 then
if getPlayerStorageValue(cid, 326610) == -1 then
doPlayerAddItem(cid, 2661, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Scarf.")
setPlayerStorageValue(cid, 326610, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must kill the monster to open the box.")
end
return TRUE
end
<action uniqueid="26610" event="script" value="quests/rookgaard_scarf.lua"/>
local config = {
bossname = "Tormented Soul",
globalStorage = 1000,
setTo = 0
}
function onDeath(cid, corpse, killer)
if config.bossname == getCreatureName(cid) then
if getGlobalStorageValue(config.globalStorage) >= 1 then
setGlobalStorageValue(config.globalStorage, 0)
end
end
return TRUE
end