Author Topic: Automatic Profile Manager  (Read 2306 times)

0 Members and 1 Guest are viewing this topic.

Offline panthera

  • Newbie
  • *
  • Posts: 2
  • Karma: +1/-0
Automatic Profile Manager
« on: 24 May, 2011, 12:46:38 »
Hello,

My hub has the following Profiles
================================================
    [SHARE SIZE]                [TAG]
    ================================================
    125 GB                         STAR
    250 GB                         WOW
    500 GB                         VIP
    1 TB                             VVIP
    ================================================

I wanted a script which will automatically upgrade and downgrade users according to their Shares.

I found a script which upgrades but does not downgrade please make the required changes and post the whole script back.

Thanks In Advance.

Panthera

Script:
Code: [Select]
RegConnected = function(User)
if Core.GetUserValue(User,16) >= (500*(1024^3)) then       
local tCurProf = ProfMan.GetProfile(User.iProfile)
if tCurProf.sProfileName ~= "VIP" then                 
local tCurReg = RegMan.GetReg(User.sNick)
local tProfiles = ProfMan.GetProfiles()
for k in pairs(tProfiles) do
if tProfiles[k].sProfileName == "VIP" then     
RegMan.ChangeReg(tCurReg.sNick, tCurReg.sPassword, tProfiles[k].iProfileNumber)
Core.SendPmToUser(User,SetMan.GetString(21),"Your profile has been automatically updated to VIP.|")
end
end
end
end
end

PtokaX forum

Automatic Profile Manager
« on: 24 May, 2011, 12:46:38 »

Offline Hamachi

  • Forum Ace
  • *****
  • Posts: 88
  • Karma: +0/-7
Re: Automatic Profile Manager
« Reply #1 on: 24 May, 2011, 21:04:39 »
why downgrade  ?

Offline panthera

  • Newbie
  • *
  • Posts: 2
  • Karma: +1/-0
Re: Automatic Profile Manager
« Reply #2 on: 25 May, 2011, 10:17:27 »
why downgrade  ?

So tat if the share come down he/she will get the lower profile......as one can hash data to become vip then lower it down.which will cause Profile problems...unequal distribution.....so wanted to add downgrade system also...........


PaNtHeRa

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
Re: Automatic Profile Manager
« Reply #3 on: 02 September, 2011, 21:01:49 »
Give this a try...
I been out of PtokaX scripting for like a year or so, so script can be full of holes, errors, flawd logic and spelling misstakes and so on.
I'm to lazy to install a PtokaX on my pc, it's UNTESTED

Code: [Select]

tShareReg = {
[0] = {1,"FailSafe"}, -- DO NOT EDIT!
[1] = {125,"STAR"},
[2] = {250,"WOW"},
[3] = {500,"VIP"},
[4] = {1024,"VVIP"},
}

RegConnected = function(User)
local Size = ConvShare(User.iShareSize,"B")
local tCurProf = ProfMan.GetProfile(User.iProfile)

for i,t in ipairs(tShareReg) do
ShareRegProf = t[2] -- Should work as a failsafe if user exeades latest profile upgrade
if Size <= t[1] and Size >= tShareReg[i-1][1] then -- If share is less then current and higher then previous
ShareRegProf = t[2] -- Get new profilename
end
end
-- Time to set the ShareRegProf
if tCurProf.sProfileName ~= ShareRegProf and SharRegProf ~= "FailSafe" then
oldnr = tCurProf.iProfileNumber
local tCurReg = RegMan.GetReg(User.sNick)
local tProfiles = ProfMan.GetProfiles()
for k in pairs(tProfiles) do
if tProfiles[k].sProfileName == ShareRegProf then     
RegMan.ChangeReg(tCurReg.sNick, tCurReg.sPassword, tProfiles[k].iProfileNumber)
if tProfiles[k].iProfileNumber > oldnr then
UnD = "updated"
InD = "increased"
else
UnD = "downgraded"
InD = "decreased"
end
Core.SendPmToUser(User,SetMan.GetString(21),"Your profile has been automatically " .. UnD .. " to " .. ShareRegProf .. " due to your share has " .. InD .. ".|")
end
end
end

-- if Core.GetUserValue(User,16) >= (500*(1024^3)) then       
-- local tCurProf = ProfMan.GetProfile(User.iProfile)
-- if tCurProf.sProfileName ~= "VIP" then                 
-- local tCurReg = RegMan.GetReg(User.sNick)
-- local tProfiles = ProfMan.GetProfiles()
-- for k in pairs(tProfiles) do
-- if tProfiles[k].sProfileName == "VIP" then     
-- RegMan.ChangeReg(tCurReg.sNick, tCurReg.sPassword, tProfiles[k].iProfileNumber)
-- Core.SendPmToUser(User,SetMan.GetString(21),"Your profile has been automatically updated to VIP.|")
-- end
-- end
-- end
-- end
end

-- Lost credits for this func, but thanks to the creator of it =)
function ConvShare(iShareSize, Type) -- Convert Share Size...
while iShareSize >= 1024 and Type ~= "PB" do
if Type == "B" then
Type = "KB"
elseif Type == "KB" then
Type = "MB"
elseif Type == "MB" then
Type = "GB"
elseif Type == "GB" then
Type = "TB"
elseif Type == "TB" then
Type = "PB"
end
iShareSize = iShareSize/1024
end
return string.format("%.2f", iShareSize),Type
--return string.format("%.2f", iShareSize).." "..Type
end
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

PtokaX forum

Re: Automatic Profile Manager
« Reply #3 on: 02 September, 2011, 21:01:49 »