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

[Request | Action Script] Item Upgrader

Logarithmic

Harvard Student
Joined
Apr 11, 2010
Messages
83
Reaction score
15
Location
São Paulo, Brazil
Hello, I'm not sure if the script organization of how I want this to work is possible. But I'm not sure, so here it goes;

I want a script, that when you put an item on an alter, & pull a lever it will 'upgrade' the item if you have the required money. But I want this action script to work for multiple items, so this is how I wanted it. Also to send a magic effect to the alter if the upgrade was a success & send "CONST_ME_MAGIC_BLUE", if you don't have the money send "CONST_ME_POFF" Something like;

Code:
local upgradeItems = {
[1] = {oldItemID, newItemID, upgradeCost},
[2] = {oldItemID, newItemID, upgradeCost}
}

Here's an illustration of how it works;

zusheq.png


Thanks for any help ^^

also, my distro is TFS0.3.6pl1
 
Last edited:
Code:
local t = {
	effectSuccess = CONST_ME_MAGIC_BLUE,
	effectFail = CONST_ME_POFF,
	pos = {x=100, y=100, z=7, stackpos=1},
	upgradeItems = {
	--[oldItemID] = {newItemID, upgradeCost}
		[xxxx] = {xxxx, xxxx},
		[xxxx] = {xxxx, xxxx}
	}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, 1945)
	end
	local get = getThingfromPos(t.pos)
	local v = t.upgradeItems[get.itemid]
	if v then
		if doPlayerRemoveMoney(cid, v[2]) then
			doTransformItem(get.uid, v[1], 1)
			doSendMagicEffect(t.pos, t.effectSuccess)
			return doTransformItem(item.uid, 1946)
		else
			doPlayerSendCancel(cid, 'You don\'t have enough money.')
		end
	else
		doPlayerSendCancel(cid, 'Item not found.')
	end
	return doSendMagicEffect(t.pos, t.effectFail)
end
 
Last edited:
Perhaps I'm doing something wrong? I edited the x,y,z & put the configured the items. All's its doing is, sending effectFail to the t.pos also, there's so errors. I'm using TFS0.3.6pl1, but I don't think that has anything to do with it.

Code:
local t = {
	effectSuccess = CONST_ME_MAGIC_BLUE,
	effectFail = CONST_ME_POFF,
	pos = {x=32346, y=32237, z=7, stackpos=1},
	upgradeItems = {
	--[oldItemID] = {newItemID, upgradeCost}
		[2184] = {2361, 10000},
		[2390] = {2404, 10000}
	}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, 1945)
	end
	local get = getThingfromPos(t.pos)
	local v = t.upgradeItems[get.itemid]
	if v then
		if doPlayerRemoveMoney(cid, v[2]) then
			doTransformItem(get.uid, v[1], 1)
			doSendMagicEffect(t.pos, t.effectSuccess)
			return doTransformItem(item.uid, 1946)
		else
			doPlayerSendCancel(cid, 'You don\'t have enough money.')
		end
		doPlayerSendCancel(cid, 'Item not found.')
	end
	return doSendMagicEffect(t.pos, t.effectFail)
end
 
ok i'll have to test it -.-
----
err, cannot reproduce the bug, altough I just edited the script because of a missing 'else'.
 
Alright well now it sends the cancel "Item not found." but, when I placed the oldItemID[2184] on the alter, pulled the lever it says "Item not found." I have the required cost, it just doesn't transform the item into the new one. And no errors either.
 
Uh, debug version - post results:
Code:
local t = {
	effectSuccess = CONST_ME_MAGIC_BLUE,
	effectFail = CONST_ME_POFF,
	pos = {x=32346, y=32237, z=7, stackpos=1},
	upgradeItems = {
	--[oldItemID] = {newItemID, upgradeCost}
		[2184] = {2361, 10000},
		[2390] = {2404, 10000}
	}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, 1945)
	end
	local get = getThingfromPos(t.pos)
	local tmp = t.pos
	tmp.stackpos = 0
	while getThingfromPos(tmp).uid > 0 do
		doPlayerSendTextMessage(cid, 25, "id: "..getThingfromPos(tmp).itemid.." stackpos: "..tmp.stackpos)
		tmp.stackpos = tmp.stackpos + 1
	end
	local v = t.upgradeItems[get.itemid]
	if v then
		if doPlayerRemoveMoney(cid, v[2]) then
			doTransformItem(get.uid, v[1], 1)
			doSendMagicEffect(t.pos, t.effectSuccess)
			return doTransformItem(item.uid, 1946)
		else
			doPlayerSendCancel(cid, 'You don\'t have enough money.')
		end
	else
		doPlayerSendCancel(cid, 'Item not found.')
	end
	return doSendMagicEffect(t.pos, t.effectFail)
end
 
Uh, ok - just as I thought (altar was taking up stackpos 1).
Code:
local t = {
	effectSuccess = CONST_ME_MAGIC_BLUE,
	effectFail = CONST_ME_POFF,
	pos = {x=32346, y=32237, z=7, stackpos=[B][COLOR="Red"]2[/COLOR][/B]},
	upgradeItems = {
	--[oldItemID] = {newItemID, upgradeCost}
		[2184] = {2361, 10000},
		[2390] = {2404, 10000}
	}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, 1945)
	end
	local get = getThingfromPos(t.pos)
	local v = t.upgradeItems[get.itemid]
	if v then
		if doPlayerRemoveMoney(cid, v[2]) then
			doTransformItem(get.uid, v[1], 1)
			doSendMagicEffect(t.pos, t.effectSuccess)
			return doTransformItem(item.uid, 1946)
		else
			doPlayerSendCancel(cid, 'You don\'t have enough money.')
		end
	else
		doPlayerSendCancel(cid, 'Item not found.')
	end
	return doSendMagicEffect(t.pos, t.effectFail)
end
 
Last edited:
rep him now? ;d

Can you solve this for me?
Cykotitan's current rep points + 0

Thanks
Well, it's almost done.. except if theirs no current item on the alter, it's not sending "Item not found" and when the player doesn't have the required money it sends "Item not found"
Code:
local t = {
	effectSuccess = CONST_ME_TELEPORT,
	effectFail = CONST_ME_POFF,
	pos = {x=32346, y=32237, z=7, stackpos=2},
	upgradeItems = {
	--[oldItemID] = {newItemID, upgradeCost}
		[2184] = {2361, 10000},
		[2390] = {2404, 10000}
	}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1946 then
		return doTransformItem(item.uid, 1945)
	end
	local get = getThingfromPos(t.pos)
	local v = t.upgradeItems[get.itemid]
	if v then
		if doPlayerRemoveMoney(cid, v[2]) then
			doTransformItem(get.uid, v[1], 1)
			doSendMagicEffect(t.pos, t.effectSuccess)
			return doTransformItem(item.uid, 1946)
		else
			doPlayerSendCancel(cid, 'You don\'t have enough money.')
		end
		doPlayerSendCancel(cid, 'Item not found.')
	end
	return doSendMagicEffect(t.pos, t.effectFail)
end
 
im not better than cykotitan, but try this ;S
Code:
local t = {
	effectSuccess = CONST_ME_TELEPORT,
	effectFail = CONST_ME_POFF,
	pos = {x=32346, y=32237, z=7, stackpos=2},
	upgradeItems = {
	--[oldItemID] = {newItemID, upgradeCost}
		[2184] = {2361, 10000},
		[2390] = {2404, 10000}
	}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 or item.itemid == 1946 then
		local get = getThingfromPos(t.pos)
		local v = t.upgradeItems[get.itemid]
		if v then
			if doPlayerRemoveMoney(cid, v[2]) then
				doTransformItem(get.uid, v[1])
				doSendMagicEffect(t.pos, t.effectSuccess)
			else
				doPlayerSendCancel(cid, "You don\'t have enough money.")
			end
		else
			doPlayerSendCancel(cid, "Item not found.")
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945) or doSendMagicEffect(t.pos, t.effectFail)
end
 
Can you solve this for me?
Cykotitan's current rep points + 0

Thanks
Well, it's almost done.. except if theirs no current item on the alter, it's not sending "Item not found" and when the player doesn't have the required money it sends "Item not found"
ok i'll have to test it -.-
----
err, cannot reproduce the bug, altough I just edited the script because of a missing 'else'.
>>791674
>>791674
>>791674

I should've edited the third post too.
 
Back
Top