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

mudança no código

adrianokk

New Member
Joined
Jan 22, 2019
Messages
43
Reaction score
1
I'm making an exchange system.
and for the player to get the item, he needs to swap 2 items instead of 1.
I tried to make some changes but always the error, how to fix this?

TFS : 0.3.6

Lua:
function onSay(cid, words, param)

if getPlayerItemCount(cid, 2145) < 10 then
return doPlayerSendTextMessage(cid, 20, "Precisa de 100x + 100a.") and true
end
if getPlayerItemCount(cid, 2145) >= 10 then
doPlayerAddItem(cid, 12618, 5)
doPlayerRemoveItem(cid, 2145, 10)
doPlayerSendTextMessage(cid, 20, "voce comprou 5 Boost stone!")
return true
end

end
Code:
 
Solution
Code:
function onSay(cid, words, param)

if doPlayerRemoveItem(cid, 2145, 10) == TRUE and doPlayerRemoveItem(cid, 2148, 10) == TRUE then
    doPlayerAddItem(cid, 12618, 5)
    doSendMagicEffect(getPlayerPosition(cid), 6)
    doSendPlayerTextMessage(cid,"Você comprou 5 Boots Stone!",23)
else
    doPlayerSendCancel(cid, "Você não possui os items necessários")
end
    return TRUE
end
I don't recommend removing items before checking that all the items are available.
Otherwise it'll remove the first set of items, and then fail on the second set, causing the player to lose items without any reward.

Try this instead.
Lua:
function onSay(cid, words, param)
    if getPlayerItemCount(cid, 111111) < 10 or getPlayerItemCount(cid, 2222222) < 10...
Code:
function onSay(cid, words, param)

if doPlayerRemoveItem(cid, 2145, 10) == TRUE and doPlayerRemoveItem(cid, 2148, 10) == TRUE then
    doPlayerAddItem(cid, 12618, 5)
    doSendMagicEffect(getPlayerPosition(cid), 6)
    doSendPlayerTextMessage(cid,"Você comprou 5 Boots Stone!",23)
else
    doPlayerSendCancel(cid, "Você não possui os items necessários")
end
    return TRUE
end
 
Code:
function onSay(cid, words, param)

if doPlayerRemoveItem(cid, 2145, 10) == TRUE and doPlayerRemoveItem(cid, 2148, 10) == TRUE then
    doPlayerAddItem(cid, 12618, 5)
    doSendMagicEffect(getPlayerPosition(cid), 6)
    doSendPlayerTextMessage(cid,"Você comprou 5 Boots Stone!",23)
else
    doPlayerSendCancel(cid, "Você não possui os items necessários")
end
    return TRUE
end
I don't recommend removing items before checking that all the items are available.
Otherwise it'll remove the first set of items, and then fail on the second set, causing the player to lose items without any reward.

Try this instead.
Lua:
function onSay(cid, words, param)
    if getPlayerItemCount(cid, 111111) < 10 or getPlayerItemCount(cid, 2222222) < 10 then
        doPlayerSendCancel(cid, "Need more items for this reward.")
        return true
    end
    doPlayerRemoveItem(cid, 111111, 10)
    doPlayerRemoveItem(cid, 2222222, 10)
    doPlayerAddItem(cid, 12618, 5)
    doPlayerSendTextMessage(cid, 20, "Here is your reward.")
    return true
end
 
Solution
I don't recommend removing items before checking that all the items are available.
Otherwise it'll remove the first set of items, and then fail on the second set, causing the player to lose items without any reward.

Try this instead.
Lua:
function onSay(cid, words, param)
    if getPlayerItemCount(cid, 111111) < 10 or getPlayerItemCount(cid, 2222222) < 10 then
        doPlayerSendCancel(cid, "Need more items for this reward.")
        return true
    end
    doPlayerRemoveItem(cid, 111111, 10)
    doPlayerRemoveItem(cid, 2222222, 10)
    doPlayerAddItem(cid, 12618, 5)
    doPlayerSendTextMessage(cid, 20, "Here is your reward.")
    return true
end
Thanks for the correction, I don't know much about scripting ^ _ ^
 

Similar threads

Back
Top