• 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 Where do I put this code I put it in talkaction but it doesn't work

Klock

New Member
Joined
Apr 22, 2024
Messages
32
Reaction score
1
Lua:
local function checkForPartyChanges(cid)
    if not isPlayer(cid) then
        return
    end
 
    if not isInParty(cid) then
        return
    end
 
    local sto = getPlayerStorageValue(cid, 4875498)
    local party = getPartyMembers(cid)
    local canEnableExpShare = true
 
    if sto == 1 then
        return
    end

    for i = 1, #party do
        for j = i + 1, #party do
            local levelDifference = math.abs(getPlayerLevel(party[i]) - getPlayerLevel(party[j]))
            if levelDifference > 15 then
                canEnableExpShare = false
                break
            end
        end
        if not canEnableExpShare then
            break
        end
    end
 
    if not canEnableExpShare then
        for i = 1, #party do
            setPlayerStorageValue(party[i], 4875498, 1)
            doPlayerSendTextMessage(party[i], 22, "The Exp in Party is disabled! Reason: Experience difference between party members.")
        end
        return
    end

    if canEnableExpShare then
        for i = 1, #party do
            setPlayerStorageValue(party[i], 4875498, 2)
        end
    end
 
    addEvent(checkForPartyChanges, 1000, cid)
end

function onSay(cid, words, param, channel)
   if isInParty(cid) then
       local party = getPartyMembers(cid)
       local canEnableExpShare = true
       local sto = getPlayerStorageValue(cid, 4875498)

       for i = 1, #party do
           for j = i + 1, #party do
               local levelDifference = math.abs(getPlayerLevel(party[i]) - getPlayerLevel(party[j]))
               if levelDifference > 15 then
                   canEnableExpShare = false
                   break
               end
           end
           if not canEnableExpShare then
               break
           end
       end

       if party[#party] == cid then
           if canEnableExpShare then
               for i = 1, #party do
                   if sto == 2 then
                       setPlayerStorageValue(party[i], 4875498, 1)
                       doPlayerSendTextMessage(party[i], 22, "The Exp in Party is disabled!")
                   else
                       setPlayerStorageValue(party[i], 4875498, 2)
                       doPlayerSendTextMessage(party[i], 22, "The Exp in Party is enabled!")
                       if cid == party[i] then
                           checkForPartyChanges(cid)
                           doPlayerSendTextMessage(party[i], 22, "Automatic Party Checker activated.")
                       end
                   end
               end
           else
               doPlayerSendTextMessage(cid, 27, "The level difference between party members cannot exceed 15 levels.")
               setPlayerStorageValue(cid, 4875498, 0)
           end
       else
           doPlayerSendTextMessage(cid, 27, "Only the leader of the party can do that!")
       end
   else
       doPlayerSendTextMessage(cid, 27, "You need to be a leader of a party to do that!")
   end
   return true  
end
 
Last edited:
onSay is a talkaction.

You would put this in data/talkactions/scripts

and then register that script in data/talkactions/talkactions.xml
 
There is no way to use the source to get XP through the game normally

data/talkactions/scripts

and then register that script in data/talkactions/talkactions.xml

I did this and I didn't function

Only the leader of the party can do that!

The level difference between party members cannot exceed 15 levels.
 
Back
Top