• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Talkaction to others players guild

gmstrikker

Well-Known Member
Joined
Jul 30, 2014
Messages
458
Solutions
1
Reaction score
50
I need help with this code:


The problem with this code is in these lines:
Code:
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have received 3 premium days (GUILD BONUS).")
setPlayerStorageValue(cid, 666, os.time()+days*86400)

These lines being applied to the leader of the guild (which uses the command), but members do not receive the message and the 3 days of storage.

Why?

The rest of the whole code is working!
code:
Code:
local playersNeeded = 2
local ipsNeeded = 0
local minimumLevel = 1
local storageId = 47581

local function sendPlayersList(cid, list)
for i, pid in ipairs(list) do
local level = getPlayerLevel(pid) < minimumLevel and " - " .. getPlayerLevel(cid) .. " level " or ""
local valid = getCreatureStorage(pid, storageId) > 1 and " - already received!" or ""
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(pid) .. level)
end
end

function onSay(cid, words, param, channel)
if(getPlayerGuildLevel(cid) == 3) then
local leaderGuild = getPlayerGuildId(cid)
local players = getPlayersOnline()
local guildMembersValid = {}
local guildMembersInvalid = {}
for i, pid in ipairs(players) do
if(leaderGuild == getPlayerGuildId(pid)) then
if(getPlayerLevel(pid) >= minimumLevel and tonumber(getCreatureStorage(pid, storageId)) < 2) then
table.insert(guildMembersValid, pid)
else
table.insert(guildMembersInvalid, pid)
end
end
end

if(#guildMembersValid >= playersNeeded) then
local IPs = {}
for i, pid in ipairs(guildMembersValid) do
local ip = getPlayerIp(pid)
if(IPs[ip] == nil) then
IPs[ip] = ip
end
end
if(#IPs >= ipsNeeded) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Players that received points:")
sendPlayersList(cid, guildMembersValid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Players that did not receive points:")
sendPlayersList(cid, guildMembersInvalid)
local accounts = {}
for i, pid in ipairs(guildMembersValid) do
-- coloca o item aqui
--local item = doCreateItemEx(6527, 20)
--doPlayerAddItemEx(cid, item, true)

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have received 3 premium days (GUILD BONUS).")
setPlayerStorageValue(cid, 666, os.time()+3*86400)

table.insert(accounts, getPlayerAccountId(pid))
doCreatureSetStorage(pid, storageId, os.time())
end
-- aqui coloca pra dar uma vez pro líder
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, #guildMembersValid .. " players from your guild are valid (" .. playersNeeded .. " required), but you have together only " .. #IPs .. " IPs (" .. ipsNeeded .. " required)")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Valid players:")
sendPlayersList(cid, guildMembersValid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Invalid players:")
sendPlayersList(cid, guildMembersInvalid)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, #guildMembersValid .. " players from your guild are valid, " .. playersNeeded .. " required. Minimum level required is " .. minimumLevel)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Valid players:")
sendPlayersList(cid, guildMembersValid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Invalid players:")
sendPlayersList(cid, guildMembersInvalid)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Only guild leader can request points.")
end
return true
end
 
Last edited:
I might be tired but where does the script get the value days from

setPlayerStorageValue(cid, 666, os.time()+days*86400)
 
Tab your fking scripts...
Code:
for i, pid in ipairs(guildMembersValid) do
-- coloca o item aqui
--local item = doCreateItemEx(6527, 20)
--doPlayerAddItemEx(cid, item, true)

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have received 3 premium days (GUILD BONUS).")
setPlayerStorageValue(cid, 666, os.time()+days*86400)

table.insert(accounts, getPlayerAccountId(pid))
doCreatureSetStorage(pid, storageId, os.time())
end

Hint: array variables.
 
I don't know if your problem is already solved but just change cid to pid on the two lines that you provided.

A good ide is to try and get them to find the problem, otherwise he will be back tomorow with the exact same problem.
 
It was only comrade, I mistook me time to put those who receive, put the variable of who uses the command and not to those inside the loop and had not realized it, he just helped with a simple thing that I have not seen
 
It was only comrade, I mistook me time to put those who receive, put the variable of who uses the command and not to those inside the loop and had not realized it, he just helped with a simple thing that I have not seen

And that is the point, so you can learn how do find things like this on your own, insted of creating a post everytime you run into a problem.
If everyone did it that way this forum would have a billion threads.
 
Back
Top