matthew123456
New Member
- Joined
- Aug 24, 2013
- Messages
- 124
- Reaction score
- 4
does anyone have or could make a killed monsters counter for tfs 1.2 thanks n advance
local monster = {
['dragon'] = 123456
}
function onKill(creature, target)
if creature:isPlayer() and target:isMonster() then
local name = target:getName():lower()
if monster[name] then
local storage = creature:getStorageValue(monster[name])
local count = storage > 0 and storage + 1 or storage + 2
creature:setStorageValue(storage, count)
creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. count .. "x " .. name ".")
end
end
return true
end
Code:local monster = { ['dragon'] = 123456 } function onKill(creature, target) if creature:isPlayer() and target:isMonster() then local name = target:getName():lower() if monster[name] then local storage = creature:getStorageValue(monster[name]) local count = storage > 0 and storage + 1 or storage + 2 creature:setStorageValue(storage, count) creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. count .. "x " .. name ".") end end return true end
local monster = {
['dragon'] = 123456
}
function onKill(creature, target)
if creature:isPlayer() and target:isMonster() then
local name = target:getName():lower()
if monster[name] then
local storage = creature:getStorageValue(monster[name])
local count = storage > 0 and storage + 1 or storage = 1
creature:setStorageValue(storage, count)
creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. count .. "x " .. name ".")
end
end
return true
end
local count = storage > 0 and storage + 1 or storage + 2
What is this in red?
local count = storage > 0 and storage + 1 or storage = 1
I'll explain this for you.
If the storage value is great than 0 then add 1, if it isn't meaning if its -1 add 2, -1 + 2 = 1Code:local count = storage > 0 and storage + 1 or storage + 2
If you knew how the code works you would not being asking why I wrote the code the way I did.I know how it works lol,
Your right I don't understand anything you are saying, because none of it makes any sense what so ever.What if something is wring the server and it's -2000, then your way of doing it would make storage to -1998... when it could make it right directly by making it 1.
But apparently you didn't understand my post at all..
Then you haven't had enough experience..If you knew how the code works you would not being asking why I wrote the code the way I did.
Your right I don't understand anything you are saying, because none of it makes any sense what so ever.
Have a nice day!![]()
Just hush right now, the more you type about how you think something works the more you sound like an idiot.Then you haven't had enough experience..
If the bit-system fails at some point in your server, it fucks up a lot, your way writing codes determine how fucked up the server gets by it.
My way of doing it, keep it at bay long enough so the issue can be fixed..
Your way of doing it just accelerate the problems of the server and you'll need to close it down to fix it, as it can't wait.. and if unlucky, you might even have to make a rollback...
Holy crap you're naive, just stop already..Just hush right now, the more you type about how you think something works the more you sound like an idiot.
I just want to LoL at everything you have posted in this thread.. wait LoL, I feel so much better now.Holy crap you're naive, just stop already..
You have no idea the possibilities in programs with that statement.
I just seen the error here, this should be.Code:local monster = { ['dragon'] = 123456 } function onKill(creature, target) if creature:isPlayer() and target:isMonster() then local name = target:getName():lower() if monster[name] then local storage = creature:getStorageValue(monster[name]) local count = storage > 0 and storage + 1 or storage + 2 creature:setStorageValue(storage, count) creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. count .. "x " .. name ".") end end return true end
creature:setStorageValue(monster[name], count)
If this is the case then whatever storage value is will always be the count and will always be the storage value, the value will never change.Does it really matter if you make it equal 1? @Omni Cloud Dont understand how it could be a bad thing?
Personally i would use
local count = math.max(1, storage)
If this is the case then whatever storage value is will always be the count and will always be the storage value, the value will never change.
storage = creature:getStorageValue(monster[name])
count = math.max(0, storage) + 1
creature:setStorageValue(storage)
That's incorrect, I think you didn't see the corrected code or don't know what the code says and just got caught up in trying to prove your point of view.Code:storage = creature:getStorageValue(monster[name]) count = math.max(0, storage) + 1 creature:setStorageValue(storage, count)
kThat's incorrect, I think you didn't see the corrected code or don't know what the code says and just got caught up in trying to prove your point of view.
lmao you are nothing but a piece of trash. Why not just leave the forum already codex?Btw I wouldn't take any of your advice code wise... stick to something you are good at.. you know those copy and pasting modal window scripts you keep releasing.![]()