Hey guys, running into a problem with shared experience. I know that it is in the source code but since original Tibia didn't have shared experience you can't enable it like normal by right clicking on yourself after you are in a party.
I created a talkaction to do it but I'm getting a nil value error and I don't understand why. Here is my shared.lua:
The first part of the code works, meaning that if I am not in a party and say "!shared", I get a blue console message saying "22:38 You are not in a party."
When I am in a party and I say "!shared," this is the error I get in the console:
So I understand this message, it means that it doesn't recognize the value I'm trying to call (who is the leader of the party). But I thought that all I needed to include was cid? I don't know how else to call it so I need some help.
Thank you
I created a talkaction to do it but I'm getting a nil value error and I don't understand why. Here is my shared.lua:
Lua:
local cfg = {
inFightBlock = true,
onlyLeader = true,
}
function onSay(cid, words, param, channel)
local members = getPartyMembers(cid)
if(not(members))then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not in a party.")
return true
end
if(cfg.onlyLeader and not(iscurrentLeader(cid)))then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Only the party leader can enable/disable shared experience.")
return true
end
if(cfg.inFightBlock and hasCreatureCondition(cid, CONDITION_INFIGHT))then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You may not enable shared experience during or immediately after a fight!")
return true
end
local boolean = not(isPartySharedExperienceActive(cid))
if(setPartySharedExperience(cid, boolean))then
for _, pid in ipairs(members) do
if(not(iscurrentLeader(pid)))then
doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "Shared Experience has been "..(boolean and "activated" or "deactivated")..".")
end
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There was an error. Try again in few seconds.")
end
return true
end
The first part of the code works, meaning that if I am not in a party and say "!shared", I get a blue console message saying "22:38 You are not in a party."
When I am in a party and I say "!shared," this is the error I get in the console:
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/shared.lua:onSay
data/talkactions/scripts/shared.lua:13: attempt to call global 'iscurrentLeader' (a nil value)
stack traceback:
[C]: in function 'iscurrentLeader'
data/talkactions/scripts/shared.lua:13: in function <data/talkactions/scripts/shared.lua:6>
So I understand this message, it means that it doesn't recognize the value I'm trying to call (who is the leader of the party). But I thought that all I needed to include was cid? I don't know how else to call it so I need some help.
Thank you