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

TFS 1.X+ regeneration mp/hp for vip

jel

Member
Joined
Mar 22, 2014
Messages
302
Reaction score
12
how could you put more hp / mp regeneration for vip players?

tfs 1.3
 
Creaturescripts:

Lua:
local regenCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition:setTicks(-1)
regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 15)
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 2000)
regenCondition:setParameter(CONDITION_PARAM_MANAGAIN, 15)
regenCondition:setParameter(CONDITION_PARAM_MANATICKS, 2000)

function onLogin(player)
    if player:getStorageValue(XXXXX) == YYY then -- YOUR VIP CONDITION
        player:addCondition(regenCondition)
        return true
    end
end

Remember register the script in login.lua 🙃
 
Creaturescripts:

Lua:
local regenCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition:setTicks(-1)
regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 15)
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 2000)
regenCondition:setParameter(CONDITION_PARAM_MANAGAIN, 15)
regenCondition:setParameter(CONDITION_PARAM_MANATICKS, 2000)

function onLogin(player)
    if player:getStorageValue(XXXXX) == YYY then -- YOUR VIP CONDITION
        player:addCondition(regenCondition)
        return true
    end
end

Remember register the script in login.lua 🙃
after being placed on the server I can't login to the game
 
You need to create a script, ex: regen.lua in data/creaturescripts/scripts, and put the script that i've said.

You'll need to register the script in creaturescripts.xml, like:
Code:
<event type="login" name="regenStorage" script="regen.lua"/>

The last step, is to register the script on your server's login.lua. On my server, it's located at: data/creaturescripts/scripts/others/login.lua
Lua:
    for i = 1, #events do
        player:registerEvent("regenStorage")
    end
 
Make sure to give the if player:getStorageValue(XXXXX) == YYY then -- YOUR VIP CONDITION an storagevalue which is the same as you give to a vip player :) so XXXXX for example is 123456 and it must be equal to YYY so in this example equal to 123456
 
Make sure to give the if player:getStorageValue(XXXXX) == YYY then -- YOUR VIP CONDITION an storagevalue which is the same as you give to a vip player :) so XXXXX for example is 123456 and it must be equal to YYY so in this example equal to 123456
function onLogin(player) if player:getStorageValue(161398) < 1 then -- YOUR VIP CONDITION player:addCondition(regenCondition) return true end end

I put it like this
 
local STORAGE = 161398
storage is vip

function onLogin(player)
if player:getStorageValue(161398) > 0 then -- YOUR VIP CONDITION
player:addCondition(regenCondition)
return true
end
end

no work
Post automatically merged:

The StorageValue has to match the VIP storageValue
 
Try this :)
Lua:
function onLogin(player)
    if player:getStorageValue(161398) == 161398 then -- YOUR VIP CONDITION
        player:addCondition(regenCondition)
        return true
    end
end
 
Try this :)
Lua:
function onLogin(player)
    if player:getStorageValue(161398) == 161398 then -- YOUR VIP CONDITION
        player:addCondition(regenCondition)
        return true
    end
end
VIP is almost always used as os.time(), it's very unlikely that it would equal the storage number.
Using > 0 was the correct approach.
 
Did you register the script in login.lua? If isn't registered, it won't work.
yes
VIP is almost always used as os.time(), it's very unlikely that it would equal the storage number.
Using > 0 was the correct approach.
actions vip
local STORAGE = 161398 local TIME = 60 * 60 * 12 function onUse(player, item, fromPosition, target, toPosition, isHotkey) local cur = math.max(player:getStorageValue(STORAGE) - os.time(), 0) player:setStorageValue(161398, os.time() + cur + TIME) item:remove(1) player:sendTextMessage(MESSAGE_INFO_DESCR, "You've activated More regeneration.") player:getPosition():sendMagicEffect(15) return true end
 
When you say storage is higher than zero, which always, everyone will be VIP.
True. It's not the best approach, as it would apply for anyone who had used vip before.. but OP's attempt was wildly better then your idea. :D

This would be the correct usage in this case.
Lua:
if player:getStorageValue(161398) > os.time() then
 
As he said, os.time () is usually used, then the correct one would be:
Lua:
getStorageValue (161398) > os.time ()






Try use this:
Lua:
getStorageValue (161398) > os.time ()
True. It's not the best approach, as it would apply for anyone who had used vip before.. but OP's attempt was wildly better then your idea. :D

This would be the correct usage in this case.
Lua:
if player:getStorageValue(161398) > os.time() then
the player cannot sign in
 
Personally I would go for a source edit and doing everything via SQL, it works the same way as getting your vocation id via the database. No performance decrease as it loads only one time each time an account login
 
Back
Top