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

[0.3.4] [Action]Simple script with coffin and item

Dymczas

New Member
Joined
Mar 8, 2009
Messages
105
Reaction score
0
Hello all ! I need this script for TFS 0.3.4 :
1. The player clicks on the coffin with uid 10000.
2. If player has the item 'xx' in backpack, he gets item 'yy' and item 'xx' is removed.
3. Player can't do the second time this quest.

Thanks ^^
Rep ++
 
Last edited:
Updated. Only 10th revision. tell me if it works.

I think this is what you are looking for, Please Rep+ me if this helps cause I wrote this script just for you. And I made it easy to edit/config for the most part.

Add to action.xml
PHP:
<action actionid="10000" event="script" script="custom/coffin.lua"/>
/custom/coffin.lua
PHP:
-- Made by Delconis from Eclipseonline.servegame.com

function onUse(cid, item, frompos, item2, topos)
	local _UID = 5000
	local _removeditem = 1500
	local _additem = 2000
	local _storage = 30045
	local _removeamount = 1
	local _addamount = 1
	local _queststatus = getPlayerStorageValue(cid,_storage)
	
	-- MSG  Config -----------------------------------------------------------------------------------------------------------------
	msgDone = "You have allready done this."
	msgGetItem = "You have found gotten "..getItemArticleById(_additem).." "..getItemNameById(_additem).."."
	msgNoCap = "You have found a "..getItemNameById(newItem).." weighing "..getItemWeightById(newItem,count).." oz it is too heavy."
	msgNoRegent = "You do not have "..getItemArticleById(_removeditem).." "..getItemNameById(_removeditem).."."
	--------------------------------------------------------------------------------------------------------------------------------

	
	if item.uid == 5000 then
		if _queststatus < 1 then
			if getPlayerItemCount(cid,_removeditem) >= _removeamount then
				if getPlayerFreeCap(cid) >= getItemWeightById(_additem,1) then
					doPlayerRemoveItem(cid, _removeditem, 1)
					doPlayerAddItem(cid,_additem,_addamount)
					setPlayerStorageValue(uid, _storage, 1)
					doPlayerSendTextMessage(cid,21,msgGetItem)
				else
					doPlayerSendTextMessage(cid,21,msgNoCap)
				end
			else
				doPlayerSendTextMessage(cid,21,msgNoRegent)
			end
		else
			doPlayerSendTextMessage(cid,21,msgDone)
		end
	return true
	end
 
Last edited:
[17/02/2010 10:23:29] Lua Script Error: [Action Interface]
[17/02/2010 10:23:29] data/actions/scripts/HOTA/coffin.lua:eek:nUse

[17/02/2010 10:23:29] data/actions/scripts/HOTA/coffin.lua:15: attempt to call global 'getItemArticaleById' (a nil value)
[17/02/2010 10:23:29] stack traceback:
[17/02/2010 10:23:29] data/actions/scripts/HOTA/coffin.lua:15: in function <data/actions/scripts/HOTA/coffin.lua:3>

Got this error ; x
 
Try this:
Lua:
local StorageValue  = 30045
function onUse(cid, item, frompos, item2, topos)
    local UniqueID = 10000
    local item = 1500
    local item2 = 2000

    if item.uid == UniqueID and getPlayerStorageValue(cid, storage) == -1 and getPlayerItemCount(cid,item1,1) then
                    doPlayerRemoveItem(cid,item,1)
                    doPlayerAddItem(cid,item2,1)
                    setPlayerStorageValue(cid,StorageValue, 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You\'ve received [item name]")
   else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You\'ve already done this before")
   end
   return true
end
 
Improvement on SexyDevil's code. Hate to not have your players have cap for new item

PHP:
  local StorageValue  = 30045
function onUse(cid, item, frompos, item2, topos)
    local UniqueID = 10000
    local item = 1500
    local item2 = 2000

    if item.uid == UniqueID and getPlayerStorageValue(cid, storage) == -1 and getPlayerItemCount(cid,item1,1) then
		if getPlayerFreeCap(cid) >= getItemWeightById(item,1) then
			doPlayerRemoveItem(cid,item,1)
			doPlayerAddItem(cid,item2,1)
			setPlayerStorageValue(cid,StorageValue, 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You\'ve received [item name]")
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don't have enough cap.")
		end
   else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You\'ve already done this before")
   end
   return true
end
 
Lua:
function onUse(cid, item, frompos, item2, topos)
    local StorageValue  = 30045
    local item = 1500
    local item2 = 2000

    if getPlayerStorageValue(cid, StorageValue) == -1 and getPlayerItemCount(cid,item1) >= 1 then
        if getPlayerFreeCap(cid) >= getItemWeightById(item,1) then
            doPlayerRemoveItem(cid,item,1)
            doPlayerAddItem(cid,item2,1)
            setPlayerStorageValue(cid,StorageValue, 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You've received a " .. getItemNameById(item2) ..".")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don't have enough cap.")
        end
   else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You've already done this before")
   end
   return true
end
 
Last edited:
Aint this
Lua:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don't have enough cap.")
Suposed to be this:
Lua:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don\'t have enough cap.")

Sorry but small things sometimes destroy all the script
 
Aint this
Lua:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don't have enough cap.")
Suposed to be this:
Lua:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don\'t have enough cap.")

Sorry but small things sometimes destroy all the script

That isn't needed in this case.
'Now it\'s needed'
"Now it's not needed"
 
Lua:
function onUse(cid, item, frompos, item2, topos)
    local StorageValue  = 30045
    local item = 1500
    local item2 = 2000

    if getPlayerStorageValue(cid, StorageValue) == -1 and getPlayerItemCount(cid,item1) >= 1 then
        if getPlayerFreeCap(cid) >= getItemWeightById(item,1) then
            doPlayerRemoveItem(cid,item,1)
            doPlayerAddItem(cid,item2,1)
            setPlayerStorageValue(cid,StorageValue, 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You\'ve received a " .. getItemNameById(item2) ..".")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don\'t have enough cap.")
        end
   else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You\'ve already done this before")
   end
   return true
end
 
What did you even do to the script added the storage under the function doesn\'t matter ;)

I changed this...
local StorageValue = 30045
function onUse(cid, item, frompos, item2, topos)
local UniqueID = 10000
local item = 1500
local item2 = 2000

if item.uid == UniqueID <-- Not needed and getPlayerStorageValue(cid, storage <-- StorageValue*) == -1 and getPlayerItemCount(cid,item1,1 <-- == 1*) then
doPlayerRemoveItem(cid,item,1)
doPlayerAddItem(cid,item2,1)
setPlayerStorageValue(cid,StorageValue, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You\'ve received [item name] <-- getItemNameById*")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You\'ve already done this before")
end
return true
end

^^
 
Code:
local t = {
	remove = {2499, 1},
	add = {2500, 1},
	storage = 30045
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, t.storage) < 1 then
		local v = (t.add[2] > 1 and t.add[2] or getItemInfo(t.add[1]).article) .. " " .. (t.add[2] > 1 and getItemInfo(t.add[1]).plural or getItemInfo(t.add[1]).name)
		if getPlayerItemCount(cid, t.remove[1]) >= t.remove[2] then
			if getPlayerFreeCap(cid) >= getItemWeightById(t.add[1], t.add[2]) then
				doPlayerRemoveItem(cid, t.remove[1], t.remove[2])
				doPlayerAddItem(cid, t.add[1], t.add[2])
				setPlayerStorageValue(cid, t.storage, 1)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " .. v .. ".")
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " .. v .. ". Weighing " .. getItemWeightById(t.add[1], t.add[2]) .. " oz it is too heavy.")
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You do not have " .. (t.remove[2] > 1 and t.remove[2] or getItemInfo(t.remove[1]).article) .. " " .. (t.remove[2] > 1 and getItemInfo(t.remove[1]).plural or getItemInfo(t.remove[1]).name) .. ".")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have already done this.")
	end
	return true
end
 
Last edited:
Code:
local t = {
	remove = {2499, 1},
	add = {2500, 1},
	storage = 30045
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, t.storage) < 1 then
		local v = (t.add[2] > 1 and t.add[2] or getItemInfo(t.add[2]).article) .. " " .. t.add[2] and getItemInfo(t.add[1]).plural or getItemInfo(t.add[1]).name
		if getPlayerItemCount(cid, t.remove[1]) >= t.remove[2] then
			if getPlayerFreeCap(cid) >= getItemWeightById(t.add[1], t.add[2]) then
				doPlayerRemoveItem(cid, t.remove[1], t.remove[2])
				doPlayerAddItem(cid, t.add[1], t.add[2])
				setPlayerStorageValue(cid, t.storage, 1)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " .. v .. ".")
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You do not have " .. (t.remove[2] > 1 and t.remove[2] or getItemInfo(t.remove[2]).article) .. " " .. t.remove[2] and getItemInfo(t.remove[1]).plural or getItemInfo(t.remove[1]).name .. ".")
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " .. v .. ". Weighing " .. getItemWeightById(t.add[1], t.add[2]) .. " oz it is too heavy.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have already done this.")
	end
	return true
end
Works great, but there is one bug. When I haven't item appears '16:58 You have found left horns. Weighing 1.3999999761581 oz it is too heavy.' instead 'You dont have that item'.
Anyway Repp+ ^^
 
Only one bug. When i haven't item in bp, it doesn't show 'You dont have item', it shows 'item name'.
EDIT. Could you remake it, when i have 2 items and click, it removes 2 items and add 2 another items ?
 
Last edited:
Back
Top