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

addiction to cigarettes

zoubiey

New Member
Joined
Dec 9, 2008
Messages
405
Reaction score
2
Location
Sweden / Piteå
Yo!


I made an cigarette script. And i want that when someone use the cigarette, he will get addiction to it. And if he dont smoke again in like 3 minutes or something he will start to loose health. If someone help me he will get rep++.
 
LOL, awesome idea. I'd love this script. I might write it later when I get a little time ;)
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
Random Example

Actions/scripts/script.lua

Lua:
local health =
{
	minDamage = 10,
	maxDamage = 50
}

local cigarette = XXXX -- Item of Cig
local breath = 1 -- Minutes
local healthCare = math.random(cfg.minDamage, cfg.maxDamage)

function onUse(cid, item, fromPos, item2, toPos)
	if (item.itemid == cigarette) then
		addEvent(addiction, breath * 60000)
	end
	return TRUE
end

local function addiction()
	if getPlayerItemCount(cid, cigarette) == 1 then
		doCreatureAddHealth(cid, -healthCare)
		doCreatureSay(cid, "Fuuuhh....", TALKTYPE_ORANGE_1)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	end
	return TRUE
end

I gotta go, so I can't fix it...
Feel free to experiment!
 
JDB I got an idea, it keeps getting u addicted untill you go sleep to the bed, what about this huh? :D And the cigarette should disappear when u use it 3-5 times ^^ btw i know it was late xD

Lua:
local healthCare = math.random(health.minDamage, health.maxDamage

And also it says callback parameter should be a function u_U (addEvent)
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
Functions.lua:
Code:
function addiction(cid)
	local level = getPlayerLevel(cid)
	if (isPlayer(cid) and getPlayerStorageValue(cid, 54321) > 0) then
		doCreatureAddHealth(cid, -math.random(level, level+150))
		doSendAnimatedText(getCreaturePosition(cid), "Fuuuuhh...", TEXTCOLOR_WHITE)
		addEvent(addiction, 1 * 60 * 1000, cid)
	end
end

Login.lua:
Code:
function onLogin(cid)
	if (getPlayerStorageValue(cid, 54321) > 0) then
		addEvent(addiction, 1 * 60 * 1000, cid)
	end
	return true
end

Cigarette.lua:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	setPlayerStorageValue(cid, 54321, 1)
	addEvent(addiction, 1 * 60 * 1000, cid) 
	return true
end

Bed.lua:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	setPlayerStorageValue(cid, 54321, -1)
	return true
end
 
Last edited:
Yea it stops the addiction when clicking on bed but doesn't go sleep :p also, when using cigarette stop the addiction for x time.
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
Back
Top