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

weapon charges

Gubailovo

Well-Known Member
Joined
Dec 19, 2013
Messages
412
Solutions
2
Reaction score
71
I want to make freelance weapons. which, after a certain number of strokes, could be transformed into a better one.
\data\actions\lib\actions
LUA:
function addCharge(cid, itemuid)
    charge = itemUseCharge(itemuid)
    doPlayerSendTextMessage(cid,18,"charges: "..charge )
    if charge > 10000 then
        --doPlayerRemoveItem(cid, itemid, 1)
        --doRemoveItem(itemuid, 1)
        doPlayerSendTextMessage(cid,20,"The weapon is ready to be upgraded.")
    end
end
function tryUseSword(item)
     charges = getItemCharges(item.uid)
    if chrages < 10000 then
        setItemCharges(item.uid, charges + 1)
        return true
    else
        return false
    end
end
\data\actions\scripts\frilanssword
Code:
addCharge(cid, item.uid)
instead of adding blows, he takes them away. This is not critical, you can do -10000. But it's not pretty. If anyone can help I would be grateful.


XML:
        <item id="8716" isSword="1" dmax="900000000" charges="20">
</item>
 

Attachments

  • ezgif.com-gif-maker (1).gif
    ezgif.com-gif-maker (1).gif
    1.2 MB · Views: 22 · VirusTotal
Solution
X
If you can only do negative charges, just change
LUA:
charge = itemUseCharge(itemuid)
to
LUA:
charge = itemUseCharge(itemuid) * -1

multiplying by -1, will invert the number to a positive.

I'm not sure if this is what you intended, but it'll probably lead to a solution for you?

--
Else, you need to explain the exact issue you are wanting help with, cuz it's not really clear at the moment. xD
If you can only do negative charges, just change
LUA:
charge = itemUseCharge(itemuid)
to
LUA:
charge = itemUseCharge(itemuid) * -1

multiplying by -1, will invert the number to a positive.

I'm not sure if this is what you intended, but it'll probably lead to a solution for you?

--
Else, you need to explain the exact issue you are wanting help with, cuz it's not really clear at the moment. xD
 
Solution
If you can only do negative charges, just change
LUA:
charge = itemUseCharge(itemuid)
to
LUA:
charge = itemUseCharge(itemuid) * -1

multiplying by -1, will invert the number to a positive.

I'm not sure if this is what you intended, but it'll probably lead to a solution for you?

--
Else, you need to explain the exact issue you are wanting help with, cuz it's not really clear at the moment. xD
thanks a lot. it works
 
new problem
LUA:
ID_FRILANSSWORD_1   = 8708
ID_FRILANSSWORD_2   = 8716
ID_SOUL_OF_THE_BOSS = 8504
ID_COIN_DWARF        = 2151
ID_RUBY             = 2147
ID_EMERALD          = 2149
ID_SAPPHIRE         = 2146
ID_AMETHYST         = 2150    

function onUse(cid, item, item2)
     --check if the weapon is ready for upgrade
    if getItemCharges(8708) < 100000 then
             --check if all materials are in place
        if checkItem(cid, ID_FRILANSSWORD_1, 1) == 1 and checkItem(cid, ID_SOUL_OF_THE_BOSS, 1) == 1 and checkItem(cid, ID_COIN_DWARF, 10) == 1 and checkItem(cid, ID_RUBY, 100) == 1 and checkItem(cid, ID_EMERALD, 100) == 1 and checkItem(cid, ID_SAPPHIRE, 100) == 1 and checkItem(cid, ID_AMETHYST, 100) == 1 then
             --we collect all the materials for improvement
             doPlayerRemoveItem(cid, ID_FRILANSSWORD_1, 1)
             doPlayerRemoveItem(cid, ID_SOUL_OF_THE_BOSS, 1)
             doPlayerRemoveItem(cid, ID_COIN_DWARF, 10)
             doPlayerRemoveItem(cid, ID_RUBY, 100)
             doPlayerRemoveItem(cid, ID_EMERALD, 100)
             doPlayerRemoveItem(cid, ID_SAPPHIRE, 100)
             doPlayerRemoveItem(cid, ID_AMETHYST, 100)
             --issue upgraded weapons
             map_uid = doPlayerAddItem(cid, ID_FRILANSSWORD_2, 1)

            else
            doPlayerSendTextMessage(cid, 22, "Not enough materials to upgrade weapons.")
        end
    else
        doPlayerSendTextMessage(cid, 22, "To raise the level of weapons, you need to increase the number of hits inflicted by them.")
    end
    return 1
end
how to bind the number of charges of an object.
if the number of charges is less than 100000, then sends a message. (string30)
LUA:
else
        doPlayerSendTextMessage(cid, 22, "To raise the level of weapons, you need to increase the number of hits inflicted by them.")
    end
creating new weapons is impossible.

that's all I could think of(string12), but it doesn't work (if all the ingredients are there, then the script is executed). despite the limitation of 100,000 charges.
 
Getitemcharges is probably still returning negative value. You can always debug your code by printing the messages in the console or local chat
 
Getitemcharges is probably still returning negative value. You can always debug your code by printing the messages in the console or local chat
thanks for the hint. decided
LUA:
 if getItemCharges(8708) < -100000 then
 
Back
Top