• 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 Need fix for this script

Riyan

New Member
Joined
Aug 14, 2010
Messages
28
Reaction score
0
Hi,
I have a script on my server, which should replace the weapon on an improved (with another id.)
The point is that weapon when you click on the "cross" (id. 2354) turned in another direction, but it does not. When you click on this cross the weapon disappears and shows the message "You do not have any items to upgrade." Could I ask someone to fix this script?
Thanks in advance.
Code:
function onUse(cid, item, frompos, item2, topos)

	if item.itemid == 2354 then 
   
        if doPlayerRemoveItem(cid,8931,1) == 1 then
           doPlayerAddItem(cid,8932,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")

	elseif item.itemid == 2354 then 
   
        if doPlayerRemoveItem(cid,8925,1) == 1 then
           doPlayerAddItem(cid,7434,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
	
	elseif item.itemid == 2354 then 
   
        if doPlayerRemoveItem(cid,7422,1) == 1 then
           doPlayerAddItem(cid,7429,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")

	elseif item.itemid == 2354 then 
   
        if doPlayerRemoveItem(cid,8850,1) == 1 then
           doPlayerAddItem(cid,8851,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")

	elseif item.itemid == 2354 then 

        if doPlayerRemoveItem(cid,8920,1) == 1 then
           doPlayerAddItem(cid,8922,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
       else
           doPlayerSendCancel(cid, "You do not have any pro items to uprgade!")
       end
end
end
end
end
end
   
       return 1
   end
 
Hi, your script is screwed up in a lot of different ways and I will have to re-write it. I think you would be better off using a NPC, because you have all these items to check for and there is not going to be a way for the player to pick what item they want to upgrade. Do you want me to write this as a NPC script?
 
: /
Not really, I care about this, that this has happened with a particular subject.
So you're saying that this script is not practically possible to fix it?
 
No you can fix it, if you're just going to "use" a switch or what ever, the best you can do is check for the first available item to upgrade which may not be the one they want
 
These items:
Code:
		<item id="8925" article="a" name="Pro Gloving Axe">
		<attribute key="description" value="The axe is so strong its gloving. Best axe on server."/>
		<attribute key="weight" value="11000"/>
		<attribute key="defense" value="29"/>
		<attribute key="attack" value="130"/>
		<attribute key="weaponType" value="axe"/>
		<attribute key="extradef" value="3"/>
	</item>
Code:
		<item id="8931" article="the" name="Pro Sword of Lava">
		<attribute key="description" value="The sword is filled with melting lava. Best sword on server."/>
		<attribute key="weight" value="6800"/>
		<attribute key="defense" value="35"/>
		<attribute key="attack" value="130"/>
		<attribute key="weaponType" value="sword"/>
	</item>
Code:
		<item id="8920" article="a" name="Pro Death Shooter">
		<attribute key="description" value="It is sparkling black death from its tip."/>
		<attribute key="weight" value="2550"/>
		<attribute key="weaponType" value="wand"/>
		<attribute key="shootType" value="death"/>
		<attribute key="range" value="3"/>
	</item>
Code:
		<item id="8850" article="a" name="Pro ArrowShooter">
		<attribute key="description" value="It will make your crystal arrow attack 180 instead of 140."/>
		<attribute key="weight" value="5500"/>
		<attribute key="slotType" value="two-handed"/>
		<attribute key="weaponType" value="distance"/>
		<attribute key="ammoType" value="arrow"/>
		<attribute key="range" value="6"/>
		<attribute key="attack" value="30"/>
	</item>
Code:
	<item id="7422" article="a" name="Pro Club of Death">
		<attribute key="weight" value="6300"/>
		<attribute key="defense" value="80"/>
		<attribute key="attack" value="130"/>
		<attribute key="weaponType" value="club"/>
		<attribute key="description" value="This is the best club on the server. You can feel the death tilting out of the center of the club."/>
	</item>

Need to be "replaced" by these:


Code:
		<item id="7429" article="a" name="Upgraded Pro Club">
		<attribute key="description" value="This is an upgraded Pro Club. It adds death damage to the enemy."/>
		<attribute key="weight" value="11000"/>
		<attribute key="defense" value="29"/>
		<attribute key="attack" value="133"/>
		<attribute key="weaponType" value="club"/>
		<attribute key="extradef" value="3"/>
	</item>
Code:
	<item id="7434" article="a" name="Upgraded Pro Axe">
		<attribute key="description" value="This is an upgraded Pro Axe. It adds fire damage to the enemy."/>
		<attribute key="weight" value="11000"/>
		<attribute key="defense" value="29"/>
		<attribute key="attack" value="133"/>
		<attribute key="weaponType" value="axe"/>
		<attribute key="extradef" value="3"/>
	</item>
Code:
	<item id="8851" article="a" name="Upgraded Pro ArrowShooter">
	<attribute key="description" value="Use VIP Arrow with this shooter and you will become pro!."/>
		<attribute key="weight" value="12000"/>
		<attribute key="slotType" value="two-handed"/>
		<attribute key="weaponType" value="distance"/>
		<attribute key="ammoType" value="arrow"/>
		<attribute key="range" value="7"/>
		<attribute key="hitChance" value="40"/>
		<attribute key="attack" value="700"/>
	</item>
Code:
	<item id="8922" article="a" name="Upgraded Pro Wand">
		<attribute key="description" value="This wand will make death to all it touches! Upgraded range and attack!"/>
		<attribute key="weight" value="2850"/>
		<attribute key="weaponType" value="wand"/>
		<attribute key="shootType" value="death"/>
		<attribute key="range" value="6"/>
	</item>
Code:
	<item id="8932" article="the" name="Upgraded Pro Sword">
		<attribute key="description" value="This is an upgraded Pro Sword. It adds energy damage to the enemy."/>
		<attribute key="weight" value="11000"/>
		<attribute key="defense" value="29"/>
		<attribute key="attack" value="133"/>
		<attribute key="weaponType" value="sword"/>
		<attribute key="extradef" value="3"/>
	</item>
When a player click on a "cross".
Please Reply Fast.
 
Last edited:
Um ...
This script needs to work uniqueids?
I ask because I need a script that makes:
Get cross from for example. sms shop, click on an item (the cross for example), if the player is a pro weapon in the backpack or password Equipped it, this cross should change pro weapon to a upgraded pro weapon.
I mean:
Have a cross in a backpack and weapon pro Equipped, RightClick on the cross, the pro weapon should be replaced by the upgraded pro weapon, the cross disappears.

Even simpler:
Player have a cross (or any item that replaces a weapon) in backpack, or Equipped weapon in backpack too -> RightClick on the cross -> the pro weapon is Replaced by the upgraded pro weapon, the cross disappears.

Please Reply Fast,
Thanks in advance.
I really need this script working.
 
here is how it works, use the item 2354 on the pro weapons and it will upgrade it.
Code:
local pro_items = {
	[8931] = {upgraded = 8932},
	[8925] = {upgraded = 7434},
	[7422] = {upgraded = 7429},
	[8850] = {upgraded = 8851},
	[8920] = {upgraded = 8922}
	}
function onUse(cid, item, frompos, itemEx, topos)

	if item.itemid == 2354 then 
		local item = pro_items[itemEx.itemid]
        if doPlayerRemoveItem(cid,item,1) == true then
			doPlayerAddItem(cid,item[1].upgraded,1)
			doPlayerRemoveItem(cid,2354,1)
			doPlayerSendTextMessage(cid,21,"Your weapon has been to "..getItemNameById(item[1].upgraded).."!")
		end
	end
return true
end
 
Lua:
local t = {
	[8931] = 8932,
	[8925] = 7434,
	[7422] = 7429,
	[8850] = 8851,
	[8920] = 8922
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[itemEx.itemid]
	if v then
		doRemoveItem(item.uid, 1)
		doTransformItem(itemEx.uid, v)
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Your weapon has been upgraded to ' .. getItemInfo(v).name .. '!')
		return true
	end
end
 
Last edited:
I know that I write a little bit silly and annoying, but I care much for this script. I would be very thankful if someone could write this script, or maybe he has it somewhere on your computer, I asked for a place it here.
Thanks in advance

Sry for bad eng.

#Edit:
Thank you guys! You're great!
 
Okay, so there is another problem, namely, I can't use the cross(item with id 2354). If i rightclick on it, nothing happens. Does not show even the cursor to "move the object." Just nothing. Can somebody help me, please?

Sorry for my shitty eng.
 
You must use another item for this. Ornamented Ankhs are not usable externally (with crosshairs) without editing items.otb & Tibia.dat :p.
 
Thanks, but again have another problem (I hope this is the last one ;P)
Your script working correctly, but it don't removing the old pro weapon.
Am I doing something wrong?
 
Last edited:
Without adding a new Thread I ask you guys to help me with another error in another script.
This script should change (when someone clicks on the "Orshabaal's Brain" item: P) vocation with first promotion to the Super (second) promotion.
For example:
Elite Knight -> Click on an item -> Congrats! You have advanced to a Super Knight!
The script that I have done it, but after re-login, the super promotion Disappears: /
Here is the script:
Lua:
local mageffect = 43 
local level = 1 
 
function onUse(cid, item, fromPosition, itemEX, toPosition)
    local voc = getPlayerVocation(cid)
    local vocname = getPlayerVocationName(cid)
    if(getPlayerVocation(cid) >= 5 and getPlayerVocation(cid) <= 8 and getPlayerLevel(cid) >= level) then
        setPlayerPromotionLevel(cid, getPlayerPromotionLevel(cid)+1)
        local vocnamenew = getPlayerVocationName(cid)
        doSendMagicEffect(getCreaturePosition(cid), mageffect)
        doPlayerSendTextMessage(cid,19, "Congratulations! You have been promoted from "..vocname.." to "..vocnamenew.."!")
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendCancel(cid, "Your vocation may not use the brain power!")
    end
    return TRUE
end

And the vocations.lua from "lib" folder:
Lua:
function isSorcerer(cid)
    return isInArray({1, 5, 20}, getPlayerVocation(cid))
end

function isDruid(cid)
    return isInArray({2, 6, 21}, getPlayerVocation(cid))
end

function isPaladin(cid)
    return isInArray({3, 7, 22}, getPlayerVocation(cid))
end

function isKnight(cid)
    return isInArray({4, 8, 23}, getPlayerVocation(cid))
end

function isRookie(cid)
    return isInArray({0}, getPlayerVocation(cid))
end
I'll be very thankfull if someone help me with this.
Sorry for my shitty eng ^^''
Yours.
 

Similar threads

Back
Top