• 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 Lua Experience bonus for MC

G3

:P
Joined
Sep 6, 2014
Messages
28
Reaction score
0
How do I check if the player is using MC will receive experience bonus


I make this script, but is not working. (TFS 1.0)

Code:
function onKill(cid, target, lastHit)
     local attackMonster = Monster(target)
     if not attackMonster then
         return true
     end

     for id, damage in pairs(attackMonster:getDamageMap()) do
         local player = Player(id)
         if player then
             if #getPlayersByIp(getPlayerIp(cid)) >= 2 then
                 local experience = MonsterType(attackMonster:getName()):getExperience()
                 local expFormula = (experience * 0.5)
                 player:addExperience(math.floor(expFormula), true)
             end
         end
     end
     return true
end
 
Last edited by a moderator:
Very interesting. It looks like it should work, I don't know much about the return on :getDamageMap() but I do recall that it's a table. Maybe try inserting some print's under each check to figure out if it's passing each check. That should help you narrow the problem down quickly. You definitely look like you know what you are doing so just try that out, I'm sure it will help you get the problem solved quickly.
 
erro

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/expmc.lua:eek:nKill
data/creaturescripts/scripts/others/expmc.lua:10: attempt to call global 'getPlayersByIp' (a nil value)
stack traceback:
[C]: in function 'getPlayersByIp'
data/creaturescripts/scripts/others/expmc.lua:10: in function <data/creaturescripts/scripts/others/expmc.lua:1>
 
That's because you don't have that function defined anywhere. It should be in your global or compat libs. Search on github main branch or even on here for that function and add it to your global.lua
 
Back
Top