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

Solved Adding a storage on first login!

calveron

Bravemansworld
Joined
Feb 5, 2008
Messages
165
Reaction score
13
Location
Sweden
So, basicly I need help!
I have a skillpoint system on my server, each level gives you 1 point.
However, I removed rook and now I want players who create their character to get 10 skill points on their first login! Anyone who wants to help me out? :)
using TFS 1.1!
 
Code:
if player:getStorageValue(storage) < 10 then
     player:setStorageValue(storage, 10)
end
Instead of storage the storage number you use for that skill.
 
It wont work, I have no clue why. No errors or anything and when I add the storage value manually, it works.. Strange

I just noticed, it added the value instead of the storage, so the storage is 0 and the value is the storage Im using..
 
Last edited by a moderator:
Unsure of the problem, but just to clarify..
Code:
if player:getStorageValue(91234) < 10 then
   player:setStorageValue(91234, 10)
end
Assuming your point system works as we assume..
You'd be using 1 storage value, and then increasing is every time you level, by 1 or 5 or 60.
So the '91234' is that storage value.
 
Code:
if player:getStorageValue(62490) == -1 then
      player:setStorageValue(62490, 10)
end
Same thing.. It works, but doesnt add it correcly :S Instead of 62490 as a key, it goes as a value.
Or actually, it seems like it adds it as a key aswell! A diferent key. However, the value is 0
 
You can also use getLastLoginSaved if it's only for new players.
Code:
if player:getLastLoginSaved() == 0 then

Or use a different storage to check if players already received it.
 
Code:
function onLogin(player)
    local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. " Please choose your outfit."
        player:sendOutfitWindow()
    end
end
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    nextUseStaminaTime[player:getId()] = 0

    player:registerEvent("modalDeath")
    player:registerEvent("deathMW")
    player:registerEvent("loginDeath")
    player:registerEvent("Skillbook")
    player:registerEvent("Destination")
    player:registerEvent("PlayerDeath")
    player:registerEvent("DropLoot")
    return true
end

    if player:getLastLoginSaved() <= 0 then
        if player:getStorageValue(62490) < 10 then
     player:setStorageValue(62490, 10)
end
 
Remove the 2 ends on line 6 and 7.
Add the part I posted between function onLogin and return true. Atm it's outside the function which means it won't be loaded when a player logs in and player will be nil.
 
Nothing. However! I changed the storage to something else and it doesn't add that either. I also noticed that the actual point script seems to be adding the storage once a new player logs in. Perhaps I could add something there?
 
Remove the 2 ends on line 6 and 7.
Add the part I posted between function onLogin and return true. Atm it's outside the function which means it won't be loaded when a player logs in and player will be nil.
I added it to the actuall skillpoint script, and now it works! Thanks alot for the help!

Ooorr.. no. Now I can't login at all haha
 
Code:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:skillWindowChoice(modalWindowId, buttonId, choiceId)
    return true
end

function onAdvance(player, skill, oldLevel, newLevel)
    if skill == SKILL_LEVEL then
        player:skillPointsAdvance(newLevel)
    end
    return true
end

function onLogin(player)
    if player:getLastLoginSaved() <= 0 then   
    if player:getStorageValue(62490) == -1 then
      player:setStorageValue(62490, 10)
end
    player:registerEvent("skillPoints_advance")
    player:registerEvent("skillPoints_modal")
    return true
end
end

It actually worked, the new character I made got 10 points. But I relogged, and couldn't log back in.
 
Last edited:
Back
Top