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

Script help: storage values&summoning creatures

Michael Orsino

Premium User
Premium User
Support Team
Joined
Nov 15, 2007
Messages
854
Solutions
10
Reaction score
389
Location
Santiago, Chile (Australian)
Am working on a script for the Azerus quest in Yalahar for my server.
The one I had was not ideal as players could summon Azerus and his minions as many times as they wished. I am sure this is not the best way to deal with the situation but I really don't know that much about scripting.

** I wan't the script to check a players storage value to determine if he/she has 'started' the quest before, and if so not to restart it.
** If the player has not 'started' the quest before, to start it.

How the quest works - Player 'uses' the focal item, the quest is initiated and monsters are summoned.

This is what I have so far
Code:
function onUse(cid, item, frompos, item2, topos)
	Activated = getPlayerStorageValue(cid, 98761)
    
	if item.itemid == 9767 then
	if Activated == -1 then
		setPlayerStorageValue(cid, 98761, 1)
		doPlayerSendCancel(cid, "Azerus is summoning his army")

function Potwory1()

	doSummonCreature("Rift Worm", {x=1189,y=984,z=10})

	doSummonCreature("Rift Worm", {x=1197,y=988,z=10})

	doSummonCreature("Rift Worm", {x=1189,y=983,z=10})

	doSummonCreature("Rift Worm", {x=1197,y=983,z=10})


end


function Potwory2()

	doSummonCreature("Rift Brood", {x=1189,y=984,z=10})

	doSummonCreature("Rift Brood", {x=1197,y=988,z=10})

	doSummonCreature("Rift Brood", {x=1189,y=983,z=10})

	doSummonCreature("Rift Brood", {x=1197,y=983,z=10})


end




function Potwory3()


	doSummonCreature("Rift Scythe", {x=1189,y=984,z=10})

	doSummonCreature("Rift Scythe", {x=1197,y=988,z=10})

	doSummonCreature("Rift Scythe", {x=1189,y=983,z=10})

	doSummonCreature("Rift Scythe", {x=1197,y=983,z=10})


end




function Potwory4()


	doSummonCreature("Azerus", {x=1193,y=985,z=10})
	
	doSummonCreature("War Golem", {x=1189,y=984,z=10})

	doSummonCreature("War Golem", {x=1197,y=988,z=10})

	doSummonCreature("War Golem", {x=1189,y=983,z=10})

	doSummonCreature("War Golem", {x=1197,y=983,z=10})



end




function onUse(cid, item, frompos, item2, topos)


	addEvent(Potwory1, 0)


	addEvent(Potwory2, 10000)


	addEvent(Potwory3, 60000)


	addEvent(Potwory4, 120000)


	return TRUE


end
    
else
    doPlayerSendCancel(cid, "You have already summoned Azerus!")
end
end
return 1
end

At the moment the script skips the function Potwory's, adds the storage value as desired and then cancels as desired. Basically I would like to know how to have this script work as i'd like it to.

Thanks for any help
 
PHP:
function onUse(cid, item, frompos, item2, topos) 
    if getPlayerStorageValue(cid, 98761) == -1 then
        setPlayerStorageValue(cid, 98761, 1)
        addEvent(Potwory1, 0)
        addEvent(Potwory2, 10000)
        addEvent(Potwory3, 60000)
        addEvent(Potwory4, 120000)
    else
        doPlayerSendCancel(cid, "You have already summoned Azerus!")
    end
    return TRUE
end


PHP:
function Potwory1()
doSummonCreature("Rift Worm", {x=1189,y=984,z=10})
doSummonCreature("Rift Worm", {x=1197,y=988,z=10})
doSummonCreature("Rift Worm", {x=1189,y=983,z=10})
doSummonCreature("Rift Worm", {x=1197,y=983,z=10})
end


function Potwory2()
doSummonCreature("Rift Brood", {x=1189,y=984,z=10})
doSummonCreature("Rift Brood", {x=1197,y=988,z=10})
doSummonCreature("Rift Brood", {x=1189,y=983,z=10})
doSummonCreature("Rift Brood", {x=1197,y=983,z=10})
end

function Potwory3()
doSummonCreature("Rift Scythe", {x=1189,y=984,z=10})
doSummonCreature("Rift Scythe", {x=1197,y=988,z=10})
doSummonCreature("Rift Scythe", {x=1189,y=983,z=10})
doSummonCreature("Rift Scythe", {x=1197,y=983,z=10})
end

function Potwory4()
doSummonCreature("Azerus", {x=1193,y=985,z=10})
doSummonCreature("War Golem", {x=1189,y=984,z=10})
doSummonCreature("War Golem", {x=1197,y=988,z=10})
doSummonCreature("War Golem", {x=1189,y=983,z=10})
doSummonCreature("War Golem", {x=1197,y=983,z=10})
end


Not tested //
 
Last edited:
Works just as I wanted it to, thanks a lot.

In case anyone else reads this, this is the complete script.

*Add AID 11223 to the focal item.
*Insert the actions.xml line
*create azerus.lua

/actions/actions.xml
Code:
<action actionid="11223" script="azerus.lua" />

actions/scripts/azerus.lua
Code:
function onUse(cid, item, frompos, item2, topos) 

  local Activated = getPlayerStorageValue(cid, 98761) 
     
  if item.itemid == 9767 and Activated == -1 then 
    setPlayerStorageValue(cid, 98761, 1) 
    addEvent(Potwory1, 0) 
    addEvent(Potwory2, 10000) 
    addEvent(Potwory3, 60000) 
    addEvent(Potwory4, 120000) 
    else 
    doPlayerSendCancel(cid, "You have already summoned Azerus!") 
   end 
    return TRUE 
   end 

function Potwory1() 
doSummonCreature("Rift Worm", {x=1189,y=984,z=10}) 
doSummonCreature("Rift Worm", {x=1197,y=988,z=10}) 
doSummonCreature("Rift Worm", {x=1189,y=983,z=10}) 
doSummonCreature("Rift Worm", {x=1197,y=983,z=10}) 
end 


function Potwory2() 
doSummonCreature("Rift Brood", {x=1189,y=984,z=10}) 
doSummonCreature("Rift Brood", {x=1197,y=988,z=10}) 
doSummonCreature("Rift Brood", {x=1189,y=983,z=10}) 
doSummonCreature("Rift Brood", {x=1197,y=983,z=10}) 
end 

function Potwory3() 
doSummonCreature("Rift Scythe", {x=1189,y=984,z=10}) 
doSummonCreature("Rift Scythe", {x=1197,y=988,z=10}) 
doSummonCreature("Rift Scythe", {x=1189,y=983,z=10}) 
doSummonCreature("Rift Scythe", {x=1197,y=983,z=10}) 
end 

function Potwory4() 
doSummonCreature("Azerus", {x=1193,y=985,z=10}) 
doSummonCreature("War Golem", {x=1189,y=984,z=10}) 
doSummonCreature("War Golem", {x=1197,y=988,z=10}) 
doSummonCreature("War Golem", {x=1189,y=983,z=10}) 
doSummonCreature("War Golem", {x=1197,y=983,z=10}) 
end
 
dont work for me in 0.3.4 tfs

Lua:
[28/05/2009 15:03:28] Lua Script Error: [Action Interface] 
[28/05/2009 15:03:28] in a timer event called from: 
[28/05/2009 15:03:28] data/actions/scripts/yalahar.lua:onUse

[28/05/2009 15:03:28] luaDoCreateMonster(). Cannot create monster: Rift Scythe
 
Back
Top