• 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 No more crash by magebomb

Svetrey

3+3*3 = ?
Joined
Aug 5, 2008
Messages
233
Reaction score
0
Open your creturescripts folder and go to scripts.
Make login2.lua and paste there:
Code:
-- Script made by Huggen --
-- Make players can´t log in if it haven´t gone 2 sec from last player --
-- Config --
storage = 9876
seconds = 2
-- Config --
function onLogin(cid)
    gone = os.time()
    if getGlobalStorageValue(storage)+seconds < gone then
        setGlobalStorageValue(storage, os.time())
        return TRUE
    else
        return FALSE
    end
return TRUE
end

Add in creatureevents.xml:
Code:
<event type="login" name="PlayerLogin" event="script" value="login2.lua"/>
 
Idea good, but why using global storage? ;P And also it could be more configurable, for same IP

Look:
Code:
local config = {
	loginDelay = 2,		-- in seconds
	onlyWithSameIP = "yes"	-- will work for all players ("no"), or only check player with same IP? ("yes")
}

--DONT MODIFY
config.onlyWithSameIP = getBooleanFromString(config.onlyWithSameIP)

local m_lastLogin, m_lastIP = 0, 0

function onLogin(cid)
	local timeNow, playerIP = os.time(), getPlayerIp(cid)
	if(m_lastLogin + seconds >= timeNow and
		(config.onlyWithSameIP == FALSE or m_lastIP == playerIP)) then
		return FALSE
	end

	m_lastIP = playerIP
	m_lastLogin = timeNow
	return TRUE
end
 
/\ It won't work that as I wanted because some people have proxy server or something like this and they login with other IP on each character.
 
@UP
When I put this script into my server, no one can crash my server by magebomb:)
 
Need some help, for got the ip too I have to make this: ?

PHP:
-- Script made by Huggen --
-- Make players can´t log in if it haven´t gone 2 sec from last player --
-- Config --
storage = 9876
seconds = 2
-- Config --
function onLogin(cid)
    gone = os.time()
    if getGlobalStorageValue(storage)+seconds < gone then
        setGlobalStorageValue(storage, os.time())
        return TRUE
    else
        return FALSE
    end
return TRUE
end

local config = {
	loginDelay = 2,		-- in seconds
	onlyWithSameIP = "yes"	-- will work for all players ("no"), or only check player with same IP? ("yes")
}

--DONT MODIFY
config.onlyWithSameIP = getBooleanFromString(config.onlyWithSameIP)

local m_lastLogin, m_lastIP = 0, 0

function onLogin(cid)
	local timeNow, playerIP = os.time(), getPlayerIp(cid)
	if(m_lastLogin + seconds >= timeNow and
		(config.onlyWithSameIP == FALSE or m_lastIP == playerIP)) then
		return FALSE
	end

	m_lastIP = playerIP
	m_lastLogin = timeNow
	return TRUE
end

I go rep++
 
Fixed version, with IP block (You can't also do fast relog)

Lua:
local config = {
	seconds = 2,		-- in seconds
	onlyWithSameIP = "yes"	-- will work for all players ("no"), or only check player with same IP? ("yes")
}

--DONT MODIFY
config.onlyWithSameIP = getBooleanFromString(config.onlyWithSameIP)

local m_lastLogin, m_lastIP = 0, 0

function onLogin(cid)
	local timeNow, playerIP = os.time(), getPlayerIp(cid)
	if(m_lastLogin + config.seconds >= timeNow and
		(config.onlyWithSameIP == FALSE or m_lastIP == playerIP)) then
		return FALSE
	end

	m_lastIP = playerIP
	m_lastLogin = timeNow
	return TRUE
end
 
That's a very nice idea. ;) I think I'm gonna use it and update it a bit.

Code:
local config = {
        seconds = 2,            -- in seconds
        onlyWithSameIP = "yes"  -- will work for all players ("no"), or only check player with same IP? ("yes")
        logPlayerName = "yes"
}

--DONT MODIFY
config.onlyWithSameIP = getBooleanFromString(config.onlyWithSameIP)
config.logPlayerName = getBooleanFromString(config.logPlayerName)

local m_lastLogin, m_lastIP = 0, 0

function onLogin(cid)
	local timeNow, playerIP, playerName = os.time(), getPlayerIp(cid), getPlayerName(cid)
	if(m_lastLogin + config.seconds >= timeNow and (config.onlyWithSameIP == FALSE or m_lastIP == playerIP)) then
		if config.logPlayerName == TRUE then
			doWriteLogFile("multiIp.txt", .. playerName" ; \n")
		end
		return FALSE
	end

	m_lastIP = playerIP
	m_lastLogin = timeNow
	return TRUE
end

It will now log the player names.^_^
 
Last edited:
this script works with both versions? 0.2 and 0.3?

For both, but for 0.2 you need to copy few things from functions.lua

getBooleanFromString
and
doWriteLogFile

#Edit
I see in 0.2 getPlayerIp(cid) does not exists.. there is just getIPByPlayerName(name) so you can use
getIPByPlayerName(getPlayerName(cid))
 
For 0.2:
Code:
local config = {
        seconds = 2,		-- in seconds
        onlyWithSameIP = TRUE	-- will work for all players (FALSE), or only check player with same IP? (TRUE)
}

local m_lastLogin, m_lastIP = 0, 0

function onLogin(cid)
        local timeNow, playerIP = os.time(), getIPByPlayerName(getPlayerName(cid))
        if(m_lastLogin + config.seconds >= timeNow and
                (config.onlyWithSameIP == FALSE or m_lastIP == playerIP)) then
                return FALSE
        end

        m_lastIP = playerIP
        m_lastLogin = timeNow
        return TRUE
end
 
For 0.2:
Code:
local config = {
        seconds = 2,		-- in seconds
        onlyWithSameIP = TRUE	-- will work for all players (FALSE), or only check player with same IP? (TRUE)
}

local m_lastLogin, m_lastIP = 0, 0

function onLogin(cid)
        local timeNow, playerIP = os.time(), getIPByPlayerName(getPlayerName(cid))
        if(m_lastLogin + config.seconds >= timeNow and
                (config.onlyWithSameIP == FALSE or m_lastIP == playerIP)) then
                return FALSE
        end

        m_lastIP = playerIP
        m_lastLogin = timeNow
        return TRUE
end

Works PERFECT!
Thanks ofc rep++
 
doesnt works for me :( im using tfs 0.3 beta 2 and well, players can still make mage bombs and nothing happends to them :p
 
Back
Top