• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Can seem to get my upgrade lua to work

Saints Anathema

Old School Doleran
Joined
Feb 24, 2009
Messages
653
Reaction score
8
Location
BC,Canada
Using Tfs 2, and i run a edited roxors map. Decided to add some new items in monsters, was wondering if anyone knew why this wasnt working.

Code:
function onUse(cid, item, frompos, item2, topos)

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

	elseif item.itemid == 2354 then 
   
        if doPlayerRemoveItem(cid,7407,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,8929,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,9970,100) == 1 then
           doPlayerAddItem(cid,8909,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")

	elseif item.itemid == 2354 then 

        if doPlayerRemoveItem(cid,5669,1) == 1 then
           doPlayerAddItem(cid,8910,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
		
		elseif item.itemid == 2354 then 
   
        if doPlayerRemoveItem(cid,2157,100) == 1 then
           doPlayerAddItem(cid,8853,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
		
		elseif item.itemid == 2354 then 
   
        if doPlayerRemoveItem(cid,9969,1) == 1 then
           doPlayerAddItem(cid,8890,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



I get this in the server window,

Code:
[27/04/2005  08:37:57] Warning: [Event::loadScript] Can not load script. data/actions/scripts/quests/pro update.lua
[27/04/2005  08:37:57] data/actions/scripts/quests/pro update.lua:61: 'end' expected (to close 'if' at line 3) near '<eof>'

Any help is appreciated, im still learning.
ofcourse rep+
 
Hello!
You made a lot of errors. Change the items' ID that are with red color.

Code:
function onUse(cid, item, frompos, item2, topos)

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

elseif item.itemid == [B][COLOR="Red"]2354[/COLOR][/B] then 
   
	if doPlayerRemoveItem(cid,7407,1) == 1 then
		doPlayerAddItem(cid,8932,1)
		doPlayerRemoveItem(cid,2354,1)
		doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
	end
	
elseif item.itemid == [B][COLOR="Red"]2354[/COLOR][/B] then 
   
	if doPlayerRemoveItem(cid,8929,1) == 1 then
		doPlayerAddItem(cid,7429,1)
		doPlayerRemoveItem(cid,2354,1)
		doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
	end

elseif item.itemid == [B][COLOR="Red"]2354[/COLOR][/B] then 
   
	if doPlayerRemoveItem(cid,9970,100) == 1 then
		doPlayerAddItem(cid,8909,1)
		doPlayerRemoveItem(cid,2354,1)
		doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
	end

elseif item.itemid == [B][COLOR="Red"]2354[/COLOR][/B] then 

	if doPlayerRemoveItem(cid,5669,1) == 1 then
		doPlayerAddItem(cid,8910,1)
		doPlayerRemoveItem(cid,2354,1)
		doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
	end

elseif item.itemid == [B][COLOR="Red"]2354[/COLOR][/B] then 
   
	if doPlayerRemoveItem(cid,2157,100) == 1 then
		doPlayerAddItem(cid,8853,1)
		doPlayerRemoveItem(cid,2354,1)
		doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
	end
		
elseif item.itemid == [B][COLOR="Red"]2354[/COLOR][/B] then 
   
	if doPlayerRemoveItem(cid,9969,1) == 1 then
		doPlayerAddItem(cid,8890,1)
		doPlayerRemoveItem(cid,2354,1)
		doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
	end
else
	doPlayerSendCancel(cid, "You do not have any pro items to upgrade!")
end
end
 
That is very poorly scripted :p

I fixed it for you, although i was not entirely sure of what you were trying to do. My script does this: Use the item 2354(Ornamented Ankh) on an item that is in the required array, and the ankh and the item you used it on will be removed, and you get a new item.

(My script only works if that ornamented ankh has "Use With")
LUA:
function onUse(cid, item, frompos, item2, topos)

rewards = {2447, 8932, 7429, 8909, 8910, 8853, 8890}

required = {6553, 7407, 8929, 9970, 5669, 2157, 9969}
counts = {1, 1, 1, 100, 1, 100, 1}


for i = 1, #rewards do
if item2.itemid == required[i] and item2.count >= counts[i] then
	if item2.stackpos = 65535 then
		doPlayerRemoveItem(cid, required[i], 1)
	else
		doRemoveItem(item2.uid, 1)
end
		doPlayerRemoveItem(cid,2354,1)
			doPlayerAddItem(cid, rewards[i], 1)
				doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
       else
           doPlayerSendCancel(cid, "You do not have any pro items to uprgade!")
       end
end
return TRUE
end
 
Last edited:
thanks for you reply's! I greatly appreciate it. I'm still continuously learning a lot everyday. I looked at the template from a script, and pretty much just tried to change it to work. I was under the assumption that all i had to do was change the item id's needed and what you'd receive. I'm going to test both and reply,


REP+ thanks
 
You're welcome!

If you are wondering about what something in my script does,
or if it's not working as you want it to, you can ask me :thumbup:
 
Ok so, Ive looked at xampys post, and kokokoko's. I will try and explain as much as i can here. I have made 7 new items for players that they would have to find for example 100 small topaz's and have that ankh in their backpack, and it would make a new item.

Some items would require 100 of that item stacked, or just a single item.

Here is the original script i tried messing with to get work it was called pro update.lua and is apart of the Roxor's Distro.

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

So i changed out the old update weapons with items like different axes, different armors, and added things like 100 small topazs to be needed to make them.

so After reading Xampys post, i think he just wanted me to change the required ankh id to make it. I tried Kokokoko's post i literally just copy and pasted it all into a new pro update.lua and reloaded it on the server and i got this

Code:
[27/04/2005  19:18:35] Warning: [Event::loadScript] Can not load script. data/actions/scripts/quests/pro update.lua
[27/04/2005  19:18:35] data/actions/scripts/quests/pro update.lua:11: 'then' expected near '='

Im going to keep trying but if anyone else has any other suggestions, im all ears.

thanks again,
 
Miss counted the ends

Code:
function onUse(cid, item, frompos, item2, topos)

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

	elseif item.itemid == 2354 then 
   
        if doPlayerRemoveItem(cid,7407,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,8929,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,9970,100) == 1 then
           doPlayerAddItem(cid,8909,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")

	elseif item.itemid == 2354 then 

        if doPlayerRemoveItem(cid,5669,1) == 1 then
           doPlayerAddItem(cid,8910,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
		
		elseif item.itemid == 2354 then 
   
        if doPlayerRemoveItem(cid,2157,100) == 1 then
           doPlayerAddItem(cid,8853,1)
	doPlayerRemoveItem(cid,2354,1)
	doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
		
		elseif item.itemid == 2354 then 
   
        if doPlayerRemoveItem(cid,9969,1) == 1 then
           doPlayerAddItem(cid,8890,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
       end
       end
       end
 
Last edited:
Tested, and Works.

You use the Ceremonial Ankh, with the required item(s) and you get the reward item.

Appreciate the help from everyone on this,

Ofcourse Rep+


.:Edit:.
The first item worked, itemid6553 (gorehowl) and then none of the others worked, im sure its just not reading the others in the script. I'm going to try and figure it out and check back if anyone else knows.

Im just happy its atleast somewhat works lol
 
Last edited:
Back
Top