• 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 idle kick dont work !

bandita315

New Member
Joined
Nov 29, 2008
Messages
48
Reaction score
0
Hello my brother from another mother !
I have some problem with idle.lua

PHP:
local config = {
	idleWarning = getConfigValue('idleWarningTime'),
	idleKick = getConfigValue('idleKickTime')
}

function onThink(cid, interval)
	if(getTileInfo(getCreaturePosition(cid)).nologout or getCreatureNoMove(cid) or
		getPlayerCustomFlagValue(cid, PlayerCustomFlag_AllowIdle)) then
		return true
	end

	local idleTime = getPlayerIdleTime(cid) + interval
	doPlayerSetIdleTime(cid, idleTime)
	if(config.idleKick > 0 and idleTime > config.idleKick) then
		doRemoveCreature(cid)
	elseif(config.idleWarning > 0 and idleTime == config.idleWarning) then
		local message = "You have been idle for " .. math.ceil(config.idleWarning / 60000) .. " minutes"
		if(config.idleKick > 0) then
			message = message .. ", you will be disconnected in "
			local diff = math.ceil((config.idleWarning - config.idleKick) / 60000)
			if(diff > 1) then
				message = message .. diff .. " minutes"
			else
				message = message .. "one minute"
			end

			message = message .. " if you are still idle"
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, message .. ".")
	end

	return true
end

This is my script... and dont kick platers ?! WTF ?

Config:
PHP:
-- The Forgotten Server Config

	-- Account manager
	accountManager = "no"
	namelockManager = "yes"
	newPlayerChooseVoc = "yes"
	newPlayerSpawnPosX = 1000
	newPlayerSpawnPosY = 1000
	newPlayerSpawnPosZ = 7
	newPlayerTownId = 1
	newPlayerLevel = 1
	newPlayerMagicLevel = 0
	generateAccountNumber = "no"

	-- Unjustified kills
	redSkullLength = 30 * 24 * 60 * 60
	blackSkullLength = 45 * 24 * 60 * 60
	dailyFragsToRedSkull = 10
	weeklyFragsToRedSkull = 30
	monthlyFragsToRedSkull = 100
	dailyFragsToBlackSkull = dailyFragsToRedSkull
	weeklyFragsToBlackSkull = weeklyFragsToRedSkull
	monthlyFragsToBlackSkull = monthlyFragsToRedSkull
	dailyFragsToBanishment = dailyFragsToRedSkull
	weeklyFragsToBanishment = weeklyFragsToRedSkull
	monthlyFragsToBanishment = monthlyFragsToRedSkull
	blackSkulledDeathHealth = 40
	blackSkulledDeathMana = 0
	useBlackSkull = "yes"
	advancedFragList = "yes"

	-- Banishments
	notationsToBan = 3
	warningsToFinalBan = 4
	warningsToDeletion = 5
	banLength = 1 * 24 * 60 * 60
	finalBanLength = 30 * 24 * 60 * 60
	ipBanishmentLength = 1 * 24 * 60 * 60
	broadcastBanishments = "yes"
	maxViolationCommentSize = 200
	violationNameReportActionType = 2
	autoBanishUnknownBytes = "no"

	-- Battle
	worldType = "pvp"
	protectionLevel = 500
	pvpTileIgnoreLevelAndVocationProtection = "yes"
	pzLocked = 20000
	huntingDuration = 60 * 1000
	criticalHitChance = 7
	criticalHitMultiplier = 1
	displayCriticalHitNotify = "yes"
	removeWeaponAmmunition = "no"
	removeWeaponCharges = "no"
	removeRuneCharges = "no"
	whiteSkullTime = 2 * 60 * 1000
	noDamageToSameLookfeet = "no"
	showHealingDamage = "yes"
	showHealingDamageForMonsters = "yes"
	fieldOwnershipDuration = 5 * 1000
	stopAttackingAtExit = "yes"
	oldConditionAccuracy = "no"
	loginProtectionPeriod = 10 * 1000
	deathLostPercent = 8
	stairhopDelay = 2 * 1000
	pushCreatureDelay = 2 * 1000
	deathContainerId = 1987
	gainExperienceColor = 35
	addManaSpentInPvPZone = "yes"
	squareColor = 0
	allowFightback = "yes"

	-- Connection config
	worldId = 0
	ip = "127.0.0.1"
	bindOnlyConfiguredIpAddress = "no"
	loginPort = 7171
	gamePort = 7172
	adminPort = 7171
	statusPort = 7171
	loginTries = 10
	retryTimeout = 5 * 1000
	loginTimeout = 60 * 1000
	maxPlayers = 250
	motd = "Witaj na Heaven-OTS.pl! Wpisz /commands aby poznac komendy"
	displayOnOrOffAtCharlist = "no"
	onePlayerOnlinePerAccount = "yes"
	allowClones = "no"
	serverName = "Heaven-OTS.pl "
	loginMessage = "Witaj na Heaven-OTS.pl   ! Wpisz /commands aby poznac komendy"
	statusTimeout = 5 * 60 * 1000
	replaceKickOnLogin = "yes"
	forceSlowConnectionsToDisconnect = "yes"
	loginOnlyWithLoginServer = "no"
	premiumPlayerSkipWaitList = "yes"

	-- Database
	sqlType = "mysql"
	sqlHost = "localhost"
	sqlPort = 3306
	sqlUser = "root"
	sqlPass = "dexter"
	sqlDatabase = "1"
	sqlFile = "forgottenserver.s3db"
	sqlKeepAlive = 0
	mysqlReadTimeout = 10
	mysqlWriteTimeout = 10
	passwordType = "plain"


	-- Deathlist
	deathListEnabled = "yes"
	deathListRequiredTime = 1 * 60 * 1000
	deathAssistCount = 19
	maxDeathRecords = 10

	-- Guilds
	ingameGuildManagement = "yes"
	levelToFormGuild = 5000
	premiumDaysToFormGuild = 0
	guildNameMinLength = 4
	guildNameMaxLength = 20

	-- Highscores
	highscoreDisplayPlayers = 15
	updateHighscoresAfterMinutes = 60

	-- Houses
	buyableAndSellableHouses = "yes"
	houseNeedPremium = "yes"
	bedsRequirePremium = "yes"
	levelToBuyHouse = 5000
	housesPerAccount = 0
	houseRentAsPrice = "no"
	housePriceAsRent = "no"
	housePriceEachSquare = 10000
	houseRentPeriod = "never"
	guildHalls = "no"

	-- Item usage
	timeBetweenActions = 200
	timeBetweenExActions = 1000
	checkCorpseOwner = "yes"
	hotkeyAimbotEnabled = "yes"
	maximumDoorLevel = 500

	-- Map
	mapName = "Evolutions"
	mapAuthor = "Komic"
	randomizeTiles = "yes"
	useHouseDataStorage = "no"
	storeTrash = "yes"
	cleanProtectedZones = "yes"
	mailboxDisabledTowns = "-1"

	-- Startup
	defaultPriority = "high"
	niceLevel = 5
	coresUsed = "-1"
	optimizeDatabaseAtStartup = "yes"
	removePremiumOnInit = "yes"
	confirmOutdatedVersion = "no"

	-- Muted buffer
	maxMessageBuffer = 4
	bufferMutedOnSpellFailure = "no"

	-- Miscellaneous
	dataDirectory = "data/"
	allowChangeOutfit = "yes"
	allowChangeColors = "yes"
	allowChangeAddons = "yes"
	disableOutfitsForPrivilegedPlayers = "no"
	bankSystem = "yes"
	saveGlobalStorage = "yes"
	displaySkillLevelOnAdvance = "yes"
	spellNameInsteadOfWords = "no"
	emoteSpells = "yes"
	promptExceptionTracerErrorBox = "yes"
	storePlayerDirection = "no"
	monsterLootMessage = 3
	monsterLootMessageType = 25

	-- Ghost mode
	ghostModeInvisibleEffect = "no"
	ghostModeSpellEffects = "yes"

	-- Limits
	idleWarningTime = 14 * 60
	idleKickTime = 15 * 60 
	expireReportsAfterReads = 1
	playerQueryDeepness = 2
	maxItemsPerPZTile = 0
	maxItemsPerHouseTile = 0

	-- Premium-related
	freePremium = "yes"
	premiumForPromotion = "yes"

	-- Blessings
	blessingsOnlyPremium = "yes"
	blessingReductionBase = 30
	blessingReductionDecreament = 5
	eachBlessReduction = 8

	-- Rates
	experienceStages = "yes"
	rateExperience = 1
	rateExperienceFromPlayers = 0
	rateSkill = 100	
	rateMagic = 60
	rateLoot = 50
	rateSpawn = 10

	-- Experience from players
	minLevelThresholdForKilledPlayer = 0
	maxLevelThresholdForKilledPlayer = 0

	-- Stamina
	rateStaminaLoss = 1
	rateStaminaGain = 1000 / 3
	rateStaminaThresholdGain = 4
	staminaRatingLimitTop = 41 * 60
	staminaRatingLimitBottom = 14 * 60
	rateStaminaAboveNormal = 1.5
	rateStaminaUnderNormal = 0.5
	staminaThresholdOnlyPremium = "yes"

	-- Party
	experienceShareRadiusX = 30
	experienceShareRadiusY = 30
	experienceShareRadiusZ = 1
	experienceShareLevelDifference = 2 / 3
	extraPartyExperienceLimit = 20
	extraPartyExperiencePercent = 5
	experienceShareActivity = 2 * 60 * 1000

	-- Global save
	globalSaveEnabled = "yes"
	globalSaveHour = 2
	shutdownAtGlobalSave = "no"
	cleanMapAtGlobalSave = "yes"

	-- Spawns
	deSpawnRange = 2
	deSpawnRadius = 50

	-- Summons
	maxPlayerSummons = 2
	teleportAllSummons = "no"
	teleportPlayerSummons = "no"

	-- Status
	ownerName = ""
	ownerEmail = "@otland.net"
	url = "http://10.8.4.25/"
	location = "Europe"
	displayGamemastersWithOnlineCommand = "no"

	-- Logs
	adminLogsEnabled = "no"
	displayPlayersLogging = "yes"
	prefixChannelLogs = ""
	runFile = ""
	outLogName = ""
	errorLogName = ""
	truncateLogsOnStartup = "no"

Help me pleeeeeeease !! ; *
 
Have you added registring in login part?

I`m from polish- dont understood ; /
My login.lua

PHP:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
SQL_COMUNICATION_INTERVAL = SQL_interval * 1000
function onLogin(cid)
	if(InitShopComunication == 0) then
		local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, {})
		InitShopComunication = eventServ
	end
	registerCreatureEvent(cid, "PlayerDeath")
	return TRUE
end

function sql_communication(parameters)
	dofile("./config.lua")
	env = assert(luasql.mysql())
	con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
	result_plr = assert(con:execute("SELECT * FROM z_ots_comunication WHERE `type` = 'login';"))
	todo = result_plr:fetch({}, "a")
	while todo do
		id = tonumber(todo.id)
		action = tostring(todo.action)
		delete = tonumber(todo.delete_it)
		cid = getPlayerByName(tostring(todo.name))
		if isPlayer(cid) == TRUE then
			local itemtogive_id = tonumber(todo.param1)
			local itemtogive_count = tonumber(todo.param2)
			local container_id = tonumber(todo.param3)
			local container_count = tonumber(todo.param4)
			local add_item_type = tostring(todo.param5)
			local add_item_name = tostring(todo.param6)
			local received_item = 0
			local full_weight = 0
			if add_item_type == 'container' then
				container_weight = getItemWeight(container_id, 1)
				if isItemRune(itemtogive_id) == TRUE then
					items_weight = container_count * getItemWeight(itemtogive_id, 1)
				else
					items_weight = container_count * getItemWeight(itemtogive_id, itemtogive_count)
				end
				full_weight = items_weight + container_weight
			else
				full_weight = getItemWeight(itemtogive_id, itemtogive_count)
				if isItemRune(itemtogive_id) == TRUE then
					full_weight = getItemWeight(itemtogive_id, 1)
				else
					full_weight = getItemWeight(itemtogive_id, itemtogive_count)
				end
			end
			local free_cap = getPlayerFreeCap(cid)
			if full_weight <= free_cap then
				if add_item_type == 'container' then
					local new_container = doCreateItemEx(container_id, 1)
					local iter = 0
					while iter ~= container_count do
						doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
						iter = iter + 1
					end
					received_item = doPlayerAddItemEx(cid, new_container)
				else
					local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
					received_item = doPlayerAddItemEx(cid, new_item)
				end
				if received_item == RETURNVALUE_NOERROR then
					doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')
					delete = assert(con:execute("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";"))
					assert(con:execute("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";"))
				else
					doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
				end
			else
				doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
			end
		end
		todo = result_plr:fetch (todo, "a")
	end
	con:close()
	env:close()
	local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, parameters)
end


function onLogin(cid)
    if(InitHistory == 0) then
        local historyPage = addEvent(historyPage, 60000, {})
        InitHistory = historyPage
    end
    registerCreatureEvent(cid, "PlayerDeath")
    return TRUE
end

function historyPage(parameters)
    local historyPage = addEvent(historyPage, 60000, {})
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
        setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
        db.executeQuery("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;")
        db.executeQuery("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
    end
    db.executeQuery("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;")
end
 
I don't really understand that well, but if no one can log off,
have you put "no-logout zone" area? maybe in the map editor you can change it.
 
I think he have to add:
Code:
registerCreatureEvent(cid, "Idle")

In login.lua
 
Back
Top