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

Solved doPlayerAddPremiumDays

Demnish

Tibian Hero
Joined
Sep 28, 2011
Messages
401
Solutions
2
Reaction score
63
Location
Sweden
SOLVED
OTServ 0.6.4 had doPlayerAddPremiumDays hardcoded, it was just my base script that was broken. Check out WibbenZ's scripts below if you have a persistent problem, maybe it'll help you.


I have a problem with my functions.lua.

Got it working but after some tweaking it broke,
when I reverted back it wouldn't work either. (which is really wierd)

I am using the [8.6] OTServ 0.6.4 STABLE distro for my current project.
Unfortunately this distro does not come with doPlayerAddPremiumDays implemented.

functions.lua
LUA:
function doPlayerAddPremiumDays(cid, count)
    if isPlayer(cid) == true then
    return doPlayerAddPremiumDays(cid, count)
end

    return false
end

function doPlayerRemovePremiumDays(cid, count)
    if isPlayer(cid) == true and count > 0 then
    return doPlayerAddPremiumDays(cid, count)
end

    return false
end

This code does not work at this time, I don't even know what I am doing, so I would really appreciate some help to learn what's wrong and to fix it.
 
Last edited by a moderator:
Solution
premend is an int(10).

However, I had to use Unix Time Converter to add my premium time manually.


So if I simply change premend to premdays it feels like I will f*ck it up beyond repair, assuming both the distro and the AAC is run off of this?
I use Geisor AAC.

TD;LR: It is using date instead of days.

Humm I guess you can use this then;
LUA:
function doPlayerAddPremiumDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `premdays` = `premdays` + " .. days * 60 * 60 * 1000 .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
LUA:
function doPlayerAddPremiumDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `premdays` = `premdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

function doPlayerRemovePremiumDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `premdays` = `premdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
 
Oh, I forgot to mention, I don't actually have "premdays" I have "premend".
do I simply change the table from "premend" to "premdays"?

This is the script I had when it was working:
functions.lua
LUA:
function doPlayerAddPremiumDays(cid, count)
if isPlayer(cid) == true and level >= 1 then
  local experience = getPlayerRequiredExperience(cid, getPlayerLevel(cid)+level)
  return doPlayerAddExp(cid, experience)
end

return false
end
 
Last edited by a moderator:
Oh, I forgot to mention, I don't actually have "premdays" I have "premend".

do I simply change the table from "premend" to "premdays"?

If premend is an integer that holds the days and not the date (my guess since they use premend) you should be fine.
So check your database and see what premend has in it.
 
premend is an int(10).

However, I had to use Unix Time Converter to add my premium time manually.
Account Status: Premium Account, ends Monday 22nd of January 2018
premend for my account in the database: 1516582800

So if I simply change premend to premdays it feels like I will f*ck it up beyond repair, assuming both the distro and the AAC is run off of this?
I use Geisor AAC.

TD;LR: It is using date instead of days.
 
premend is an int(10).

However, I had to use Unix Time Converter to add my premium time manually.


So if I simply change premend to premdays it feels like I will f*ck it up beyond repair, assuming both the distro and the AAC is run off of this?
I use Geisor AAC.

TD;LR: It is using date instead of days.

Humm I guess you can use this then;
LUA:
function doPlayerAddPremiumDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `premdays` = `premdays` + " .. days * 60 * 60 * 1000 .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
 
Solution
Solved it, apparently it was hardcoded, it was just my base script that was trash. LMAO

Thanks alot for your help though WibbenZ, appreciate it! :)
 
Back
Top