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

Lua chest problem

Ezeq

New Member
Joined
Nov 23, 2010
Messages
45
Reaction score
1
I've created simple script, but it doesnt work and console doesnt return any errors. I am using Mystic Spirit 0.2.9
Lua:
-- [chest.uid] = [item_id, item_id_count, player_storage_value_id]
local chest = { 
[2000] = {2475, 1, 2000},
[2001] = {2475, 2, 2000} 
}

function onUse(cid, item)
local i = chest[item.uid]
local freecap = getPlayerFreeCap(cid)
local cap = getItemWeight(i[1],i[2]) - freecap
	if item.uid == i then
		if getPlayerStorageValue(cid,i[3]) == -1 then			
			if freecap >= (getItemWeight(i[1],i[2])) then
				doPlayerAddItem(cid,i[1],i[2])					
					if i[2] > 1 then
					doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " ..i[2].. " " .. getItemName(i[1]) .. ".")
					else
					doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " .. getItemName(i[1]) .. ".")
					end
				setPlayerStorageValue(cid,i[3],1)						
			else
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need " .. cap .. " more cap to get this item.")
			end				
		else
		doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "This chest is empty.")
		end
	end			
end
I'll rep++ for help.
 
ee
Lua:
function onUse(cid, item, frompos, item2, topos)


if item.uid == xxxxx then           -----------uniqueID = pick it. any number from 1-99999 (any that arent taken)
if getPlayerStorageValue(cid,xxxxx) == -1 then --------same as above ^
doPlayerSendTextMessage(cid,25,"You have found a massive dildo")  ------whatever item you decide to put in the chest
doPlayerAddItem(cid,xxxx,x) -------------- item ID, and amount
setPlayerStorageValue(cid,xxxxx,x) ------------ same as above
else
doPlayerSendTextMessage(cid,25,"The chest is empty.")
end

end
return TRUE
end
 
Lua:
-- [chest.uid] = {item_id[, item_id_count [, player_storage_value_id]]}
local chest = { 
	[2000] = {2475, 1},
	[2001] = {2475, 2} 
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local i = chest[item.uid]
	if i then
		if getPlayerStorageValue(cid, i[3] or item.uid) == -1 then	
			local cap = getPlayerFreeCap(cid)	
			if cap >= getItemWeight(i[1], i[2] or 1) then
				doPlayerAddItem(cid, i[1], i[2] or 1)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " ..(tonumber(i[2]) and i[2] > 1 and i[2] .. " " or "") .. " " .. getItemName(i[1]) .. ".")
				setPlayerStorageValue(cid, i[3] or item.uid, 1)						
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need " .. getItemWeight(i[1], i[2] or 1) - cap .. " more cap to get this item.")
			end				
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The chest is empty.")
		end
		return TRUE
	end
end
 
Lua:
-- [chest.uid] = {item_id[, item_id_count [, player_storage_value_id]]}
local chest = { 
	[2000] = {2475, 1},
	[2001] = {2475, 2} 
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local i = chest[item.uid]
	if i then
		if getPlayerStorageValue(cid, i[3] or item.uid) == -1 then	
			local cap = getPlayerFreeCap(cid)	
			if cap >= getItemWeight(i[1], i[2] or 1) then
				doPlayerAddItem(cid, i[1], i[2] or 1)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " ..(tonumber(i[2]) and i[2] > 1 and i[2] .. " " or "") .. " " .. getItemName(i[1]) .. ".")
				setPlayerStorageValue(cid, i[3] or item.uid, 1)						
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need " .. getItemWeight(i[1], i[2] or 1) - cap .. " more cap to get this item.")
			end				
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The chest is empty.")
		end
		return TRUE
	end
end

weakest c,c
 
Back
Top