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

Trap Script

Dyker

New Member
Joined
Sep 12, 2008
Messages
97
Reaction score
1
Hi people. I need a bomb with detonator. An item which explote when player use item X. So I need 2 actions script.

1- When you use it appears item XXX on player position.
2- When you use it item XXX explote dealing damage.
 
I done the first bit for you:
With the second bit do you want it to explode a radius or just the person using it...?

Lua:
function onUse(cid, item, frompos, item2, topos)
----------------------------------------------------------------------------
local time = {
		useCooldown = true, -- True recommended
		cooldown = 1000, -- 1000 = 1 second
		storage = 1337 -- Storage to store the cooldown
	}

local i = {
		itemID = 1337,
		CreatePos = getPlayerPosition(cid)
	}
----------------------------------------------------------------------------

if time.useCooldown == true then
	 if exhaustion.check(cid, time.storage) == false then
		doCreateItem(cid, i.itemID, i.CreatePos)
			exhaustion.set(cid, time.storage, time.cooldown)
				return doCombat(cid, combat, var)
		else
			doPlayerSendTextMessage(cid, 25, "You are currently on cooldown please wait: ".. time.cooldown .."!")
			end
		end	
	end	

if time.useCooldown == false then
	doCreateItem(cid, i.itemID, i.CreatePos)
		return doCombat(cid, combat, var)	
	end
 
Try:
Lua:
function explode(pos)
local area = {
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 3, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 0, 0}
}
area = createCombatArea(area)

for i = 1, 3 do
	addEvent(doSendAnimatedText, 1000*i, pos, "" .. (i > 2 and 3 or i < 2 and 1 or i) .. "", 180)
end
doAreaCombatHealth(0, COMBAT_FIREAREA, pos, area, -config.min, -config.max, CONST_ME_FIREAREA)
return true
end

local config = {

item = {
create = {enable = true, itemCreated = xxxx}, 
transport = false
},  -- if not enable remove then it will transport the SAME ITEM, else it will create a NEW ONE. (it will always remove the item).
storage = 5555, -- free storage
seconds = 10, -- seconds of exhaustion
min = 500, -- min dmg of bomb
max = 1000 -- max dmg of bomb
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if exhaustion.get(cid, storage) then
	return doPlayerSendCancel(cid, "You can not use this item yet.")
end
if(config.item.create.enable and config.item.transport) or (not config.item.create.enable and not config.item.transport) then
	print("Item creation and transport in config is wrong - bomb script")
	return doPlayerSendCancel(cid, "Problem! Please contact an administrator")
end
doCreateItem(config.item.create.enable and config.item.create.itemCreated or item.uid, 1, getPlayerPosition(cid))
doRemoveItem(item.uid, 1)
exhaustion.set(cid, config.storage, 1000*config.seconds)
for i = 5000, 5002 do
	setPlayerStorageValue(cid, i, getPlayerPosition(cid).i == 5000 and x or i == 5001 and y or z)
end
local pos = {x=getPlayerStorageValue(cid, 5000), y=getPlayerStorageValue(cid,5001), z=getPlayerStorageValue(cid,5002)}
explode(pos)
return true
end
 
colud you explain a little bot how does it works? xD I get lost in some parts of the script xD

Well, all you gotta touch is config, so I guess you are wondering bout:
Lua:
local config = {
 
item = {
create = {enable = true, itemCreated = xxxx}, 
transport = false
},  -- if not enable remove then it will transport the SAME ITEM, else it will create a NEW ONE. (it will always remove the item).

If create is enabled then you put the new item that want to be created, it will create a DIFFERENT ITEM, than the one you use in your current backpack/floor. If you enable transport then it will create the SAME ITEM. Always below you.
And, well that's pretty much it, report to me the errors.
 
Humm, it doesn't explote. When I use the item.id from xml, it makes the item which i put before in .lua but it doesn't exlpote.. And how can I put some item like a open trap and when someone stepout disappear the item of the floor. So it deals damage but after disappear...
 
I got this errors :

Code:
[25/09/2011 20:47:37] [Error - Action Interface] 
[25/09/2011 20:47:37] data/actions/scripts/bomb.lua:onUse
[25/09/2011 20:47:37] Description: 
[25/09/2011 20:47:37] data/actions/scripts/bomb.lua:16: attempt to index global 'config' (a nil value)
[25/09/2011 20:47:37] stack traceback:
[25/09/2011 20:47:37] 	data/actions/scripts/bomb.lua:16: in function 'explode'
[25/09/2011 20:47:37] 	data/actions/scripts/bomb.lua:47: in function <data/actions/scripts/bomb.lua:32>
 
Back
Top