Nostalgian
Member
- Joined
- Mar 17, 2018
- Messages
- 66
- Reaction score
- 15
Hey, its me again.... hung up with yet another problem I can't seem to figure out.
I just discovered an issue with my smelting system. I am using opcodes to communicate back and forth between Tfs 1.2 > Otclient
This code works exactly as intended...... except for the fact that it only works for one character a time, and I have no idea why.
So here is the code:
The client sends opcode 52 to my server, and then this receives it:
All well and good here.
and then once it receives it, here is the function that is being performed:
I placed the above function into a seperate lua file inside my lib folder. I am suspecting that this is the reason why I am having the problem that I am having, but I am not sure the solution.
This function executes exactly as intended. The problem is that it will only work for one character at a time. What happens is, I log into one character, use a "forge" and can create a bronze bar. Once I do that, i can't do it with another character until the first one logs off.
If I use it on one character, and keep him logged in, then there is no functionality with additional characters until the first one is logged off.
What I have tried so far:
Gahhhh. I'm confused and I've ran out of google.
Thank you in advance for your help
I just discovered an issue with my smelting system. I am using opcodes to communicate back and forth between Tfs 1.2 > Otclient
This code works exactly as intended...... except for the fact that it only works for one character a time, and I have no idea why.
So here is the code:
The client sends opcode 52 to my server, and then this receives it:
Code:
function onExtendedOpcode(player, opcode, buffer)
local player = Player(cid)
if opcode == 52 then
-- print(buffer)
local choice = tonumber(buffer)
if choice == 1 then
Player:smeltingBronze()
end
end
and then once it receives it, here is the function that is being performed:
Code:
function Player.smeltingBronze(self)
local exhaust = Condition(CONDITION_EXHAUST_WEAPON)
local STORAGE_SKILL_LEVEL = 20038
local STORAGE_SKILL_TRY = 20039
local STORAGE_smithingMASTERY = 20040
for _, player in ipairs(Game.getPlayers()) do
if player:getCondition(CONDITION_EXHAUST_WEAPON) then
return player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
end
local skillLevel = player:getStorageValue(STORAGE_SKILL_LEVEL)
local skillTry = player:getStorageValue(STORAGE_SKILL_TRY)
local smithingMastery = player:getStorageValue(STORAGE_smithingMASTERY)
local quant = configs.experience[skillLevel][1]
if not quant then return false end
player:addCondition(exhaust)
if player:getItemCount(3266) < 1 then
player:sendCancelMessage("You need a copper ore.")
return true
end
if player:getItemCount(3269) < 1 then
player:sendCancelMessage("You need a tin ore.")
return true
end
if (skillLevel) >= 1 then
player:removeItem(3266, 1)
player:removeItem(3269, 1)
doPlayerAddItem(player,3249,1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,"You smelted a bronze bar.")
player:say("+6 Smithing Exp", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_EXPERIENCE,"You received 6 smithing exp by smelting a bronze bar.")
if skillLevel >= 1 and skillLevel <= 99 and skillTry >= (quant-6) then
setPlayerStorageValue(player,STORAGE_SKILL_TRY,skillTry + 6)
setPlayerStorageValue(player,STORAGE_SKILL_LEVEL,skillLevel + 1)
player:sendSmithingLevel()
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have advanced from Smithing Level ".. skillLevel .." to Smithing Level ".. skillLevel + 1 .."")
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
else
setPlayerStorageValue(player,STORAGE_SKILL_TRY,skillTry + 6)
player:sendSmithingTries()
return true
end
end
if skillTry >= (expmax-6) and smithingMastery == 0 then
broadcastMessage("[SYSTEM] "..player:getName().." has just advanced to Smithing Level 100.", MESSAGE_STATUS_WARNING)
player:sendWoodcuttingLevel()
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Congratulations! You earned the achievement 'Smithing Mastery'.")
player:setStorageValue(STORAGE_smithingMASTERY, 1)
return true
end
end
end
This function executes exactly as intended. The problem is that it will only work for one character at a time. What happens is, I log into one character, use a "forge" and can create a bronze bar. Once I do that, i can't do it with another character until the first one logs off.
If I use it on one character, and keep him logged in, then there is no functionality with additional characters until the first one is logged off.
What I have tried so far:
- Moving the function inside my opcode file instead of calling the function from there. (It works exactly the same, same problem)
- Removing
Code:
for _, player in ipairs(Game.getPlayers()) do
Code:local player = Player(cid)
Gahhhh. I'm confused and I've ran out of google.
Thank you in advance for your help