Hello everybody! I need help with a script...
I have this talkaction:
<talkaction words="!partyexp" event="script" value="partyexp.lua"/>
What calls this script:
This script will activate the sharing of experience in a party, this will only be possible if the level of all players in the party is not higher than 15 levels, both up and down. So far so good, the problem is that, for example, if there are two level 30 players in the party and they activate sharing, it will work. So, with sharing activated, if they invite a level 14 player, he will be able to receive the shared experience, because it was already activated before he joined.
I need to somehow make it so that every time a new player joins the party, sharing is automatically deactivated and I have to use the "!partyexp" command again, to check, or if anyone has any other ideas, to ensure that every time a new player joins the party, this check is carried out again to resolve this error.
Can anyone help me? Please!
I have this talkaction:
<talkaction words="!partyexp" event="script" value="partyexp.lua"/>
What calls this script:
Lua:
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!")
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
This script will activate the sharing of experience in a party, this will only be possible if the level of all players in the party is not higher than 15 levels, both up and down. So far so good, the problem is that, for example, if there are two level 30 players in the party and they activate sharing, it will work. So, with sharing activated, if they invite a level 14 player, he will be able to receive the shared experience, because it was already activated before he joined.
I need to somehow make it so that every time a new player joins the party, sharing is automatically deactivated and I have to use the "!partyexp" command again, to check, or if anyone has any other ideas, to ensure that every time a new player joins the party, this check is carried out again to resolve this error.
Can anyone help me? Please!