• 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 New Function Need Scripers!

Knight God

Member
Joined
Oct 19, 2008
Messages
1,180
Reaction score
21
Good night, well I wonder if there could be a script to do that using marijuana,
this protect you from all the physicality and magical damage by 39%
for 15 minutes and at the end of the effect this will damage per turn
in hits of -10 hp and -10 mana for 6 minutes
.
but if you do not have mana, the damage increases hits to -20 hp per turn.
that's it, thanks in advance and hope to have luck with this script.
 
creaturescripts:
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	local storage = 2500
	local pct = 39

	if type == 1 and combat ~= COMBAT_PHYSICALDAMAGE then
		if isPlayer(cid) and getCreatureStorage(cid, storage) == 1 then
			doTargetCombatHealth(target, cid, combat, -value * pct / 100, -value * pct / 100, 0)
			return false
		end
	end
	return true
end

action:
Lua:
function eraseStorage(cid, storage, guid)
	if isPlayer(cid) then
		doCreatureSetStorage(cid, storage, -1)
	else
		db.executeQuery("UPDATE `player_storage` SET `value` = -1 WHERE `player_id` = " .. guid .. " AND `key` = " .. storage .. " LIMIT 1")
	end
end

function removeHealthAndMana(cid, i)
	if isPlayer(cid) and i > 0 then
		local mana, health = getCreatureMana(cid), getCreatureHealth(cid)
		local removeMana, removeHealth = 0, 0
		
		if mana >= 10 then			
			removeMana = 10
		elseif mana < 10 and mana ~= 0 then
			removeMana = mana
			removeHealth = removeHealth + 10 - mana
		elseif mana == 0 then
			removeHealth = removeHealth + 10
		end
		
		if removeMana > 0 then
			doCreatureAddMana(cid, - removeMana)
		end
		
		doCreatureAddHealth(cid, - removeHealth - 10)
		addEvent(removeHealthAndMana, 1000, cid, i - 1)
	end
end

local storage = 2500 -- same as in statsChange
local protectTime = 15 -- mins
local removeHpManaTime = 6 -- mins
local secondStorage = 2501

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getCreatureStorage(cid, secondStorage) <= os.time() then
		doCreatureSay(cid, "Ahhhh..", TALKTYPE_MONSTER_YELL)
		doCreatureSetStorage(cid, storage, 1)
		addEvent(eraseStorage, protectTime * 60 * 1000, cid, storage, getPlayerGUID(cid))
		addEvent(removeHealthAndMana, protectTime * 60 * 1000 + 1000, cid, removeHpManaTime * 60)
		
		doCreatureSetStorage(cid, secondStorage, os.time() + 30 * 60)
	else
		doPlayerSendCancel(cid, 'You can\'t use it right now.')
	end
	return true
end

Didn't test everything so perhaps there are bugs.
 
Last edited:
I did a test, and the script does not send errors to the console, I think it's working but I can see the wear it again and use me like that when you use it you can not use it again after 30 minutes.
thanks for script i rep+++ to you.
 
sorry double post... marijuana sending error.

PHP:
[16/08/2011 15:22:47] [Error - Action Interface] 
[16/08/2011 15:22:47] In a timer event called from: 
[16/08/2011 15:22:47] data/actions/scripts/marihuana.lua:onUse
[16/08/2011 15:22:47] Description: 
[16/08/2011 15:22:47] data/actions/scripts/marihuana.lua:5: attempt to call field 'query' (a nil value)
[16/08/2011 15:22:47] stack traceback:
[16/08/2011 15:22:47] 	data/actions/scripts/marihuana.lua:5: in function <data/actions/scripts/marihuana.lua:1>
 
Is it working now or not?



I think that someone who have no donator shouldn't get help if have bugs with TFS and need help or need any TFS configuration but not if need script

But having 0.4 with no donator is illegal and it's dissrespect to the tfs' staff work.
 
Back
Top