• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

RevScripts onKill

alcapone

Member
Joined
Jan 13, 2021
Messages
237
Reaction score
18
Lua:
local test = CreatureEvent("test")
function test.onKill(player, target)

     local monster = config[target:getName():lower()]
     if target:isPlayer() or not monster or target:getMaster() then
         return true
     end
    
    local stor = player:getStorageValue(monster.storage)+1
    
    if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
         player:setStorageValue(monster.storage, stor)
      
     end
    
      
     if (stor +1) == monster.amount then
    
        player:setStorageValue(monster.storage, stor +1)
                  
     end
    
    
     return true
end
test:register()

I have a problem with two players, the mobi is only counting for 1 player
 
S

Shadow_

Guest
Lua:
local test = CreatureEvent("test")
function test.onKill(player, target)

     local monster = config[target:getName():lower()]
     if target:isPlayer() or not monster or target:getMaster() then
         return true
     end
     for currentPlayerId, currentDamage in pairs(target:getDamageMap()) do
        local currentPlayer = Player(currentPlayerId)
        if currentPlayer then
            local stor = currentPlayer:getStorageValue(monster.storage)+1

            if stor < monster.amount and currentPlayer:getStorageValue(monster.startstorage) >= monster.startvalue then
                 currentPlayer:setStorageValue(monster.storage, stor)

             end


             if (stor +1) == monster.amount then

                currentPlayer:setStorageValue(monster.storage, stor +1)

             end
        end
    end
    return true
end
test:register()

getDamageMap() will return a table that looks that way

[PlayerId] = DMGValue
[425] = 5000

so we call a for loop for the key to roll on the table and bring the player by his id in our code to cast the script on all players who did dmg on the monster
 
OP
OP
A

alcapone

Member
Joined
Jan 13, 2021
Messages
237
Reaction score
18
Lua:
local test = CreatureEvent("test")
function test.onKill(player, target)

     local monster = config[target:getName():lower()]
     if target:isPlayer() or not monster or target:getMaster() then
         return true
     end
     for currentPlayerId, currentDamage in pairs(target:getDamageMap()) do
        local currentPlayer = Player(currentPlayerId)
        if currentPlayer then
            local stor = currentPlayer:getStorageValue(monster.storage)+1

            if stor < monster.amount and currentPlayer:getStorageValue(monster.startstorage) >= monster.startvalue then
                 currentPlayer:setStorageValue(monster.storage, stor)

             end


             if (stor +1) == monster.amount then

                currentPlayer:setStorageValue(monster.storage, stor +1)

             end
        end
    end
    return true
end
test:register()

getDamageMap() will return a table that looks that way

[PlayerId] = DMGValue
[425] = 5000

so we call a for loop for the key to roll on the table and bring the player by his id in our code to cast the script on all players who did dmg on the monster
more than 1 person it counts 1 before giving the monster exp and when giving the exp add again to storage
 

pink_panther

Excellent OT User
Joined
Sep 10, 2016
Messages
1,132
Solutions
13
Reaction score
582
Location
Kazordoon
what sources are you using?

therse a bug in older tfs that counts kill for monsters twice, which it should only do for pvp kills to give out unjustified kills, it shouldn't do this for monster kills
 
OP
OP
A

alcapone

Member
Joined
Jan 13, 2021
Messages
237
Reaction score
18
what sources are you using?

therse a bug in older tfs that counts kill for monsters twice, which it should only do for pvp kills to give out unjustified kills, it shouldn't do this for monster kills
I understand I tested other task scripts that worked and the count worked, but this one did not work when the player gains the monster's exp, the count is made again
 
Top