• 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 Grow marijuana and smoke it

Eazy M

Developer
Joined
Oct 17, 2010
Messages
911
Reaction score
61
Location
.
This script was made by me.

Use water (id 7494) on id 7673 and it will grow.
After 20 seconds it will add 5 marijuana.

Use the cigarette (id 7499) to smoke it.

The cigarette script was made by ruggedmage:
http://otland.net/f81/marijuana-script-152194/


[video=youtube;cuX9MgF16HE]http://www.youtube.com/watch?v=cuX9MgF16HE&[/video]


actions/scripts/smoke/water.lua:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Rasmus75
	if isInArray(7673, itemEx.itemid) then
			doPlayerRemoveItem(cid, 7673, 1)
			doPlayerAddItem(cid, 7678, 1)
			
			addEvent(doPlayerRemoveItem, 5000, cid, 7678, 1) --5000 ms = 5 seconds
			addEvent(doPlayerAddItem, 5000, cid, 7680, 1)
			
			addEvent(doPlayerRemoveItem, 15000, cid, 7680, 1) --15000 ms = 15 seconds
			addEvent(doPlayerAddItem, 15000, cid, 5953, 5)
			return true
	end
return true
end

actions/scripts/smoke/smoke.lua:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerItemCount(cid, 5953) >= 1 then
	doPlayerRemoveItem(cid, 5953, 1)
	doCreatureAddHealth(cid, -200)
	doSendMagicEffect(getPlayerPosition(cid), 31)
	doCreatureSay(cid, "-Cough-", 3)
	doPlayerSendTextMessage(cid, 22, "You have been affected from smoking marijuana!")
	doChangeSpeed(cid, -400)
else
	doPlayerSendTextMessage(cid, 22, "You have nothing to smoke.")
	end
	return true
end

actions.xml:
XML:
	<!-- Smoke -->
	<action itemid="7494" event="script" value="smoke/water.lua"/>
	<action itemid="7499" event="script" value="smoke/smoke.lua"/>


Rep++ please if you like it / using it! :)

Please, don't post your own version here. Respect!

No hatin' please ;s
I don't script much. I am most into programming.
 
Last edited:
hahah, looks really neat :p
I think I'll use it on my server xD

Red
 
DAMN!! It dont work for me... Really want it in my serv:(

Code:
[2/1/2013 23:52:41] [Error - Action Interface] 
[2/1/2013 23:52:41] data/actions/scripts/smoke/water.lua:onUse
[2/1/2013 23:52:41] Description: 
[2/1/2013 23:52:41] data/lib/050-function.lua:10: bad argument #1 to 'ipairs' (table expected, got number)
[2/1/2013 23:52:41] stack traceback:
[2/1/2013 23:52:41] 	[C]: in function 'ipairs'
[2/1/2013 23:52:41] 	data/lib/050-function.lua:10: in function 'isInArray'
[2/1/2013 23:52:41] 	data/actions/scripts/smoke/water.lua:2: in function <data/actions/scripts/smoke/water.lua:1>
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Rasmus75
	if isInArray({7673}, itemEx.itemid) then
			doPlayerRemoveItem(cid, 7673, 1)
			doPlayerAddItem(cid, 7678, 1)
 
			addEvent(doPlayerRemoveItem, 5000, cid, 7678, 1) --5000 ms = 5 seconds
			addEvent(doPlayerAddItem, 5000, cid, 7680, 1)
 
			addEvent(doPlayerRemoveItem, 15000, cid, 7680, 1) --15000 ms = 15 seconds
			addEvent(doPlayerAddItem, 15000, cid, 5953, 5)
			return true
	end
return true
end

Just a guess
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Rasmus75
	if isInArray({7673}, itemEx.itemid) then
			doPlayerRemoveItem(cid, 7673, 1)
			doPlayerAddItem(cid, 7678, 1)
 
			addEvent(doPlayerRemoveItem, 5000, cid, 7678, 1) --5000 ms = 5 seconds
			addEvent(doPlayerAddItem, 5000, cid, 7680, 1)
 
			addEvent(doPlayerRemoveItem, 15000, cid, 7680, 1) --15000 ms = 15 seconds
			addEvent(doPlayerAddItem, 15000, cid, 5953, 5)
			return true
	end
return true
end

Just a guess

Thank you, it worked! <3
 
actions/scripts/smoke/smoke.lua:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerItemCount(cid, 5953) >= 1 then
	doPlayerRemoveItem(cid, 5953, 1)
	doCreatureAddHealth(cid, -200)
	doSendMagicEffect(getPlayerPosition(cid), 31)
	doCreatureSay(cid, "-Cough-", 3)
	doPlayerSendTextMessage(cid, 22, "You have been affected from smoking marijuana!")
	doChangeSpeed(cid, -400)
else
	doPlayerSendTextMessage(cid, 22, "You have nothing to smoke.")
	end
	return true
end

Have I missed some kind of code here, how do you intend to change the movement speed to normal?
Can't find anything here which changes the movement speed to normal after some time ammount :p
You should add an addevent to change the movement speed back to normal after a certain ammount of time, that way it'll even be more realistic :)


Kind regards, Evil Hero
 
Have I missed some kind of code here, how do you intend to change the movement speed to normal?
Can't find anything here which changes the movement speed to normal after some time ammount :p
You should add an addevent to change the movement speed back to normal after a certain ammount of time, that way it'll even be more realistic :)


Kind regards, Evil Hero

Forgot to do that, lol. I am most into programming for MPGH now, feel free to fix the code. :p
 
Last edited:
Back
Top