So you want players to prove their worth before they can get into a new hunting place? Or maybe you want a place where only skillful players can go to relax with others? Now you can make it so players have to kill a certain monster, in this example a Demon, to use a lever to get somewhere.
Here we go...
in Login.lua (creaturescripts) add:
in Creaturescripts.xml add:
in (we'll use Demon as an example) monsters/Demons/Demon.xml before </monster> add:
create a file called killrequirement.lua in creaturescripts/scripts, in it put:
to add more creatures, for example a rat, all you have to do is add:
below the line local
then below:
add:
don't forget to add this script in EVERY monster you want to use for this script:
ok... this part will be short and sweet, but it will basically check if the player has killed the demon, and if the player hasn't it will tell them they need to kill a demon, otherwise it'll teleport them to the place we set at the start of the script
first of all we need to go into the actions folder, in actions.xml you need to add the lines:
(the first line is just to make finding scripts in actions.xml easier, it's not a requirement)
then in the scripts folder make a new file named killrequirement.lua
in this file paste this code, i'll explain everything after:
Ok, to make things simple I've made it so in the map you set the ActionID of the lever to 10203 so it knows which script to use, then you set the UniqueID to the storage for that monster, for example the Demon Lever will be: Actionid - 10203, Uniqueid - 10001.
You can replace the line under queststatus == 1 to anything you want until the "else" line, for example you may want to make it so they learn a spell or get an item (but this will require more work, as you'll need another storage added so they can't just keep pulling it)
Any problems just say
Thanks to View Profile: darkhaos - OtLand for his Killing In The Name script, which this is loosely based on.
Here we go...
in Login.lua (creaturescripts) add:
Code:
registerCreatureEvent(cid, "KillRequirement")
in Creaturescripts.xml add:
Code:
<event type="kill" name="KillRequirement" event="script" value="killrequirement.lua"/>
in (we'll use Demon as an example) monsters/Demons/Demon.xml before </monster> add:
Code:
<script>
<event name="KillRequirement"/>
</script>
create a file called killrequirement.lua in creaturescripts/scripts, in it put:
Code:
function onKill(cid, target, lastHit)
local demonstorage = 10001
local demonkilled = getPlayerStorageValue(cid,demonstorage)
local creature = getCreatureName(target)
if creature == "demon" then
if demonkilled == -1 then
doCreatureSetStorage(cid, demonstorage, 1)
end
end
end
to add more creatures, for example a rat, all you have to do is add:
Code:
local ratstorage = 10002
local ratkilled = getPlayerStorageValue(cid,demonstorage)
Code:
demonkilled = getPlayerStorageValue(cid,demonstorage)
then below:
Code:
if creature == "Demon" then
if demonkilled == -1 then
doCreatureSetStorage(cid, demonstorage, 1)
end
end
Code:
if creature == "rat" then
if ratkilled == -1 then
doCreatureSetStorage(cid, ratstorage, 1)
end
end
don't forget to add this script in EVERY monster you want to use for this script:
Code:
<script>
<event name="KillRequirement"/>
</script>
ok... this part will be short and sweet, but it will basically check if the player has killed the demon, and if the player hasn't it will tell them they need to kill a demon, otherwise it'll teleport them to the place we set at the start of the script
first of all we need to go into the actions folder, in actions.xml you need to add the lines:
Code:
<!-- Kill Requirement Lever -->
<action actionid="10203" event="script" value="killrequirement.lua"/>
then in the scripts folder make a new file named killrequirement.lua
in this file paste this code, i'll explain everything after:
Code:
function onUse(cid, item, frompos, item2, topos)
local demonstorage = 10001
local demonteleport = {x=1133, y=959, z=7} --Location to teleport to on the map if you pull the lever
--Demon Kill
if item.uid == 10001 then
queststatus = getPlayerStorageValue(cid,demonstorage)
if queststatus == 1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have defeated a demon, therefore you can pass.")
doTeleportThing(cid,demonteleport)
doSendMagicEffect(demonteleport,10)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to defeat a demon to use this lever.")
end
end
end
Ok, to make things simple I've made it so in the map you set the ActionID of the lever to 10203 so it knows which script to use, then you set the UniqueID to the storage for that monster, for example the Demon Lever will be: Actionid - 10203, Uniqueid - 10001.
You can replace the line under queststatus == 1 to anything you want until the "else" line, for example you may want to make it so they learn a spell or get an item (but this will require more work, as you'll need another storage added so they can't just keep pulling it)
Any problems just say
Thanks to View Profile: darkhaos - OtLand for his Killing In The Name script, which this is loosely based on.