• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Death portal rune.

Potar

SocialWorld
Senator
Joined
Mar 1, 2009
Messages
1,664
Reaction score
125
Location
Warsaw, Poland
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.

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:
Really cool script! never heard something like that but it sound awesome! :D

Thanks for the release!
 
OP, I knew the intentions of the script and fixed it.(it was not going to work as anyone thought it would.)
I left a few comment inside the script, explaining various things, also when you comment it's mainly to explain what the part does, or leave an important notice.
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
 
Lol, i use my script from 3 months, and i never got any problem -.- do not tell me it doesn't work -.-

You've made it like loop version, there is not any difference.
 
Why not check if isPlayer(item2.uid) and item2.uid == cid ..
Makes look better I think, if I understood the use rightl.
 
The script you posted, is missing an "end" that is supposed to close "function", with that only the script will not even load.
then there is this part:
Lua:
	if(getPlayerItemCount(cid, rune) > 0) then
		doPlayerRemoveItem(cid, rune, 1)
		doTeleportThing(cid, {x=x, y=y, z=z})
		doSendMagicEffect({x=x, y=y, z=z}, CONST_ME_TELEPORT)
	else
		doPlayerSendCancel(cid,"You need to death first.")
	end
first, it check if the player has enough runes, anything bigger than 0, the message after else, will never execute, since if you use the last one, by the time you use it you ran out, you would need 0 runes(impossible that's a nil to the script) in order to see that message and that will never happen.

I changed it to check if the player has the position values inside their storage, if there is, it continues with the script, if not it sends the message. I also added that loop that returns the values back to -1. that helps from having the players abuse the script.

if you were thinking I was trying to make fun of you, then you are sadly mistaking, I'm simply pointing out problems and helping you fix them, with some explanation. Good luck with the script.
 
could you add some type of timer or something to this so it wont work except for like 2 minutes only after death? Then it would reset and not tp the char? I have tried it and it works well but I think to add this part would help prevent it from being abused (so the chars have to get right back to their bodies rather than use it 2 days later for travel, etc.)
 
@otuserbyme

Creaturescripts.xml

PHP:
<event type="login" name="Reset" event="script" value="reset.lua"/>

reset.lua

Lua:
local storage = 2500 -- your storages of possitions, +1 and +2 must be free too!
local reset = 2*60*1000 -- 1000 = 1sec so 60sec* 2 = 120 sec (2min).

function onLogin()

registerCreatureEvent(cid, "Reset")

addEvent(function()
for i = storage, storage+2 do
setPlayerStorageValue(cid, i, -1)
end end, reset)

return true
end
 
Last edited:
@otuserbyme

Creaturescripts.xml

PHP:
<event type="login" name="Reset" event="script" value="reset.lua"/>

reset.lua

Lua:
local storage = 2500 -- your storages of possitions, +1 and +2 must be free too!
local reset = 2*60*1000 -- 1000 = 1sec so 60sec* 2 = 120 sec (2min).

function onLogin()

registerCreatureEvent(cid, "Reset")

addEvent(function()
for i = storage, storage+2 do
setPlayerStorageValue(cid, i, -1)
end end, reset)

return true
end
maybe adding to the script it self if it works? would be better than having alot of scripts :p
 
Not working, At least not to me
What am I doing wrong?

Code:
[01/10/2013 16:58:30] data/actions/scripts/dprune.lua:onUse
[01/10/2013 16:58:30] data/actions/scripts/dprune.lua:2: attempt to call global 'getThingPosition' (a nil value)
[01/10/2013 16:58:30] stack traceback:
[01/10/2013 16:58:30]    [C]: in function 'getThingPosition'
[01/10/2013 16:58:30]    data/actions/scripts/dprune.lua:2: in function <data/actions/scripts/dprune.lua:1>
 
You can use getThingPos.
If you have more nil value errors, you can look in the folder doc in file LUA_FUNCTIONS for similar functions.
 
the time limit doesnt works :( you can still use it even 1 hour after your dead
 
Hey :D
Wanted to test the Script now... I made everything but I get this Error:

[Warning - Event::loadScript] Event onDeath not found (data/creaturescript/scripts/dprune.lua)

What can I do now? :/

Thanks!
 
Back
Top