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

item change script on tfs 1.2+

zxzxzx

New Member
Joined
Mar 12, 2011
Messages
334
Reaction score
3
Hello! I have script which change item 2191 to item 8921 when I use item id 10305 and then items id 2191 and 10305 remove - this is ok but when I use item 10305 on the ground (not backpack) item 10305 not remove and this is the problem..

Help me to make item 10305 remove when it is on the ground too!

Thanks for help!++

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

if item.itemid == 10305 then

if doPlayerRemoveItem(cid,2191,1) == true then
doPlayerAddItem(cid,8921,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end
else
doPlayerSendCancel(cid, "You do not have any pro items to uprgade!")
end
return true
end
 
Looks like you are looking for a weapon upgrading script?

if player:getItemCount(2191) >= 1 then
player:addItem(8921, 1)
player:removeItem(10305,1)
player:sendTextMessage((MESSAGE_STATUS_WARNING),"Your weapon has been upgraded!")
else
player:sendTextMessage((MESSAGE_STATUS_DEFAULT), "You do not have any pro items to uprgade!")
end
return true
end
 
Last edited:
oh i thought it was 0.x, if its 1.x, change player:removeItem(10305) or doPlayerRemoveItem(10305) to just
item:remove()
 
I am not sure what you really mean.
You requested for TFS 1.2 correct? The code you gave us was for TFS 1.0 and before.

If you can download the master files for TFS 1.1 and on, which includes the distributions sources, you will find a file called luascript.cpp. There you will find your strings.

Also, if item.itemid isn't needed before you will be declaring that itemid in your actions.xml. Just less line to read.

Code:
function onUse(player, item)
For function use.

player:removeItem(itemid, amount to remove). doPlayerRemoveItem is outdated to TFS 1.0 and before.
 
instead of player:removeItem(10305,1) in your code, item:remove() should be used in 1.x, what you have will not work if the item is used while on the ground, wheras item:remove() will
 
Code:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(cid)
    if item.itemid == 10305 then
        player:addItem(8921, 1)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Your weapon has been upgraded!')
        item:remove()
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have any pro items to uprgade!')
    end
    return true
end
dunno if i got u correctly, but this might work no clue
 
Last edited:
Can we make the script works with more items?, I don't wan't to make single action line for single item, now my script looks like this:

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

if item.itemid == 10305 then

if doPlayerRemoveItem(cid,2191,1) == true then
doPlayerAddItem(cid,8921,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,2186,1) == true then
doPlayerAddItem(cid,8911,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,5907,1) == true then
doPlayerAddItem(cid,21690,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,7416,1) == true then
doPlayerAddItem(cid,6101,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,2447,1) == true then
doPlayerAddItem(cid,7455,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,7410,1) == true then
doPlayerAddItem(cid,7429,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,8920,1) == true then
doPlayerAddItem(cid,8922,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,2181,1) == true then
doPlayerAddItem(cid,18411,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,8850,1) == true then
doPlayerAddItem(cid,8851,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,8931,1) == true then
doPlayerAddItem(cid,8932,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,8925,1) == true then
doPlayerAddItem(cid,2443,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,7422,1) == true then
doPlayerAddItem(cid,23543,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,3961,1) == true then
doPlayerAddItem(cid,7958,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,7379,1) == true then
doPlayerAddItem(cid,13760,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,13873,1) == true then
doPlayerAddItem(cid,18453,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,7418,1) == true then
doPlayerAddItem(cid,7449,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,7433,1) == true then
doPlayerAddItem(cid,10301,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,8927,1) == true then
doPlayerAddItem(cid,7427,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,13880,1) == true then
doPlayerAddItem(cid,18409,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,13872,1) == true then
doPlayerAddItem(cid,18390,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,13871,1) == true then
doPlayerAddItem(cid,18450,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,13875,1) == true then
doPlayerAddItem(cid,18451,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

if doPlayerRemoveItem(cid,13876,1) == true then
doPlayerAddItem(cid,18452,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end
else
doPlayerSendCancel(cid, "You do not have any pro items to uprgade!")
end
return true
end

I use item id 10305 to upgrade many weapons.
 
Code:
local upg = {
[id1] = toid1,
[id2] = toid2,
}

onUse()
local tmp = upg[item2:getId()]
if item:getId() == 10305 and tmp then
item:remove()
item2:transform(tmp)
player:sendTextMessage()
end
 
Code:
local upg = {
[id1] = toid1,
[id2] = toid2,
}

onUse()
local tmp = upg[item2:getId()]
if item:getId() == 10305 and tmp then
item:remove()
item2:transform(tmp)
player:sendTextMessage()
end
where to put items ids? here?
Code:
[id1] = toid1,
[id2] = toid2,
 
Hello! I have script which change item 2191 to item 8921 when I use item id 10305 and then items id 2191 and 10305 remove - this is ok but when I use item 10305 on the ground (not backpack) item 10305 not remove and this is the problem..

Help me to make item 10305 remove when it is on the ground too!

Thanks for help!++

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

if item.itemid == 10305 then

if doPlayerRemoveItem(cid,2191,1) == true then
doPlayerAddItem(cid,8921,1)
doPlayerRemoveItem(cid,10305,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end
else
doPlayerSendCancel(cid, "You do not have any pro items to uprgade!")
end
return true
end



if doPlayerRemoveItem(cid,2191,1) == true and
doPlayerRemoveItem(cid,1035,1) == true then
doPlayerAddItem(cid,8921,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

else
doPlayerSendCancel(cid, "You do not have any pro items to upgrade!")

end
return true
end


the script first need to remove the items before give to the player the upgraded weapon.
 
if doPlayerRemoveItem(cid,2191,1) == true and
doPlayerRemoveItem(cid,1035,1) == true then
doPlayerAddItem(cid,8921,1)
doPlayerSendTextMessage(cid,21,"Your weapon has been upgraded!")
end

else
doPlayerSendCancel(cid, "You do not have any pro items to upgrade!")

end
return true
end


the script first need to remove the items before give to the player the upgraded weapon.
Error in line 7 (eof) expected near 'else'
 
change id1 to 2191, toid1 to 8921 in your case, and add more the similar way if you need
Code:
local upg = {
[2191] = 8921,
[2186] = 8911,
}

onUse()
local tmp = upg[item2:getId()]
if item:getId() == 10305 and tmp then
item:remove()
item2:transform(tmp)
player:sendTextMessage()
end

lua6 attempt to call global 'onuse' (a nil value)
 
Back
Top