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

Requesting a simple action script take a look please.

Status
Not open for further replies.

Sir Shutter

Learning LUA
Joined
Nov 17, 2008
Messages
1,437
Reaction score
10
Location
Egypt
Hi, i'm requesting a simple action script.

The script should do the following :-

It will be an item which is called a bullset upgrader.

If I use this item on any part of the set, the part I chosen will dissappear and another item will appear..

So for example, this item I right clicked it, then used it on the bull armor, then it will send text message "You have upgraded your bull armor." then the bull armor dissappears and another item appears which I already made in items.xml + also the upgrader will dissappear, so I use the upgrader on the armor, it sends the text message, the upgrader dissappear, and also the bull armor dissappear, and another armor with another ID which I called Upgraded Bull Armor, will appear instead..

Here are the ID's :-

Upgrader item id = 8306

[9927 - Bull helmet] - When upgraded will become :- 2128
[8879 - Bull armor] - When upgraded will become :- 8880
[9928 - Bull Legs] - When upgraded will become :- 9777
[7892 - Bull Boots] - When upgraded will become :- 7893
[2537 - Bull Shield] - When upgraded will become :- 6391


So remember, when the item is used on any piece of the set, the piece will dissappear, and the new item appear, plus also the upgrader will be destroyed, and the new item will be added, and the text message will be sent.

Ofcorse I'll rep++ who do it for me, I really need it badly right now, I dont got my scripters online, since im doing an update for my server, so I need this script working, I got about 2 hours, so please try to do it, thanks again!

Rep++ :thumbup:
 
Test: (Just test to see if works)
Lua:
local helmet = { old = 9927 }
local armor = { old = 8879 }
local legs = { old = 9928 }
local shield = { old = 2537 }
local boots = { old = 7892 }

local newHelmet = { new = 2128 }
local newArmor = { new = 8880 }
local newLegs = { new = 9777 }
local newShield = { new = 6391 }
local newBoots = { new = 7893 }

local upgrade = getPlayerItemCount(cid, 8306)
function onUse(cid, item, fromPos, item2, toPos)
    if upgrade.itemid == 1 and item.itemid == helmet.old then
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        doPlayerAddItem(cid, newHelmet.new, 1)
        doRemoveItem(helmet.old, 1)
        doRemoveItem(upgrade.uid, 1)
    elseif upgrade.itemid == 1 and item.itemid == armor.old then
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        doPlayerAddItem(cid, newArmor.new, 1)
        doRemoveItem(armor.old, 1)
        doRemoveItem(upgrade.uid, 1)
    elseif upgrade.itemid == 1 and item.itemid == legs.old then
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        doPlayerAddItem(cid, newLegs.new, 1)
        doRemoveItem(legs.old, 1)
        doRemoveItem(upgrade.uid, 1)
    elseif upgrade.itemid == 1 and item.itemid == shield.old then
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        doPlayerAddItem(cid, newShield.new, 1)
        doRemoveItem(shield.old, 1)
        doRemoveItem(upgrade.uid, 1)
    elseif upgrade.itemid == 1 and item.itemid == boots.old then
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        doPlayerAddItem(cid, newBoots.new, 1)
        doRemoveItem(boots.old, 1)
        doRemoveItem(upgrade.uid, 1)
    end
    return TRUE
end
 
Last edited:
Try this one.

I just changed something, forgot some "=" signs.
 
[22/08/2009 03:14:47] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Custom Vets/rich update.lua)
[22/08/2009 03:14:47] data/actions/scripts/Custom Vets/rich update.lua:2: unexpected symbol near 'local'
 
ok sec

no console errors, and dont work =/

btw im using tibia 8.42 - tfs 0.3.4 i think
 
Last edited by a moderator:
doesnt work still :/

[22/08/2009 03:25:19] Lua Script Error: [Action Interface]
[22/08/2009 03:25:19] data/actions/scripts/Custom Vets/rich update.lua:eek:nUse

[22/08/2009 03:25:19] data/actions/scripts/Custom Vets/rich update.lua:15: attempt to index upvalue 'upgrade' (a boolean value)
[22/08/2009 03:25:19] stack traceback:
[22/08/2009 03:25:19] data/actions/scripts/Custom Vets/rich update.lua:15: in function <data/actions/scripts/Custom Vets/rich update.lua:14>
 
Well, I have to leave...
Maybe someone else can help you.
(Try PM'ing Shawak)

Sorry.
 
bullupdater.lua:
Lua:
local items = {
        [9927] = 2128,
	[8879] = 8880,
	[9928] = 9777,
	[2537] = 6391,
	[7892] = 7893
} 


function onUse(cid, item, fromPos, item2, toPos)
	if item.itemid == 8306 then
		if items[itemEx.itemid] then
		doPlayerAddItem(cid, items[item.itemid], 1)
                doRemoveItem(helmet.old, 1)
                doRemoveItem(upgrade.uid, 1)
		doSendMagicEffect(toPos,14)
		doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
		return true
		else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can update only bull items.")
		doSendMagicEffect(toPos,3)
		return false
		end	
	end
return true
end

<action itemid="8306" event="script" value="bullupdater.lua"/>
post if any problems ;)
 
Test: (Just test to see if works)
Lua:
local helmet = { old = 9927 }
local armor = { old = 8879 }
local legs = { old = 9928 }
local shield = { old = 2537 }
local boots = { old = 7892 }

local newHelmet = { new = 2128 }
local newArmor = { new = 8880 }
local newLegs = { new = 9777 }
local newShield = { new = 6391 }
local newBoots = { new = 7893 }

local upgrade = getPlayerItemCount(cid, 8306)
function onUse(cid, item, fromPos, item2, toPos)
    if upgrade.itemid == 1 and item.itemid == helmet.old then
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        doPlayerAddItem(cid, newHelmet.new, 1)
        doRemoveItem(helmet.old, 1)
        doRemoveItem(upgrade.uid, 1)
    elseif upgrade.itemid == 1 and item.itemid == armor.old then
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        doPlayerAddItem(cid, newArmor.new, 1)
        doRemoveItem(armor.old, 1)
        doRemoveItem(upgrade.uid, 1)
    elseif upgrade.itemid == 1 and item.itemid == legs.old then
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        doPlayerAddItem(cid, newLegs.new, 1)
        doRemoveItem(legs.old, 1)
        doRemoveItem(upgrade.uid, 1)
    elseif upgrade.itemid == 1 and item.itemid == shield.old then
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        doPlayerAddItem(cid, newShield.new, 1)
        doRemoveItem(shield.old, 1)
        doRemoveItem(upgrade.uid, 1)
    elseif upgrade.itemid == 1 and item.itemid == boots.old then
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        doPlayerAddItem(cid, newBoots.new, 1)
        doRemoveItem(boots.old, 1)
        doRemoveItem(upgrade.uid, 1)
    end
    return TRUE
end

Stupid usage of tables ;(

Better:
Code:
local items = {
    [9927] = 2128... etc
 
@Up,
It was really early, I had to leave for a party...
I was just typing fast, and throwing stuff together.
 
bullupdater.lua:
Lua:
local items = {
        [9927] = 2128,
	[8879] = 8880,
	[9928] = 9777,
	[2537] = 6391,
	[7892] = 7893
} 


function onUse(cid, item, fromPos, item2, toPos)
	if item.itemid == 8306 then
		if items[itemEx.itemid] then
		doPlayerAddItem(cid, items[item.itemid], 1)
                doRemoveItem(helmet.old, 1)
                doRemoveItem(upgrade.uid, 1)
		doSendMagicEffect(toPos,14)
		doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
		return true
		else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can update only bull items.")
		doSendMagicEffect(toPos,3)
		return false
		end	
	end
return true
end


post if any problems ;)

[22/08/2009 16:39:43] Lua Script Error: [Action Interface]
[22/08/2009 16:39:43] data/actions/scripts/Custom Vets/rich update.lua:eek:nUse

[22/08/2009 16:39:43] data/actions/scripts/Custom Vets/rich update.lua:12: attempt to index global 'itemEx' (a nil value)
[22/08/2009 16:39:43] stack traceback:
[22/08/2009 16:39:43] data/actions/scripts/Custom Vets/rich update.lua:12: in function <data/actions/scripts/Custom Vets/rich update.lua:10>
 
Change script header from:
Code:
function onUse(cid, item, fromPos, item2, toPos)

To:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
[22/08/2009 17:03:06] Lua Script Error: [Action Interface]
[22/08/2009 17:03:06] data/actions/scripts/custom vets/rich update.lua:eek:nUse

[22/08/2009 17:03:06] data/actions/scripts/custom vets/rich update.lua:14: attempt to index global 'helmet' (a nil value)
[22/08/2009 17:03:06] stack traceback:
[22/08/2009 17:03:06] data/actions/scripts/custom vets/rich update.lua:14: in function <data/actions/scripts/custom vets/rich update.lua:10>
 
Code:
                doRemoveItem(helmet.old, 1)
                doRemoveItem(upgrade.uid, 1)

To:
Code:
                doRemoveItem(item.uid, 1)
                doRemoveItem(itemEx.uid, 1)
 
ops;D my bad, copyed from JDB's script, forgot to change values ;D

updated:
Lua:
local items = {
        [9927] = 2128,
        [8879] = 8880,
        [9928] = 9777,
        [2537] = 6391,
        [7892] = 7893
} 


function onUse(cid, item, fromPos, itemEx, toPos)
    if items[itemEx.itemid] then
        doPlayerAddItem(cid, items[itemEx.itemid], 1)
        doRemoveItem(item.uid, 1)
        doRemoveItem(itemEx.uid, 1)
        doSendMagicEffect(toPos,14)
        doSendAnimatedText(getCreaturePosition(cid), "Upgraded!", TEXTCOLOR_RED)
        return true
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can update only bull items.")
        doSendMagicEffect(toPos,3)
    return false
    end     
return true
end
 
Last edited:
Status
Not open for further replies.
Back
Top