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

onKill storage value question!

MarkSmartRemark

Lua-Noob in Training :D
Joined
Jan 27, 2010
Messages
139
Reaction score
3
Hey, just wondering.. is there a way to set a storage value for a player thats killed a monster but only for 20 seconds? example

I kill any monster> for 20 seconds after kill i have storage 9999> after 20 seconds it goes away
I kill another monster> same storage value again for 20 sec.. ^^

I want to make a spell that is only usable 20 seconds after ive killed a monster (or player).
 
Function os.time() is taking actual server time in seconds.
Code:
setPlayerStorageValue(cid, storage, os.time() + 20)

if getPlayerStorageValue(cid, storage) < os.time() then
     doScript...
end
 
Function os.time() is taking actual server time in seconds.
Code:
setPlayerStorageValue(cid, storage, os.time() + 20)

if getPlayerStorageValue(cid, storage) < os.time() then
     doScript...
end

ok gotchaa, so i make a script on creaturescript that sets a specific storage value onKill and in spell i would add the second part you gave me correct?

EDIT: @andu by the way thanks alot dude, youre a great help.
 
Ok, up until this part its worked perfectly! i have something else id like to add now..

Right now, when player kills a monster, he has 20 seconds to use BUT he can use this spell more then once in those 20 seconds..

I want to make it so he can use only ONE time after he kills a monster in those 20 seconds. But if he kills a monster again then it is usable.. You get me?

something like

kill> (20sec) can use spell ONE time> cant use spell
if he does this
kill>use spell right away>kill again> then he can use spell..

basically he can use spell as long as he kills.. Sorry if its complicated.. here is my scripts so far and they work halfway down

my creature script
Code:
function onKill(cid, target, lastHit)
if lastHit then
setPlayerStorageValue(cid, 6969, os.time() + 20)
end
return true
end


my spell
Code:
function onCastSpell(cid, var)
if getPlayerStorageValue(cid, 6969) > os.time() then
    return doCombat(cid, combat, var)
    else
    doPlayerSendCancel(cid, "You need to kill something before using this spell!")
        return false
        end
end

right now if he uses this spell, he can spam ability over and over in those 20 seconds.. Thanks!
 
You could add extra storage, set it to value 1 when casting the spell, set it to -1 in the kill script and check for it before doing the spell if it's -1.
 
Im gonna give it a try, still a bit new to this :p thanks for the help ill let you know if it worked

EDIT: Ok i got to this but couldnt fix it to do what i wanted heh..

Spell Code
Code:
function onCastSpell(cid, var)
  if (getPlayerStorageValue(cid, 6969) < os.time()) and (getPlayerStorageValue(cid, 6868) > 0) then
    doPlayerSendCancel(cid, "You need to kill something before using this spell!")
        return false
        else
        setPlayerStorageValue(cid, 6868, 1)
    return doCombat(cid, combat, var)
    end
end

in creaturescript folder
Code:
function onKill(cid, target, lastHit)
if lastHit then
setPlayerStorageValue(cid, 6868, -1)
setPlayerStorageValue(cid, 6969, os.time() + 20)
end
return true
end

How do i go about this? :/ only other thing i can think of is adding a cooldown but that would change what i want it to do..

this link is what i want it to do heh
http://www.wowhead.com/spell=34428/victory-rush

It says there 20 sec after killing someone only, but when you kill again even if its in those 20 seconds it resets basically..

Let me know if its possible and how! thankss
 
Last edited:
In spell script I think it should be
Code:
(getPlayerStorageValue(cid, 6868) < 0)
Check it, and tell what's exactly not working now.
 
In spell script I think it should be
Code:
(getPlayerStorageValue(cid, 6868) < 0)
Check it, and tell what's exactly not working now.
No. Everything is good except
getPlayerStorageValue(cid, 6969) < os.time()
should be
getPlayerStorageValue(cid, 6969) > os.time()

It will work exactly like WoW's Victory Rush
Remember to register creaturescript in login.lua
 
No. Everything is good except
getPlayerStorageValue(cid, 6969) < os.time()
should be
getPlayerStorageValue(cid, 6969) > os.time()

It will work exactly like WoW's Victory Rush
Remember to register creaturescript in login.lua

@andu hey bro, it works like i said earlier, i just tried this again but once i get the kill, i can use it as many times as i want for the 20 seconds.. i want it to only be usable ONE time after i get the kill.. you get me? right now i can use as many times, and when the 20 seconds pass i cant use it again
 
I know how WoW spells works.

I analized your scripts and found some minimal bugs.
Use these codes:
Code:
function onKill(cid, target)
    if isPlayer(cid) == true then
        setPlayerStorageValue(cid, 6868, 1)
        setPlayerStorageValue(cid, 6969, os.time() + 20)
    end
    return true
end

And this one for spell:
Code:
function onCastSpell(cid, var)
    if getPlayerStorageValue(cid, 6969) > os.time() and getPlayerStorageValue(cid, 6868) == 1 then
        setPlayerStorageValue(cid, 6868, 0)
        doCombat(cid, combat, var)
    else
        return doPlayerSendCancel(cid, "You need to kill something before using this spell!")
    end
    return true
end
 
I know how WoW spells works.

I analized your scripts and found some minimal bugs.
Use these codes:
Code:
function onKill(cid, target)
    if isPlayer(cid) == true then
        setPlayerStorageValue(cid, 6868, 1)
        setPlayerStorageValue(cid, 6969, os.time() + 20)
    end
    return true
end

And this one for spell:
Code:
function onCastSpell(cid, var)
    if getPlayerStorageValue(cid, 6969) > os.time() and getPlayerStorageValue(cid, 6868) == 1 then
        setPlayerStorageValue(cid, 6868, 0)
        doCombat(cid, combat, var)
    else
        return doPlayerSendCancel(cid, "You need to kill something before using this spell!")
    end
    return true
end

Solved! thanks alot andu once again!
 
Back
Top