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

tfs 1.2 script

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

Wouldn't this be more secure?
HTML:
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
if storage <= 0 better make count = 1 than storage + 2..
Because.. not that it's comon, but what if something is screwed, and storage appears as -2, -5.. of maybe even -2147558399?

If there would appear a wild bug somewhere, codes can be made from the beginning to not feed the bug, but break them.
It's very rare something screw up so bad.. but why not already from start creating the code, expecting things to fuck up at some point :)

Just my opinion thou..
 
What is this in red?
local count = storage > 0 and storage + 1 or storage = 1

I'll explain this for you.
Code:
local count = storage > 0 and storage + 1 or storage + 2
If the storage value is great than 0 then add 1, if it isn't meaning if its -1 add 2, -1 + 2 = 1
 
What is this in red?
local count = storage > 0 and storage + 1 or storage = 1

I'll explain this for you.
Code:
local count = storage > 0 and storage + 1 or storage + 2
If the storage value is great than 0 then add 1, if it isn't meaning if its -1 add 2, -1 + 2 = 1

I know how it works lol, I just think it's way better having = 1 than making +2..
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..
 
I know how it works lol,
If you knew how the code works you would not being asking why I wrote the code the way I did.
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..
Your right I don't understand anything you are saying, because none of it makes any sense what so ever.

Have a nice day! ;)
 
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! ;)
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...
 
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...
Just hush right now, the more you type about how you think something works the more you sound like an idiot.
 
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
I just seen the error here, this should be.
Code:
creature:setStorageValue(monster[name], count)
 
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)
 
Last edited:
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.


Code:
storage = creature:getStorageValue(monster[name])
count = math.max(0, storage) + 1
creature:setStorageValue(storage)
 
Last edited:
Code:
storage = creature:getStorageValue(monster[name])
count = math.max(0, storage) + 1
creature:setStorageValue(storage, count)
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.
 
Last edited:
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. ;)
 
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. ;)
lmao you are nothing but a piece of trash. Why not just leave the forum already codex?
 
Back
Top