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

Lua Soul ring, dont work [tfs 0.3.6]

Keeq

New Member
Joined
Nov 6, 2012
Messages
100
Reaction score
0
Hello, i find script on soul necklace.
I searched the whole forum and did not find it :/
I need a script that regenerate 1 soul per 5 second

I found only this, but dont work

Lua:
local soul_ring = {}
local function addSoul(player, n)
   if not player:isPlayer then
       return true
   end
   if soul_ring[player] == n then
       player:addSoul(player:getSoul() + 2)
       soul_ring[player] = soul_ring[player] + 1
       addEvent(addSoul, 1000, player, n + 1)
   end
end
function onEquip(player, item, slot)
   soul_ring[player] = 1
   addEvent(addSoul, 1000, player, 1)
   return true
end
function onDeEquip(player, item, slot)
   soul_ring[player] = 0
   return true
end


and XML


Code:
    <movevent event="Equip" itemid="2125" function="onEquipItem" slot="necklace" script="souls.lua" />
<movevent event="DeEquip" itemid="2125" function="onDeEquipItem" slot="necklace" script="souls.lua" />

Can help me? please
 
Author say "I use it like this on my 0.3.7 server."
So it's weird,..

Do you have a working script on my tfs?
 
Test this one instead
Lua:
-- Soul ring script by Mummrik @otland.net
local delay = 5   -- in seconds
local soul = 1   -- amount of souls each tick
local soulRing = {}

local function addSoul(cid)
   if not isPlayer(cid) then
       return true
   end
   if isPremium(cid) and getPlayerSoul(cid) < 200 then
       doPlayerAddSoul(cid, soul)
       soulRing[cid] = addEvent(addSoul, delay * 1000, cid)
   elseif not isPremium(cid) and getPlayerSoul(cid) < 100 then
       doPlayerAddSoul(cid, soul)
       soulRing[cid] = addEvent(addSoul, delay * 1000, cid)
   else
       soulRing[cid] = addEvent(addSoul, delay * 1000, cid)
   end
end

function onEquip(cid, item, slot)
   soulRing[cid] = addEvent(addSoul, delay * 1000, cid)
   return true
end

function onDeEquip(cid, item, slot)
   stopEvent(soulRing[cid])
   soulRing[cid] = nil
   return true
end

Edit:
I did not test the script, but it should work. Else msg me and we will make it work
 
Last edited:
Don;t work ;/
0 in log
replace for this in movements.xml
XML:
<movevent type="Equip" itemid="2125" slot="necklace" event="script" value="souls.lua"/>
<movevent type="DeEquip" itemid="2125" slot="necklace" event="script" value="souls.lua"/>

then restart the server and then you put the amulet in the necklace slot

Edit:
make sure the player got less than 200 soul or less than 100 soul if the players is free account

Edit2:
use this script for debuging
Lua:
-- Soul ring script by Mummrik @otland.net
local debugScript = true   -- true/false, just for testing
local delay = 5       -- in seconds
local soul = 1       -- amount of souls each tick
local soulRing = {}
local function addSoul(cid)
   if not isPlayer(cid) then
       if debugScript then
           print("Soul ring script executed by something that isn't a player")
       end
       return true
   end
   if isPremium(cid) and getPlayerSoul(cid) < 200 then
       if debugScript then
           print(""..getCreatureName(cid).." is premium and got less than 200 soul points, added 1 soul to the player")
       end
       doPlayerAddSoul(cid, soul)
       soulRing[cid] = addEvent(addSoul, delay * 1000, cid)
   elseif not isPremium(cid) and getPlayerSoul(cid) < 100 then
       if debugScript then
           print(""..getCreatureName(cid).." is NOT premium and got less than 100 soul points, added 1 soul to the player")
       end
       doPlayerAddSoul(cid, soul)
       soulRing[cid] = addEvent(addSoul, delay * 1000, cid)
   else
       if debugScript then
           print(""..getCreatureName(cid).." got max soul points")
       end
       soulRing[cid] = addEvent(addSoul, delay * 1000, cid)
   end
end
function onEquip(cid, item, slot)
   if debugScript then
       print(""..getCreatureName(cid).." equiped a soul regain item")
   end
   soulRing[cid] = addEvent(addSoul, delay * 1000, cid)
   return true
end
function onDeEquip(cid, item, slot)
   if debugScript then
       print(""..getCreatureName(cid).." deEquiped a soul regain item")
   end
   stopEvent(soulRing[cid])
   soulRing[cid] = nil
   return true
end
 
Last edited:
Add soul work, but print " is premium and got less than 200 soul points, added 1 soul to the player" and others dont work
But thanks for help :)
 
Add soul work, but print " is premium and got less than 200 soul points, added 1 soul to the player" and others dont work
But thanks for help :)
So you got it to work, well it should print msg's to your server consol, you must miss something then. Did you set "local debugScript = true -- true/false, just for testing" to true?
well keep an eye on the script and test it well to make sure it work 100%, it might bug if player got the amulet equiped and then logout and login again. Then the player have to re-equip the amulet, im not sure though. But that is one bug i think can occur.
Im glad i could help you to this point atleast :)
 
Sory, i tested and

It works weird, just put it on once and take it off, and the soul gain all the time. and when you take off and dress a few times, soul is gain faster and faster :/
Can you fix? :D
 
Back
Top