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

CreatureEvent Anti-MC with Disclaimer [0.4]

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,731
Solutions
7
Reaction score
537
Location
Canada
Credits to Bogart who posted the original on the forum!

The script was great, but there was one thing I didn't find appealing which was the fact it showed the FYI popup every time you logged in. So I made a slight modification to check if the player is at his limit first, then send a FYI for 2.5 seconds and kick them off. This way, the player has a short disclaimer so he knows why he got kicked, but its not repeated everytime they login without being at the limit.
I know there's really no point in posting this, but hopefully someone will find it useful.

Create creaturescripts/scripts/antimc.lua
Code:
local config = {
max = 3, -- Maximum Clients Allowed Connected
text = "Sorry, we only allow up to 3 Multi-Clients.", -- PopupFYI Text
group_id = 1 -- This will only kick players with Group 1 (Player)
}

local accepted_ip_list = "127.0.0.1" -- IP's allowed to MC

local function AntiMC(p)
    if #getPlayersByIp(getPlayerIp(p.pid)) >= p.max then
        doPlayerPopupFYI(p.pid, config.text)
        addEvent(doRemoveCreature, 2500, p.pid)
    end
    return TRUE
end

function onLogin(cid)
    if getPlayerGroupId(cid) <= config.group_id then
        if isInArray(accepted_ip_list,getPlayerIp(cid)) == FALSE then
                addEvent(AntiMC, 1000, {pid = cid, max = config.max+1})
            end
        end
    return TRUE
end

Paste in creaturescripts/scripts/login.lua
Code:
registerCreatureEvent(cid, "AntiMC")

Paste in creaturescripts/creaturescripts.xml
Code:
<event type="login" name="AntiMC" event="script" value="antimc.lua"/>

Image:
source.gif


Regards,
Extrodus
 
Last edited:
Wouldn't it be better to send that information in the form of a motd? I have no idea if that is possible without a source edit. Instead of getting the character list window they get the motd window with the message. Similar to the motd which welcomes you to the game.
 
@A-Syntax - Yeah, I figured you'd need to do a source edit to send a motd before the player enters the game. Well, one time when I was testing different things with the timing, the PopupFYI showed up right after I clicked my character to log in, then I relogged and it didn't do it again. Because if it would just show up on the login screen like it did that once, that'd be better but - meh. This did the job for me.
 
So what about people on LAN? Or family playing? They would be affected by this I guess?
 
@Tony32 - Most definitely, that's where the "Accepted IPs" comes into play. If you can prove with the players in-game that they are all individual people/live in one house together; just /info playername and get their IP then add it to the list.
Hopefully that resolves any issues they would be having to connect. :)
 
The script should check if the player exists then after that removes, because the player can logoff many times and after a few short time the server crash, :p
 
couldn't you send an FYI window onLogin and then return false o-o
edit: nope lol
another edit: the script has "127.0.0.1" as a string and not in an array, should be like this
Code:
local accepted_ip_list = {'127.0.0.1'}
and when checking inside the array you use tostring(getPlayerIp(cid))

also there's a function in 0.4: getPlayersByIp(ip[, mask = 0xFFFFFFFF]) which you can use to check online players with that ip too :)
 
Last edited:
Back
Top