• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Cigarette - using action id

95seba

Amateur Scripter
Joined
Oct 24, 2009
Messages
11
Reaction score
0
Location
Poland
Hello. This is one from my first scripts, enjoy:

Open folder create file named cigarette.lua and copy this in file:
Code:
-- Script made by GOD Kermer
-- Xevo OTS - http://xevo.no-ip.org
-- E-Mail - [email protected]
function onUse(cid, item, frompos, item2, topos)
local playerpos = getPlayerPosition(cid)
local hp = getCreatureHealth(cid)
doSendMagicEffect(frompos,2)
		if item.itemid == 7499 and item.actionid == 3342 then
				if hp > 20 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 34)
						doSendAnimatedText(getPlayerPosition(cid), "Buh...", 129)
						doCreatureAddHealth(cid,-30) 
						doSetItemActionId(item.uid, 3343)
						doSetItemSpecialDescription(item.uid, "This cigarette is in 2/10 burned.")
				else
						doPlayerSendCancel(cid, "You are too weak for this!")
				end	
		elseif item.itemid == 7499 and item.actionid == 3343 then
				if hp > 25 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 34)
						doSendAnimatedText(playerpos, "Buh...", 129)
						doCreatureAddHealth(cid,-40) 
						doSetItemActionId(item.uid, 3344)
						doSetItemSpecialDescription(item.uid, "This cigarette is in 3/10 burned.")
						return TRUE
				else
						doPlayerSendCancel(cid, "You are too weak for this!")
				end
		elseif item.itemid == 7499 and item.actionid == 3344 then
				if hp > 30 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 34)
						doSendAnimatedText(playerpos, "Buh...", 129)
						doCreatureAddHealth(cid,-45) 
						doSetItemActionId(item.uid, 3345)
						doSetItemSpecialDescription(item.uid, "This cigarette is in 4/10 burned.")
						return TRUE
				else
						doPlayerSendCancel(cid, "You are too weak for this!")
				end
		elseif item.itemid == 7499 and item.actionid == 3345 then
				if hp > 35 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 34)
						doSendAnimatedText(playerpos, "Buh...", 129)
						doCreatureAddHealth(cid,-50) 
						doSetItemActionId(item.uid, 3346)
						doSetItemSpecialDescription(item.uid, "This cigarette is in 5/10 burned.")
						return TRUE
				else
						doPlayerSendCancel(cid, "You are too weak for this!")
				end
		elseif item.itemid == 7499 and item.actionid == 3346 then
				if hp > 50 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 34)
						doSendAnimatedText(playerpos, "Ahh...", 129)
						doCreatureAddHealth(cid,-75) 
						doSetItemActionId(item.uid, 3347)
						doSetItemSpecialDescription(item.uid, "This cigarette is in 6/10 burned.")
						return TRUE
				else
						doPlayerSendCancel(cid, "You are too weak for this!")
				end
		elseif item.itemid == 7499 and item.actionid == 3347 then
				if hp > 45 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 34)
						doSendAnimatedText(playerpos, "Ah...", 100)
						doCreatureAddHealth(cid,-65) 
						doSetItemActionId(item.uid, 3348)
						doSetItemSpecialDescription(item.uid, "This cigarette is in 7/10 burned.")
						return TRUE
				else
						doPlayerSendCancel(cid, "You are too weak for this!")
				end
		elseif item.itemid == 7499 and item.actionid == 3348 then
				if hp > 40 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 34)
						doSendAnimatedText(playerpos, "Uh...", 129)
						doCreatureAddHealth(cid,-65) 
						doSetItemActionId(item.uid, 3349)
						doSetItemSpecialDescription(item.uid, "This cigarette is in 8/10 burned.")
						return TRUE
				else
						doPlayerSendCancel(cid, "You are too weak for this!")
				end
		elseif item.itemid == 7499 and item.actionid == 3349 then
				if hp > 30 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 34)
						doSendAnimatedText(playerpos, "Urght.", 129)
						doCreatureAddHealth(cid,-65) 
						doSetItemActionId(item.uid, 3350)
						doSetItemSpecialDescription(item.uid, "This cigarette is in 9/10 burned.")
						return TRUE
				else
						doPlayerSendCancel(cid, "You are too weak for this!")
				end
		elseif item.itemid == 7499 and item.actionid == 3350 then
				if hp > 30 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 34)
						doSendAnimatedText(playerpos, "Urght!", 129)
						doCreatureAddHealth(cid,-65) 
						doSetItemActionId(item.uid, 3351)
						doSetItemSpecialDescription(item.uid, "This cigarette is burned.")
						return TRUE
				else
						doPlayerSendCancel(cid, "You are too weak for this!")
				end		
		elseif item.itemid == 7499 and item.actionid == 3351 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 2)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You can't smoke burned cigarette!")				
		elseif item.itemid == 7499 then
				if hp > 15 then
						doSendMagicEffect(frompos, 2)
						doSendMagicEffect(playerpos, 34)
						doSendAnimatedText(playerpos, "Buh...", 129)
						doCreatureAddHealth(cid,-25) 
						doSetItemActionId(item.uid, 3342)
						doSetItemSpecialDescription(item.uid, "This cigarette is in 1/10 burned.")
						return TRUE
				else
						doPlayerSendCancel(cid, "You are too weak for this!")
				end						
        end
return TRUE
end

Open actions.xml and add:
Code:
<action itemid="7499" script="cigarette.lua"/>

In items.xml search for:
Code:
<item id="7499" article="a" name="cigarette">
	<attribute key="weight" value="200" />
</item>
and change to:
Code:
<item id="7499" article="a" name="cigarette">
	<attribute key="description" value="This cigarette is new."/>
	<attribute key="weight" value="200"/>
</item>

That's it. On TFS 0.3.5 working correctly.
 
This script doesnt work "cigar.lua:6: 'then' expected near '20' (tfs 0.3.6) but man, it is nice work, im sure this can be fixed.
 
sth like this:
Code:
-- Script made by GOD Kermer
-- Xevo OTS - http://xevo.no-ip.org
-- E-Mail - [email protected]
function onUse(cid, item, frompos, item2, topos)
local playerpos = getPlayerPosition(cid)
local hp = getCreatureHealth(cid)
local config={
		[3342] = {txt="Buh...", state=2, remove_hp=-30, min_hp=20},
		[3343] = {txt="Buh...", state=3, remove_hp=-40, min_hp=25},
		[3344] = {txt="Buh...", state=4, remove_hp=-45, min_hp=30},
		[3345] = {txt="Buh...", state=5, remove_hp=-50, min_hp=35},
		[3346] = {txt="Ahh...", state=6, remove_hp=-75, min_hp=50},
		[3347] = {txt="Ah...", state=7, remove_hp=-65, min_hp=45},
		[3348] = {txt="Uh...", state=8, remove_hp=-65, min_hp=40},
		[3349] = {txt="Urght...", state=9, remove_hp=-65, min_hp=30},
		[3350] = {txt="Urght!", state=10, remove_hp=-45, min_hp=30},
		[3350] = {txt="You can't smoke burned cigarette!", state=0}


		}

	if ((isInArray(config,item.actionid)) or item.actionid == nil) then
		if (hp > (config[item.actionid].min_hp or 15) then
			if(config[item.actionid].state) then
				doSetItemSpecialDescription(item.uid, (config[item.actionid].state<10) and "This cigarette is in "..config[item.actionid].state.."/10 burned." or "This cigarette is burned.")
			else
				doSendMagicEffect(frompos, 2)
				doSendMagicEffect(playerpos, 2)
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, config[item.actionid].txt)		
				return true
			end
			doSendMagicEffect(frompos, 2)
			doSendMagicEffect(playerpos, 34)
			doSendAnimatedText(getPlayerPosition(cid),config[item.actionid].txt or "Buh..." , 129)
			doCreatureAddHealth(cid, config[item.actionid].remove_hp or -25)
			doSetItemActionId(item.uid, (item.actionid) and item.actionid+1 or 3342)
			end
		else
			doPlayerSendCancel(cid, "You are too weak for this!")
		end
	end
	return true
end

There are errors for sure, cuz i wrote this in notepad. but it should looks like it. Feel free to fix it and relase.
 
Code:
-- Script made by GOD Kermer
-- Xevo OTS - http://xevo.no-ip.org
-- E-Mail - [email protected]
local config = {
	[0]    = {txt="Buh...", state=1, remove_hp=-25, min_hp=15},
	[3342] = {txt="Buh...", state=2, remove_hp=-30, min_hp=20},
	[3343] = {txt="Buh...", state=3, remove_hp=-40, min_hp=25},
	[3344] = {txt="Buh...", state=4, remove_hp=-45, min_hp=30},
	[3345] = {txt="Buh...", state=5, remove_hp=-50, min_hp=35},
	[3346] = {txt="Ahh...", state=6, remove_hp=-75, min_hp=50},
	[3347] = {txt="Ah...", state=7, remove_hp=-65, min_hp=45},
	[3348] = {txt="Uh...", state=8, remove_hp=-65, min_hp=40},
	[3349] = {txt="Urght...", state=9, remove_hp=-65, min_hp=30},
	[3350] = {txt="Urght!", state=10, remove_hp=-45, min_hp=30},
	[3351] = {txt="You can't smoke burned cigarette!"}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local i = config[item.actionid]
	if i.min_hp then
		if getCreatureHealth(cid) > i.min_hp then
			doItemSetAtttribute(item.uid, "description", "This cigarette is " .. (i.state < 10 and i.state .. "/10 " or "") .. "burned.")
			doSendMagicEffect(fromPosition, CONST_ME_POFF)
			doSendMagicEffect(getThingPos(cid), CONST_ME_GROUNDSHAKER)
			doSendAnimatedText(getThingPos(cid), i.txt, 129)
			doCreatureAddHealth(cid, i.remove_hp)
			doItemSetAttribute(item.uid, "aid", math.max(3342, item.actionid + 1))
		else
			doPlayerSendCancel(cid, "You are too weak for this!")
		end
	else
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, i.txt)
	end
	return true
end
 
Last edited:
@Up
Sexy thang.

<The script> :wub:
 
Bad smokers. No point to get virtual fag in game ^^. The best way to smoke will be go outside. But yes, awesome script, I will use it on my test server by the way :)
 
when i use this in 0.3.6 nothing happens :S
im using
-- Script made by GOD Kermer
-- Xevo OTS - http://xevo.no-ip.org
-- E-Mail - [email protected]
local config = {
[0] = {txt="Buh...", state=1, remove_hp=-25, min_hp=15},
[3342] = {txt="Buh...", state=2, remove_hp=-30, min_hp=20},
[3343] = {txt="Buh...", state=3, remove_hp=-40, min_hp=25},
[3344] = {txt="Buh...", state=4, remove_hp=-45, min_hp=30},
[3345] = {txt="Buh...", state=5, remove_hp=-50, min_hp=35},
[3346] = {txt="Ahh...", state=6, remove_hp=-75, min_hp=50},
[3347] = {txt="Ah...", state=7, remove_hp=-65, min_hp=45},
[3348] = {txt="Uh...", state=8, remove_hp=-65, min_hp=40},
[3349] = {txt="Urght...", state=9, remove_hp=-65, min_hp=30},
[3350] = {txt="Urght!", state=10, remove_hp=-45, min_hp=30},
[3351] = {txt="You can't smoke burned cigarette!"}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local i = config[item.actionid]
if i.min_hp then
if getCreatureHealth(cid) > i.min_hp then
doItemSetAtttribute(item.uid, "description", "This cigarette is " .. (i.state < 10 and i.state .. "/10 " or "") .. "burned.")
doSendMagicEffect(fromPosition, CONST_ME_POFF)
doSendMagicEffect(getThingPos(cid), CONST_ME_GROUNDSHAKER)
doSendAnimatedText(getThingPos(cid), i.txt, 129)
doCreatureAddHealth(cid, i.remove_hp)
doItemSetAttribute(item.uid, "aid", math.max(3342, item.actionid + 1))
else
doPlayerSendCancel(cid, "You are too weak for this!")
end
else
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doSendMagicEffect(fromPosition, CONST_ME_POFF)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, i.txt)
end
return true
end
 
Back
Top