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

Action Marihuana Scirpt + The sprite

Reaper7

dunno wat 2 rite here
Joined
Feb 18, 2011
Messages
133
Reaction score
1
Hiho!
today I want to show you my new script, which is quite cool, at least for me ; d

firstly you need to add this sprite to your tfs:
i3rvw1.png

im not the author of this sprite!


script:
PHP:
--[[
Script by Elff/Reaper7
-]]
function onUse(cid, item, fromPosition, itemEx, toPosition)
local condition = createConditionObject(CONDITION_PARALYZE) 
local number = math.random(1,2)
if number==1 then
   if item.itemid == 6666 and  getPlayerLevel(cid) >= 100 then
--[[
note: id of the item must be changed!
]]
        doPlayerSendTextMessage(cid,21,"Just chill out man!")
        doCreatureAddHealth(cid,150)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
        doRemoveItem(item.uid, 1)
        return 1
      else
        doPlayerSendCancel(cid,"<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid,-150)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
        doRemoveItem(item.uid, 1)
        setConditionParam(condition, CONDITION_PARAM_TICKS, 20000) 
        setConditionFormula(condition, -1, 40, -1, 40) 
        setCombatCondition(combat, condition) 
 
 
	  end
	  return 1
end

and then we need to add this to the action.lua:
Code:
<action actionid="2142" event="script" value="marihuana.lua"/>


basically what the script does is when you click on the marihuana it makes player send a text message "Just chill out man!" and it adds 150 hp. Warning! if the player isn't at least level 100 then he will lose 150 hp!


Regards :)
 
Last edited:
Small fix (no action id required):
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (getPlayerLevel(cid) >= 100) then
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid, -(math.random(0.6, 5.0) * getPlayerLevel()))
    elseif
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Just chill out man!")
        doCreatureAddHealth(cid, math.random(150, 500) + getPlayerLevel() * 2.5)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    end
    return true
end
/data/actions/actions.xml
PHP:
<action itemid="2142" event="script" value="scriptname.lua"/>
 
doSendMagicEffect(pos, type[, player])
you must change this
ohh, my fault, i was doing 2 scripts in one go, so i probably accidently put a function to a wrong piece of a document ^^

alehopper, thanks im new at lua : )
 
or this ;p
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if (getPlayerLevel(cid) >= 100 and item.actionid <= 0 and item.itemid == 2142) then
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid, -(math.random(0.6, 5.0) * getPlayerLevel()))
		doItemSetAttribute(item.uid, "aid",item.actionid+math.random(5, 20))
    elseif (getPlayerLevel(cid) <= 101 and item.actionid <= 0 and item.itemid == 2142)
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Just chill out man!")
        doCreatureAddHealth(cid, math.random(150, 500) + getPlayerLevel() * 2.5)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
		doItemSetAttribute(item.uid, "aid",item.actionid+math.random(5, 20))
	elseif (getPlayerLevel(cid) >= 100 and item.actionid <= 2 and item.itemid == 2142) then
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid, -(math.random(0.6, 5.0) * getPlayerLevel()))
		doItemSetAttribute(item.uid, "aid",item.actionid-1)
    elseif (getPlayerLevel(cid) <= 101 and item.actionid <= 2 and item.itemid == 2142)
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Just chill out man!")
        doCreatureAddHealth(cid, math.random(150, 500) + getPlayerLevel() * 2.5)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
		doItemSetAttribute(item.uid, "aid",item.actionid-1)
	elseif (getPlayerLevel(cid) >= 100 and item.actionid == 1 and item.itemid == 2142) then
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid, -(math.random(0.6, 5.0) * getPlayerLevel()))
		doItemSetAttribute(item.uid, "aid",item.actionid-1)
		doRemoveItem(item.uid,1)
    elseif (getPlayerLevel(cid) <= 101 and item.actionid == 1 and item.itemid == 2142)
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Just chill out man!")
        doCreatureAddHealth(cid, math.random(150, 500) + getPlayerLevel() * 2.5)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
		doRemoveItem(item.uid,1)
    end
    return true
end
 
Small fix (no action id required):
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (getPlayerLevel(cid) >= 100) then
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid, -(math.random(0.6, 5.0) * getPlayerLevel()))
    elseif
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Just chill out man!")
        doCreatureAddHealth(cid, math.random(150, 500) + getPlayerLevel() * 2.5)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    end
    return true
end
/data/actions/actions.xml
PHP:
<action itemid="2142" event="script" value="scriptname.lua"/>

You should change getPlayerLevel() to getPlayerLevel(cid).
 
or this ;p
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if (getPlayerLevel(cid) >= 100 and item.actionid <= 0 and item.itemid == 2142) then
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid, -(math.random(0.6, 5.0) * getPlayerLevel()))
		doItemSetAttribute(item.uid, "aid",item.actionid+math.random(5, 20))
    elseif (getPlayerLevel(cid) <= 101 and item.actionid <= 0 and item.itemid == 2142)
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Just chill out man!")
        doCreatureAddHealth(cid, math.random(150, 500) + getPlayerLevel() * 2.5)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
		doItemSetAttribute(item.uid, "aid",item.actionid+math.random(5, 20))
	elseif (getPlayerLevel(cid) >= 100 and item.actionid <= 2 and item.itemid == 2142) then
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid, -(math.random(0.6, 5.0) * getPlayerLevel()))
		doItemSetAttribute(item.uid, "aid",item.actionid-1)
    elseif (getPlayerLevel(cid) <= 101 and item.actionid <= 2 and item.itemid == 2142)
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Just chill out man!")
        doCreatureAddHealth(cid, math.random(150, 500) + getPlayerLevel() * 2.5)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
		doItemSetAttribute(item.uid, "aid",item.actionid-1)
	elseif (getPlayerLevel(cid) >= 100 and item.actionid == 1 and item.itemid == 2142) then
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid, -(math.random(0.6, 5.0) * getPlayerLevel()))
		doItemSetAttribute(item.uid, "aid",item.actionid-1)
		doRemoveItem(item.uid,1)
    elseif (getPlayerLevel(cid) <= 101 and item.actionid == 1 and item.itemid == 2142)
        doPlayerSendTextMessage(cid, MESSAGE_FIRST, "Just chill out man!")
        doCreatureAddHealth(cid, math.random(150, 500) + getPlayerLevel() * 2.5)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
		doRemoveItem(item.uid,1)
    end
    return true
end
God, mate what have you done? xdd it was simple enough =d

I think that if you add paralyze it would be cool as well.
no problem, later i will add it;d
 
hi there!
i've made a small change to the script, now it chooses randomly, what it should do and the item removes from your bag, after you use it.
there it is:
Code:
--[[
Script by Elff/Reaper7
-]]
function onUse(cid, item, fromPosition, itemEx, toPosition)
local number = math.random(1,2)
if number==1 then
   if item.itemid == 6666 and  getPlayerLevel(cid) >= 100 then
--[[
note: id of the item must be changed!
]]
        doPlayerSendTextMessage(cid,21,"Just chill out man!")
        doCreatureAddHealth(cid,150)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
        doRemoveItem(item.uid, 1)
        return 1
      else
        doPlayerSendCancel(cid,"<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid,-150)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
        doRemoveItem(item.uid, 1)
 
 
	  end
	  return 1
end

hopefully, you'll like it =d

Regards!


@edit
Oh, i forgot about the paralize thing! sorry, my fault =d i'll add it tomoz cuz today i dont really have time. ; d
 
Paralize added:
PHP:
--[[
Script by Elff/Reaper7
-]]
function onUse(cid, item, fromPosition, itemEx, toPosition)
local condition = createConditionObject(CONDITION_PARALYZE) 
local number = math.random(1,2)
if number==1 then
   if item.itemid == 6666 and  getPlayerLevel(cid) >= 100 then
--[[
note: id of the item must be changed!
]]
        doPlayerSendTextMessage(cid,21,"Just chill out man!")
        doCreatureAddHealth(cid,150)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
        doRemoveItem(item.uid, 1)
        return 1
      else
        doPlayerSendCancel(cid,"<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid,-150)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
        doRemoveItem(item.uid, 1)
        setConditionParam(condition, CONDITION_PARAM_TICKS, 20000) 
        setConditionFormula(condition, -1, 40, -1, 40) 
        setCombatCondition(combat, condition) 
 
 
	  end
	  return 1
end

It should work =d.

Note: First post changed.
 
Last edited:
Hi!
if you've got any ideas to optymalize my script, please tell me... i run out of them ; p
 
Hiho!
today I want to show you my new script, which is quite cool, at least for me ; d

firstly you need to add this sprite to your tfs:
i3rvw1.png

im not the author of this sprite!


script:
PHP:
--[[
Script by Elff/Reaper7
-]]
function onUse(cid, item, fromPosition, itemEx, toPosition)
local condition = createConditionObject(CONDITION_PARALYZE) 
local number = math.random(1,2)
if number==1 then
   if item.itemid == 6666 and  getPlayerLevel(cid) >= 100 then
--[[
note: id of the item must be changed!
]]
        doPlayerSendTextMessage(cid,21,"Just chill out man!")
        doCreatureAddHealth(cid,150)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
        doRemoveItem(item.uid, 1)
        return 1
      else
        doPlayerSendCancel(cid,"<Coughs> I think that drugs, aren't good for me...")
        doCreatureAddHealth(cid,-150)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
        doRemoveItem(item.uid, 1)
        setConditionParam(condition, CONDITION_PARAM_TICKS, 20000) 
        setConditionFormula(condition, -1, 40, -1, 40) 
        setCombatCondition(combat, condition) 
 
 
	  end
	  return 1
end

and then we need to add this to the action.lua:
Code:
<action actionid="2142" event="script" value="marihuana.lua"/>


basically what the script does is when you click on the marihuana it makes player send a text message "Just chill out man!" and it adds 150 hp. Warning! if the player isn't at least level 100 then he will lose 150 hp!


Regards :)

Where i need to ad the sprite?? xd what is tfs and in what folder i add it?xd
 
you need to add this sprite to your tfs by using nox(?) editor, or something like that... surely there will be some tutorials on forum =d
 
Back
Top