I've made a script based on my training system ^_^
This is a rune, like death portal rune, when you die, your possition will be saved and you can back by use this rune!
dprune.lua
This is good idea for RPG servers.
actions.xml
creaturescripts.xml
login.lua
Simple, from my OT.
This is a rune, like death portal rune, when you die, your possition will be saved and you can back by use this rune!
dprune.lua
This is good idea for RPG servers.
Lua:
function onUse(cid, item, frompos, item2, topos)
if (not getTileInfo(getThingPosition(cid)).protection) then -- Checks if player is in Protection Zone, if not, the rune does not work.
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use this rune outside of PZ.") and false
end
local storage, rune = 89523, 2296 -- (Storage ID - 89524 and 89525 need to be available.), RUNE ID
local p = {
getPlayerStorageValue(cid, storage),
getPlayerStorageValue(cid, storage+1),
getPlayerStorageValue(cid, storage+2)
} -- This is an array, used to index more than one value to a single variable.
if (p[1] > -1 and p[2] > -1) then -- To call the first value in the variable 'p', you must specify the index number, p[INDEX_#]
if (getPlayerItemCount(cid, rune) > 0) then
doPlayerRemoveItem(cid, rune, 1)
doTeleportThing(cid, {x=p[1], y=p[2], z=p[3]})
doSendMagicEffect({x=p[1], y=p[2], z=p[3]}, CONST_ME_TELEPORT)
for i = storage, storage+2 do -- this is a loop, sets the storage value back to -1, once it is used.
setPlayerStorageValue(cid, i, -1)
end
end
else
doPlayerSendCancel(cid,"You must die first to use this rune.")
end
return true
end
actions.xml
Code:
<action itemid="2296" script="dprune.lua" />
creaturescripts.xml
Code:
<event type="death" name="Portal" event="script" value="dprune.lua" />
Lua:
function onDeath(cid, corpse, killer)
local storage = 89523
local playerPos = getPlayerPosition(cid)
setPlayerStorageValue(cid, storage, playerPos.x)
setPlayerStorageValue(cid, storage+1, playerPos.y)
setPlayerStorageValue(cid, storage+2, playerPos.z)
return TRUE
end
login.lua
Code:
registerCreatureEvent(cid, "Portal")
Simple, from my OT.
Last edited: