• 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 Limit 3 IPs bonus

willdu

Active Member
Joined
Mar 11, 2017
Messages
91
Reaction score
25
I found this script to encourage players to make guilds, invite their friends, makers and get a bonus
But what is happen: Some players create their own guild invite 10 mc's and let this 10 mc's open to get bonus alone...

Anybody know a way to if have more then 3 characters on the same IP stop to count?

Code:
function getGuildMembersOnline(GuildId)
local players = {}
for _, pid in pairs(getPlayersOnline()) do
if getPlayerGuildId(pid) == tonumber(GuildId) then
table.insert(players, getPlayerName(pid))
end
end
return #players > 0 and players or false
end

function onLogin(cid)

   local guild_id = getPlayerGuildId(cid)
   local minimo = 1
   local max = 10
   local porcentagem = 1
   -----------------------------------------
   doPlayerSetExperienceRate(cid, 1)
   if guild_id <= 0 then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] Join a guild to have experience bonus.")
       return true
   end
   
   if guild_id > 0 then
       local membros_online = table.maxn(getGuildMembersOnline(guild_id))
       local tabela_membros = getGuildMembersOnline(guild_id)
       
       if membros_online <= minimo then
           doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] To get bonus experience must be over "..minimo.." players online guild.\nGuild of Players Online ["..membros_online.."]")
           return true
       end
   
       if membros_online > minimo then
       for var = 1, #tabela_membros do
           local nomes = getCreatureByName(tabela_membros[var])
           local XP = (membros_online <= 10) and (membros_online / 100) + 1.00 or (10/100) + 1.00   
           doPlayerSetExperienceRate(nomes, XP)   
           doPlayerSendTextMessage(nomes, MESSAGE_STATUS_CONSOLE_RED, "[GUILD] The experience of the guild members was increased to +"..membros_online*porcentagem.."% - Member "..getCreatureName(cid).." joined.")       
       end
       return true
       end
   
   end
   
   
   
   
   
end
 
Code:
function getGuildMembersOnline(GuildId)

local players = {}
for _, pid in pairs(getPlayersOnline()) do
if getPlayerGuildId(pid) == tonumber(GuildId) then
table.insert(players, getPlayerName(pid))
end
end
return #players > 0 and players or false
end
function onLogin(cid)
   local guild_id = getPlayerGuildId(cid)
   local minimo = 1
   local max = 10
   local porcentagem = 1
   -----------------------------------------
   doPlayerSetExperienceRate(cid, 1)
   if guild_id <= 0 then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] Join a guild to have experience bonus.")
       return true
   end
  
   if guild_id > 0 then
       local membros_online = table.maxn(getGuildMembersOnline(guild_id))
       local tabela_membros = getGuildMembersOnline(guild_id)
      
       if membros_online <= minimo then
           doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] To get bonus experience must be over "..minimo.." players online guild.\nGuild of Players Online ["..membros_online.."]")
           return true
       end
  
       if membros_online > minimo and getPlayerIp(cid) <=3 then 
       for var = 1, #tabela_membros do
           local nomes = getCreatureByName(tabela_membros[var])
           local XP = (membros_online <= 10) and (membros_online / 100) + 1.00 or (10/100) + 1.00 
           doPlayerSetExperienceRate(nomes, XP) 
           doPlayerSendTextMessage(nomes, MESSAGE_STATUS_CONSOLE_RED, "[GUILD] The experience of the guild members was increased to +"..membros_online*porcentagem.."% - Member "..getCreatureName(cid).." joined.")     
else
  doPlayerSendTextMessage(p.cid, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] sorry you got bounx 3 time before.")

       end
       return true
       end
  
   end


try this
 
Lua:
function getGuildMembersOnline(guildId)
    local players = {}
    for _, pid in pairs(getPlayersOnline()) do
        if (getPlayerGuildId(pid) == tonumber(guildId)) then
            players[#players+1] = getPlayerName(pid)
        end
    end
    return players
end

local function getRealMemberCount(players)
    local ips = {}
    local total = 0
    for i = 1, #players do
        local ip = getPlayerIp(players[i])
        ips[ip] = (ips[ip] or 0) + 1
        if ips[ip] <= 3 then
            total = total + 1
        end
    end
    return total
end

local minimo = 1
local max = 10
local porcentagem = 1

function onLogin(cid)
    local guild_id = getPlayerGuildId(cid)
    -----------------------------------------
    doPlayerSetExperienceRate(cid, 1)
    if guild_id == 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] Join a guild to have experience bonus.")
        return true
    end
    if guild_id > 0 then
        local tabela_membros = getGuildMembersOnline(guild_id)
        local membros_online = getRealMemberCount(tabela_membros)
        if membros_online <= minimo then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] To get bonus experience must be over "..minimo.." players online guild.\nGuild of Players Online ["..membros_online.."]")
            return true
        end
        if membros_online > minimo then
            for var = 1, #tabela_membros do
                local nomes = getCreatureByName(tabela_membros[var])
                local XP = (membros_online <= 10) and (membros_online / 100) + 1.00 or (10/100) + 1.00  
                doPlayerSetExperienceRate(nomes, XP)  
                doPlayerSendTextMessage(nomes, MESSAGE_STATUS_CONSOLE_RED, "[GUILD] The experience of the guild members was increased to +"..membros_online*porcentagem.."% - Member "..getCreatureName(cid).." joined.")      
            end
            return true
        end
    end
end
should work fine
the player count should stop once it reaches 4 players with the same ip, meaning it will count 3 of the same ip in the guild
 
Thank you so much guys...

I'm sorry i forgotten something:

How to use that function getRealMemberCount to:
- if have more then 3 players when 1 logout dont remove the bonus
i mean if have 2 players and 1 logout remove the bonus (same ip)
if have 6 players (same ip) 1 logout dont remove bonus because its still 3 players not 5,6

Code:
<event type="logout" name="ExpGuild_out" event="script" value="exp_guild_out.lua"/>

Code:
function getGuildMembersOnline(GuildId)
   local players = {}
   for _, pid in pairs(getPlayersOnline()) do
       if getPlayerGuildId(pid) == tonumber(GuildId) then
           table.insert(players, getPlayerName(pid))
       end
   end
   return #players > 0 and players or false
end

function onLogout(cid)
   local guild_id = getPlayerGuildId(cid)
   local membros_online = table.maxn(getGuildMembersOnline(guild_id))
   local tabela_membros = getGuildMembersOnline(guild_id)
   local porcentagem = 1
   local minimo = 1
   -----------------------------------------       
   if guild_id >= 1 then
       for var = 1, #tabela_membros do
           local nomes = getCreatureByName(tabela_membros[var])
           local membros_online = membros_online - 1
           
           if membros_online <= minimo then
               doPlayerSetExperienceRate(nomes, 1.0)   
               doPlayerSendTextMessage(nomes, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] No longer does the number of players needed to earn bonus experience - Member "..getCreatureName(cid).." left.")
           end
           
           if membros_online > minimo then
               local XP = (membros_online <= 10) and (membros_online / 100) + 1.00 or (10/100) + 1.00   
               doPlayerSetExperienceRate(nomes, XP)   
               doPlayerSendTextMessage(nomes, MESSAGE_STATUS_CONSOLE_RED, "[GUILD] Experience from guild members has been adjusted to "..membros_online*porcentagem.."% - Member "..getCreatureName(cid).." left.")
           end
       end
   end
   return true   
end
 
Lua:
function getGuildMembersOnline(guildId)
    local players = {}
    for _, pid in pairs(getPlayersOnline()) do
        if (getPlayerGuildId(pid) == tonumber(guildId)) then
            players[#players+1] = getPlayerName(pid)
        end
    end
    return players
end

local function getRealMemberCount(players)
    local ips = {}
    local total = 0
    for i = 1, #players do
        local ip = getPlayerIp(players[i])
        ips[ip] = (ips[ip] or 0) + 1
        if ips[ip] <= 3 then
            total = total + 1
        end
    end
    return total
end

local minimo = 1
local max = 10
local porcentagem = 1

function onLogin(cid)
    local guild_id = getPlayerGuildId(cid)
    -----------------------------------------
    doPlayerSetExperienceRate(cid, 1)
    if guild_id == 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] Join a guild to have experience bonus.")
        return true
    end
    if guild_id > 0 then
        local tabela_membros = getGuildMembersOnline(guild_id)
        local membros_online = getRealMemberCount(tabela_membros)
        if membros_online <= minimo then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] To get bonus experience must be over "..minimo.." players online guild.\nGuild of Players Online ["..membros_online.."]")
            return true
        end
        if membros_online > minimo then
            for var = 1, #tabela_membros do
                local nomes = getCreatureByName(tabela_membros[var])
                local XP = (membros_online <= 10) and (membros_online / 100) + 1.00 or (10/100) + 1.00
                doPlayerSetExperienceRate(nomes, XP)
                doPlayerSendTextMessage(nomes, MESSAGE_STATUS_CONSOLE_RED, "[GUILD] The experience of the guild members was increased to +"..membros_online*porcentagem.."% - Member "..getCreatureName(cid).." joined.")    
            end
            return true
        end
    end
end
should work fine
the player count should stop once it reaches 4 players with the same ip, meaning it will count 3 of the same ip in the guild

I enjoy the idea and try to use this.. Okey?

But not work @Xeraphus its showing me this errors:
Code:
[18:57:48.723] [Error - CreatureScript Interface]
[18:57:48.723] data/creaturescripts/scripts/exp_guild.lua:onLogin
[18:57:48.723] Description:
[18:57:48.723] (internalGetPlayerInfo) Player not found when requesting player info #28

Is it because left left that onlogout changes or another thing?
 
You need to remove best answer else if member will think it's solved

Oh okey, thank you, i didnt know
Anybody here know how to:
Thank you so much guys...

I'm sorry i forgotten something:

How to use that function getRealMemberCount to:
- if have more then 3 players when 1 logout dont remove the bonus
i mean if have 2 players and 1 logout remove the bonus (same ip)
if have 6 players (same ip) 1 logout dont remove bonus because its still 3 players not 5,6

Code:
<event type="logout" name="ExpGuild_out" event="script" value="exp_guild_out.lua"/>

Code:
function getGuildMembersOnline(GuildId)
   local players = {}
   for _, pid in pairs(getPlayersOnline()) do
       if getPlayerGuildId(pid) == tonumber(GuildId) then
           table.insert(players, getPlayerName(pid))
       end
   end
   return #players > 0 and players or false
end

function onLogout(cid)
   local guild_id = getPlayerGuildId(cid)
   local membros_online = table.maxn(getGuildMembersOnline(guild_id))
   local tabela_membros = getGuildMembersOnline(guild_id)
   local porcentagem = 1
   local minimo = 1
   -----------------------------------------      
   if guild_id >= 1 then
       for var = 1, #tabela_membros do
           local nomes = getCreatureByName(tabela_membros[var])
           local membros_online = membros_online - 1
          
           if membros_online <= minimo then
               doPlayerSetExperienceRate(nomes, 1.0)  
               doPlayerSendTextMessage(nomes, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] No longer does the number of players needed to earn bonus experience - Member "..getCreatureName(cid).." left.")
           end
          
           if membros_online > minimo then
               local XP = (membros_online <= 10) and (membros_online / 100) + 1.00 or (10/100) + 1.00  
               doPlayerSetExperienceRate(nomes, XP)  
               doPlayerSendTextMessage(nomes, MESSAGE_STATUS_CONSOLE_RED, "[GUILD] Experience from guild members has been adjusted to "..membros_online*porcentagem.."% - Member "..getCreatureName(cid).." left.")
           end
       end
   end
   return true  
end
 
Thank you so much guys...

I'm sorry i forgotten something:

How to use that function getRealMemberCount to:
- if have more then 3 players when 1 logout dont remove the bonus
i mean if have 2 players and 1 logout remove the bonus (same ip)
if have 6 players (same ip) 1 logout dont remove bonus because its still 3 players not 5,6

Code:
<event type="logout" name="ExpGuild_out" event="script" value="exp_guild_out.lua"/>

Code:
function getGuildMembersOnline(GuildId)
   local players = {}
   for _, pid in pairs(getPlayersOnline()) do
       if getPlayerGuildId(pid) == tonumber(GuildId) then
           table.insert(players, getPlayerName(pid))
       end
   end
   return #players > 0 and players or false
end

function onLogout(cid)
   local guild_id = getPlayerGuildId(cid)
   local membros_online = table.maxn(getGuildMembersOnline(guild_id))
   local tabela_membros = getGuildMembersOnline(guild_id)
   local porcentagem = 1
   local minimo = 1
   -----------------------------------------      
   if guild_id >= 1 then
       for var = 1, #tabela_membros do
           local nomes = getCreatureByName(tabela_membros[var])
           local membros_online = membros_online - 1
          
           if membros_online <= minimo then
               doPlayerSetExperienceRate(nomes, 1.0)  
               doPlayerSendTextMessage(nomes, MESSAGE_STATUS_CONSOLE_RED,"[GUILD] No longer does the number of players needed to earn bonus experience - Member "..getCreatureName(cid).." left.")
           end
          
           if membros_online > minimo then
               local XP = (membros_online <= 10) and (membros_online / 100) + 1.00 or (10/100) + 1.00  
               doPlayerSetExperienceRate(nomes, XP)  
               doPlayerSendTextMessage(nomes, MESSAGE_STATUS_CONSOLE_RED, "[GUILD] Experience from guild members has been adjusted to "..membros_online*porcentagem.."% - Member "..getCreatureName(cid).." left.")
           end
       end
   end
   return true  
end


bump
 
Back
Top