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

8.6 - Line not work. if doPlayerRemoveMoney (cid, 1000) == 1 then

psilocibe

Member
Joined
Jul 9, 2007
Messages
479
Reaction score
8
What this code is wrong? It does not work on line 8.

if doPlayerRemoveMoney (cid, 1000) == 1 then

What's happening?

Code:
local config = {
        cost = 300,
        rune_id = 2409,
        backpack_id = 1995
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
        if doPlayerRemoveMoney(cid, 300) == 1 then
                local name = getItemNameById(2409)
                local bp = doPlayerAddItem(cid, config.backpack_id, 1) -- Editing this will not do anything.
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voce Comprou uma backpack ".. name .."s por  ".. config.cost .." golds.")
doSendAnimatedText({x=389,y=368,z=7}, 'Serpent', TEXTCOLOR_WHITE)
doSendMagicEffect({x=389,y=368,z=7}, CONST_ME_STUN)
--doSendAnimatedText(frompos, "Aol 30k", 89)
for i=1,1 do
                        doAddContainerItem(bp, config.rune_id, 1) -- You can edit this number, it will give shots per rune.
                end
                else
                        doPlayerSendCancel(cid, "Voce nao tem ".. config.cost .." golds.")
                end
        return TRUE
end

Client. 8.6
 
doPlayerRemoveMoney returns a boolean, true if it's successful, false otherwise.
Code:
if doPlayerRemoveMoney(cid, 300) == true then
 
Code:
if doPlayerRemoveMoney(cid,300) == 1 then
if doPlayerRemoveMoney(cid,config.cost) == 1 then
if doPlayerRemoveMoney(cid, config.cost) == TRUE then

all must work
Code:
local config = {
        cost = 300,
        rune_id = 2409,
        backpack_id = 1995
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
                  if doPlayerRemoveMoney(cid, config.cost) == TRUE then
                local name = getItemNameById(2409)
               local bp = doPlayerAddItem(cid,config.backpack_id, 1)
               doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voce Comprou uma backpack ".. name .."s por  ".. config.cost .." golds.")
                doSendAnimatedText({x=389,y=368,z=7}, 'Serpent', TEXTCOLOR_WHITE)
               doSendMagicEffect({x=389,y=368,z=7}, CONST_ME_STUN)
               doSendAnimatedText(fromPosition, "Aol 30k", 89)
for i=1,1 do
                        doAddContainerItem(bp,config.rune_id, 1)
                end
                else
                        doPlayerSendCancel(cid, "You don't have ".. config.cost .." golds.")
                end
        return TRUE
end
 
Last edited:
Can you post the script how it looks like now?
The function doPlayerRemoveMoney(cid, money) exists in TFS 0.3.6.

This code
Code:
local config = {
        cost = 300,
        rune_id = 2409,
        backpack_id = 1995
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
                  if doPlayerRemoveMoney(cid, config.cost) == TRUE then
                local name = getItemNameById(2409)
               local bp = doPlayerAddItem(cid,config.backpack_id, 1)
               doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voce Comprou uma backpack ".. name .."s por  ".. config.cost .." golds.")
                doSendAnimatedText({x=389,y=368,z=7}, 'Serpent', TEXTCOLOR_WHITE)
               doSendMagicEffect({x=389,y=368,z=7}, CONST_ME_STUN)
               doSendAnimatedText(fromPosition, "Aol 30k", 89)
for i=1,1 do
                        doAddContainerItem(bp,config.rune_id, 1)
                end
                else
                        doPlayerSendCancel(cid, "You don't have ".. config.cost .." golds.")
                end
        return TRUE
end
 
Code:
local config = {
  cost = 300,
  rune_id = 2409,
  backpack_id = 1995
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
     if doPlayerRemoveMoney(cid, config.cost) then
         local name = getItemNameById(2409)
         local bp = doPlayerAddItem(cid,config.backpack_id, 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voce Comprou uma backpack ".. name .."s por  ".. config.cost .." golds.")
         doSendAnimatedText({x=389,y=368,z=7}, 'Serpent', TEXTCOLOR_WHITE)
         doSendMagicEffect({x=389,y=368,z=7}, CONST_ME_STUN)
         doSendAnimatedText(fromPosition, "Aol 30k", 89)
         for i = 1, 1 do
             doAddContainerItem(bp, config.rune_id, 1)
         end
     else
         doPlayerSendCancel(cid, "You don't have ".. config.cost .." golds.")
     end
     return true
end
If it should only give 1 sword, you can also just remove the for loop: for i = 1, 1 do
And the end under that, the one that closes the for loop.
 
What I posted already works on TFS 0.3.6, doPlayerRemoveMoney is a function in the source that returns true or false, so == 1 won't work.
 

Similar threads

Back
Top