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

{Solved}Party Checking

@up
I hadn't.

Code:
local partycheck = (party == nil or type(party) ~= 'table' or table.maxn(party) <= 1 or tmp <= 1) and false or true
This line is wrong. Look:
Code:
local partycheck = (false ... ) and false or true
It will be a true because the first or any other condition is false.

Now, party members.

Code:
local members, result = getPartyMembers(cid), false
-- You need to check if party exists
for _, pmem in pairs(members) do
    if(getPlayerStorageValue(pmem, 10000) == 1) then
        result = true
    end
end

if(result) then
    for _, pmem in pairs(members) do
        doAddCondition(pmem, condition)
    end
end
 
Last edited:
I just typed out a better explanation of what I want:

1) Check nearby party members.
2) Check for storage 10000 on anyone in your party.
3) Add EXP to yourself and your nearby party if someone has the storage.


Code:
function onCastSpell(cid, var)
    local partyList = {}                                   
    local tmp = table.maxn(partyList)                                   
    local partycheck = (party == nil or type(party) ~= 'table' or table.maxn(party) <= 1 or tmp <= 1) and false or true
    local pos = getCreaturePosition(cid)

    if partycheck == true then
        for _, pid in ipairs(party) do
            if(getDistanceBetween(getCreaturePosition(pid), pos) <= 36) then
                table.insert(partyList, pid)
            end
        end
    end

    for _, pid in ipairs(partyList) do
        if getPlayerStorageValue(pid, 10000) == 1 or getPlayerStorageValue(cid, 10000) == 1 then
            doPlayerAddExp(pid, 10)
            doPlayerAddExp(cid, 10)
        end
    end

    return true
end
Could you help me out? I am almost grasping it.
 
Code:
function onCastSpell(cid, var)
    local partyMembers, storageResult = getPartyMembers(cid), false
    local nearbyMembers, pos = {}, getCreaturePosition(cid)
   
    if(partyMembers) then
        for _, pid in pairs(partyMembers) do
            if(getDistanceBetween(getCreaturePosition(pid), pos) <= 36) then
                if(getPlayerStorageValue(pid, 10000) == 1) then storageResult = true end
                table.insert(nearbyMembers, pid)
            end
        end
       
        if(storageResult) then
            for _, pid in pairs(nearbyMembers) do
                doPlayerAddExp(pid, 10)
            end
        end
    end
   
return true
end

Check that one and let me know if it works.
 
@up - That script is only giving EXP to players who have that storage. I want the whole party to get EXP if even a single person has the storage. I moved this to Party Checking #2
 
Well, either way its not working as it is:

Code:
bad argument #1 to 'pairs' (table expected, got boolean)
stack traceback:
[C]: at 0x013f4ad3e0
[C]: in function 'pairs'
 
Back
Top