• 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 Interactive party OT (bonus exp)

danbsten

New Member
Joined
Aug 3, 2015
Messages
53
Reaction score
1
I wanted a way to benefit those who are hunting in a group, to make my server is up more interactive.

It would for each party member in the experiment were increased by 100% for all, reaching up to 500% (five or more people in the party)

Can anyone do it?

I use 0.4 rev3777
 
This might require a source edit, although there are functions to handle parties in the sources for scripts, this thread should be in requests.
 
Simple example, psudo code written via phone:

Code:
function onKill(player, target)
    If(player:isInParty()) then
      player:addExperience(target:getExpWorth() * (player:getParty():getMemberCount() - 1 <= 5 ? player:getParty():getMemberCount() - 1 : 5))
    End
end

May even be a bad example to be completely honest but you should get the basic idea
 
Simple example, psudo code written via phone:

Code:
function onKill(player, target)
    If(player:isInParty()) then
      player:addExperience(target:getExpWorth() * (player:getParty():getMemberCount() - 1 <= 5 ? player:getParty():getMemberCount() - 1 : 5))
    End
end

May even be a bad example to be completely honest but you should get the basic idea
I made this same mistake a while back :p
? should be and, & : should be or
Code:
function onKill(player, target)
    If(player:isInParty()) then
      player:addExperience(target:getExpWorth() * ( player:getParty():getMemberCount() - 1 <= 5 ) and player:getParty():getMemberCount() - 1 or 5)
    End
end
 
I made this same mistake a while back :p
? should be and, & : should be or
Code:
function onKill(player, target)
    If(player:isInParty()) then
      player:addExperience(target:getExpWorth() * ( player:getParty():getMemberCount() - 1 <= 5 ) and player:getParty():getMemberCount() - 1 or 5)
    End
end
Ah, my mistake. I do more c++ than LUA these days.. Thx for the correction :p
 
Ty guys

Could explain me better this function?

player:addExperience(target:getExpWorth() * ( player:getParty():getMemberCount() - 1 <= 5 ) and player:getParty():getMemberCount() - 1 or 5)

Members in party = bonus EXP?
And..

If they are not hunting together, they have very distant one of the others?
 
Ty guys

Could explain me better this function?

player:addExperience(target:getExpWorth() * ( player:getParty():getMemberCount() - 1 <= 5 ) and player:getParty():getMemberCount() - 1 or 5)

Members in party = bonus EXP?
And..

If they are not hunting together, they have very distant one of the others?

I'm not sure this will work for TFS 0.4, I think that's TFS 1.1 functions...
 
trunk 3777
Code:
    function onKill(cid, target, damage, flags)
        if getMonsterInfo(target).experience == nil then
            return false
        end
        if getPlayerParty(cid) then
            local count = #getPartyMembers(cid) - 1
            doPlayerAddExperience(cid, getMonsterInfo(target).experience * (count <= 5) and count or 5)
        end
        return true
    end
 
trunk 3777
Code:
    function onKill(cid, target, damage, flags)
        if getMonsterInfo(target).experience == nil then
            return false
        end
        if getPlayerParty(cid) then
            local count = #getPartyMembers(cid) - 1
            doPlayerAddExperience(cid, getMonsterInfo(target).experience * (count <= 5) and count or 5)
        end
        return true
    end

I try it and...
Monsters dont die, and on console:

qKtjEty.png
 
Run this and take a screen shot of the console but also tell me what you killed when the error occurred.
Code:
    function onKill(cid, target, damage, flags)
        print(cid, target, damage, flags)
        if getMonsterInfo(target).experience == nil then
            return false
        end
        if getPlayerParty(cid) then
            local count = #getPartyMembers(cid) - 1
            doPlayerAddExperience(cid, getMonsterInfo(target).experience * (count <= 5) and count or 5)
        end
        return true
    end
 
Run this and take a screen shot of the console but also tell me what you killed when the error occurred.
Code:
    function onKill(cid, target, damage, flags)
        print(cid, target, damage, flags)
        if getMonsterInfo(target).experience == nil then
            return false
        end
        if getPlayerParty(cid) then
            local count = #getPartyMembers(cid) - 1
            doPlayerAddExperience(cid, getMonsterInfo(target).experience * (count <= 5) and count or 5)
        end
        return true
    end

i killed a rotworm and:
0bhKMq2.png
 
try this
Code:
    function onKill(cid, target, damage, flags)
        local xp = getMonsterInfo(getCreatureName(target)).experience
        if xp == nil or xp == 0 then
            return false
        end
        if getPlayerParty(cid) then
            local count = #getPartyMembers(cid) - 1
            doPlayerAddExperience(cid, xp * (count <= 5) and count or 5)
        end
        return true
    end
 
Last edited:
Back
Top