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

TFS 0.X Premium Account On One player not all account

El Man

«لَا إِلَٰهَ إِلَّا ٱللَّٰهُ»
Joined
Mar 23, 2013
Messages
161
Reaction score
33
how i can do premium account on 1 player not all player on account list

1662046361176.png

anyhelp?
 
Dear El Man,

You will need to rewrite the premium script in Lua and you need to rewrite a few parts in the C++ player.cpp file in order to make this work good. Also you will need to make changes how you will identify it in the database. Now it is set to the account, if the account has X days of premium left. You will need to make it a JSON for example so you can have it add the player and then make the premium function to read it from JSON from the database.

Description can be feel a bit odd, but trying to make it as best of understanding.
Also I might have missed a few things, its a good headstart to go and where to search for and how you would want to refactor it.

Kind regards,
Ralumbi
 
There are many C++ edits to be done, both client and server (and accompanying LUA edits)

It would probably be better (if you are not experienced) to create a new LUA based system ontop of the current premium system for this.
 
Dear El Man,

You will need to rewrite the premium script in Lua and you need to rewrite a few parts in the C++ player.cpp file in order to make this work good. Also you will need to make changes how you will identify it in the database. Now it is set to the account, if the account has X days of premium left. You will need to make it a JSON for example so you can have it add the player and then make the premium function to read it from JSON from the database.

Description can be feel a bit odd, but trying to make it as best of understanding.
Also I might have missed a few things, its a good headstart to go and where to search for and how you would want to refactor it.

Kind regards,
Ralumbi
Thank you for your respect in speaking and I will try follow the steps you gave me and if I dont succeed I will follow tibia on 1 player can enter per account
 
I don't know if it will work, I don't have a way to test it in your version.

A trick to make it work with storage:
Lua:
local config = {
    storageTime = 677777
}

function onLogin(cid)
    local time = tonumber(getCreatureStorage(cid, config.storageTime)) or -1
    if time == -1 then
        doPlayerAddPremiumDays(cid, -getPlayerPremiumDays(cid))
        return true
    elseif time >= os.time() then
        doPlayerAddPremiumDays(cid, 999)
        return true
    end
    return true
end

--[[ XML:
<event type="login" name="PremiumPerPlayer" script="premiumPerPlayer.lua" />
]]

--[[ data/lib/050-function.lua
    function setPlayerCustomPremiumDays(days)
        doPlayerAddPremiumDays(cid, -getPlayerPremiumDays(cid))
        doPlayerAddPremiumDays(cid, 999)
        doCreatureSetStorage(cid, config.storageTime, os.time() + days * 86400)
    end
]]

Just in case anyone else would like this for TFS 1.4+, here it is:
Lua:
local creatureEvent = CreatureEvent("premiumPerPlayer")

function creatureEvent.onLogin(player)
    local time = tonumber(player:getStorageValue(config.storageTime)) or -1
    if time == -1 then
        player:setPremiumTime(0)
        return true
    elseif time >= os.time() then
        player:addPremiumDays(999)
        return true
    end
    return true
end

creatureEvent:register()

function Player:setCustomPremiumDays(days)
    self:setPremiumTime(0)
    self:addPremiumDays(days)
    self:setStorageValue(config.storageTime, os.time() + days * 86400)
end
 
Back
Top