Jump to content

VipLib v1.4b + VipAdmin v1.3a [Updated]


Rafael

Recommended Posts


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  07/08/12
  • Last Seen:  

VipLib + VipAdmin

(Developed by Rafael Perrella)

Description

This system allows administrators to manage some new groups of players (usually known as donaters, special players or VIPs). It allows you to move players to these groups for a limited period of time (maybe some hours, days or months). When the time is over, they are moved back to the players' default group, 0, automatically. The system accepts more than one group (up to 126). With a precision of seconds, in the exact second a player's VIP time ends he'll be moved back to the default group. There's no need to logout to activate or deactivate the new group.

Download

It requires two files to work: VipLib v1.4b and VipAdmin v1.3a. [uPDATE: now, VipAdmin asks for username, not account id]

If you are using eAthena, use VipLib v1.4b.eA instead of VipLib v1.4b: http://rafaworks.zzl.org/root/scripts/accountmanager/viplib/v1.4b.eA.txt (still not tested, I'll try it soon)

Configurations

Just download the 2 files above, put them in NPCs folder and activate them. The NPC is at prontera 147 174, but you can also access it sending a message to npc:#vipadmin.

The script uses the group ids 1, 5, 6, 7, 8 as special groups. If you want other groups, open VipLib's file and search for "setarray $@AM_Vip_Groups", then edit the numbers (or remove, or add more numbers). Put the ids sorted from the worse to the best.

Special thanks to...

- frozenfox, for reporting a bug (of compatibility) in VipLib v1.0.x.

- Hybrid, for translating the old changelog file.

- DarkWhoteva, for testing and translating VipLib v1.2b.

How does it work? (for scripters)

We have two scripts here. Let's call these special groups "VIP groups".

The VipLib is a library of functions to manage these groups. The script considers that for every pair of groups, one is better than the other; so, if a player is in two (or more) groups at the same time, it'll first spend the best group's time and, when it's over, move them to the next group (worse than the last, better than all the rest he's in). Below, all the functions it has (time is always given in seconds):

The functions below might be called using callfunc. For example, to call vip_add, use: callfunc("vip_add", time, group_id, account_id);

Main functions

vip_add(time, group_id=1, account_id=getcharid(3))

Adds some VIP time (group <group_id>) to a player.

vip_remove(time, group_id=0, account_id=getcharid(3))

Removes some VIP time (of a specified group) of a player. If the group_id is 0, start removing the time from the best group, then the second best and so on, until there's no more time to remove.

vip_set(time, group_id=1, account_id=getcharid(3))

Alters the player's group <group_id> time to <time>.

vip_read(group_id=0, account_id=getcharid(3))

Returns a player's VIP time. If group_id is specified as 0, returns the sum of all his VIP group's time.

vip_clear(account_id=getcharid(3))

Clears all times of a player, moving him to the default group.

vip_getgroupid(account_id=getcharid(3))

Returns the group id of a player. Similar to getgroupid(), except for: it lets you specify an account_id; works even for offline players; only works for players in groups managed by VipLib (it means it doesn't work for Game Masters).

vip_listgroupid(account_id=getcharid(3), var_name="@AM_VipLevel" or "$@AM_VipLevel")

Lists all the groups a player is in (sorted by better to worse), and saves it in an array (@AM_VipLevel, if a player is attached, $@AM_VipLevel, if no player is attached, or the name you give as argument to var_name). Returns the amount of groups listed.

Main variables

$AM_Vip<account_id>[<group_id>]

It saves the player's VIP times in the array $@AM_Vip<account_id>[<group_id>]. For example, if account 2000001 has 60 seconds of group_id 3 left, then $@AM_Vip2000001[3] will be 60. The index 0 of this array tells us the last time a VIP group was updated. It means, if gettimetick(2)=1350762900 (now), and $@AM_Vip2000001=1350762800, it means that 100 seconds passed since the last time we updated this player's groups, so we need to remove 100 seconds from his VIP.

$@AM_Vip_Groups[]

Contains a list of all special groups that the script might manage, sorted from the worse to the best. You can edit this array if you need to remove or add some groups. For default, I put 1,5,6,7,8. Never use 0 or an id higher than 127 as a special group.

$@AM_Vip_CountGroups

Contains the amount of groups listed in $@AM_Vip_Groups.

$@AM_Vip_IsValidGroup[<group_id>]

If $@AM_Vip_Groups contains <group_id>, then $@AM_Vip_IsValidGroup[<group_id>]==1, else it equals 0. Observation: it also returns 1 for the group_id 0.

$@AM_Vip_AlterSQL

For default, VipLib doesn't access SQL tables directly (only uses variables and temporary groups). If you want to update the group id of the players managed by VipLib in your database's `login` table, set $@AM_Vip_AlterSQL to 1.

Other functions

vip_update(account_id=getcharid(3), refresh=true)

Updates the player's VIP times. If refresh=true and the player should be moved to another group after the update, it will call vip_refresh function with his new group id as argument.

vip_refresh(group_id=0, account_id=getcharid(3))

Refreshes a player's group, changing it to the specified group id. If the player is a Game Master, it won't do anything.

vip_reload_groups()

When you change the list of groups ($@AM_Vip_Groups[]), you need to run this function to update $@AM_Vip_CountGroups and $@AM_Vip_IsValidGroup[].

VipManager functions

vipm_npc

It isn't a function, but an npc. Before v1.2b of VipLib, there was a separate script, named VipManager, to manage the timers (and move the players to the correct group in the exact second their special group time was over); then I merged the two scripts.

-- OnInit: loads the default groups (unless another script has already done it).

-- OnPCLoginEvent: start the timers.

-- OnRefreshVip: when a player's VIP time is changed, it's necessary to refresh his timers. Call this event to do it. Observation: this event is called automatically when you update the VIP time using the VipLib functions, so you don't need to care about it. This event will call the function "vipm_force_call".

vipm_refresh(account_id=getcharid(3))

Call this function to run vipm_npc::OnRefreshVip for account <account_id>.

vipm_format_time(time_in_seconds)

Receives a time in seconds and returns a string with the two units that better fit this time. For example, the expression (5*(24*60*60) + 3*(60*60) + 5*60) equals 5 days, 3 hours and 5 minutes. This function would return the string "5 days and 3 hours".

vipm_force_call(account_id=getcharid(3))

Calls all functions listed in $@AM_Vip_CallOnRefresh$[]. These functions will received as parameter the player who called "vipm_force_call". Before each call, the script attachs <account_id> (using attachrid).

VipManager variables

$@AM_Vip_DisableManager

If you change the value to 1, then the VipManager will be disabled. Use it only when you've made your own Manager, and don't want the official manager running.

@AM_Vip_DisableManager

Do the same as $@AM_Vip_DisableManager, but only for one player. If there's a list of players you want to keep permanently in a special group managed by VipLib, so create an npc that sets his @AM_Vip_DisableManager to 1 on login.

$@AM_Vip_CallOnRefresh$[]

Contains a list of function that might be called each time event vipm_npc::OnRefreshVip is executed. If you want your function to be called, just add it to the array:

set $@AM_Vip_CallOnRefresh$[getarraysize ($@AM_Vip_CallOnRefresh$)], "my_function";

About VipAdmin, it's a script that uses the list of functions available in VipLib to let administrators add, remove, set, read or clear the player's vip. The script could be much better, but I have no time left to do it. So, if you can do a better script using VipLib, I would appreciate your contribution =D

Edited by Rafael
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  29
  • Topics Per Day:  0.01
  • Content Count:  375
  • Reputation:   88
  • Joined:  12/30/11
  • Last Seen:  

Nice one!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  07/08/12
  • Last Seen:  

Thanks Alexandria =D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  45
  • Reputation:   7
  • Joined:  04/03/12
  • Last Seen:  

oh Thanks im really need it thx for ur job

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  22
  • Reputation:   0
  • Joined:  06/14/12
  • Last Seen:  

ah.. i found a bug.

i'm using rAthena, and it doesn't have @adjgmlvl, but @adjgroup.

so, if i using your script, in chat log always show "@adjgmlvl is unknown command"

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

ah.. i found a bug.

i'm using rAthena, and it doesn't have @adjgmlvl, but @adjgroup.

so, if i using your script, in chat log always show "@adjgmlvl is unknown command"

The script is old.. thus, it was in eAthena when this was created and not rAthena. Thus, commands that were used in eAthena like @adjgmlvl wont work in rAthena servers.

Unless Rafael decides to update it more to suit rAthena, then you'll have to do all the changes and configurations yourself.

Edited by Mysterious
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  07/08/12
  • Last Seen:  

Thanks for the report. I've updated the script, it might work now. Only VipLib file needs to be updated.

Changelog: TXT (portuguese)

If you wanna make a script to this system, please take a look at the documentation file: english doc (sorry for bad translation, the original doc is here and here).

Edited by Rafael
Link to comment
Share on other sites

  • 4 weeks later...

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  01/02/12
  • Last Seen:  

-translated changelog-

15/07/12 - VipLib v1.0.1b.ra [Rafael]

* Updated cash_refresh function (@adjgmlvl to @adjgroup)

- Thanks to frozenfox's report.

10/03/12 - CashLib v1.0.1b [Rafael]

* Fixed bug: multiple calls to cash_globalize without cash_update between them

- Emulator was executing events twice in a row

11/01/12 - VipManager v1.0b [Rafael]

* Minor changes [Rafael]

- The documentation already foretold these changes, I just never realized it

- Overrode the versions, since they should have come modified as such in the first version (** translator comment: I think he means that he properly wrote out the version names, though I could be wrong **)

11/01/12 - VipLib v1.0.1b

* Function optimization [Rafael]

11/12/11 - VipManager v1.0b

* Script developed from VipAdmin v1.0a [Rafael]

- Possesses the main function: controlar o VIP (remove when necessary)

10/12/11 - VipLib v1.0b

* Script developed [Rafael]

- Continuation of CashAdminLib (now divided as CashLib and VipLib).

- Esta versão traz suporte a vários níveis VIP e o fim da divisão entre TXT e SQL.

- Com vários níveis, as pesquisas ao banco de dados tornariam-se mais pesadas.

- A melhor solução foi utilizar o mesmo algorítmo para ambos os scripts.

10/12/11 - CashLib v1.0b

* Script developed [Rafael]

- CashAdminLib continuation.

* <aid> will always be the last argument of the functions (Math3us's suggestion) [Rafael]

- <aid> will be optional (standard: getcharid(3)); I preferred to not change versions, since I won't be maintaining the older version

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  07/08/12
  • Last Seen:  

Thanks Hybrid.

- Overrode the versions, since they should have come modified as such in the first version (** translator comment: I think he means that he properly wrote out the version names, though I could be wrong **)
This is result of a bad-written changelog, sorry xD... I forgot to put what minor changes I've made. And I don't remember now =/. In BR community they don't seem to care about changelog, so I've never worried about writting this properly.

rafaworks.zzl.org/root/scripts/accountmanager/changelog.en.txt

Edited by Rafael
Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  125
  • Topics Per Day:  0.03
  • Content Count:  595
  • Reputation:   23
  • Joined:  02/23/12
  • Last Seen:  

adding exp and drop rates would be fun

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  54
  • Reputation:   4
  • Joined:  01/09/12
  • Last Seen:  

How do you know what vip lvl gives what? the npc and script works fine for me :3

Edit: Ahh just noticed the comment above, how hard would it be to add rates to the script?

Edited by DarkWhoteva
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  07/08/12
  • Last Seen:  

@Dark

This npc is old. There were no groups, just levels, and if a level was higher than another, then this level would contain all commands from the lower level (and maybe some new commands). It means a higher level is always a better level, so I just had to choose the higher level to spend first, then the second best and so on...

Now, with groups, it isn't totally true. A higher id can be worse than a lower one. The script chooses the higher group id (it doesn't mean it's the best, but that's all I can do).

The npc accepts at most 19 group ids, those with ids 1-19. It considers a GM a player who has gm level higher than 19. It will ignore the GM groups (the groups that have level higher than 19) with ids between 1 to 19, but if you have more than 1 type of VIP, make sure the VIP you want to spend first is the one with the higher group id.

@Mr BrycE

It could be a good npc. I just don't add it to VipLib/VipManager because the only thing these npcs must do is control the vip. You can develop a simple script that gives more exp or drop itens when the player dies, if he is VIP (just check his getgmlevel()).

@topic

.:. IMPORTANT WARNING :: if you are using VipAdmin v1.1a, UPDATE your VipManager v1.0b to v1.0.1b!! It has a bug that makes the VIP only end when the player logs out!! Unfortunately, no one has ever reported this bug to me =/. I found it today while reading VipManager's source.

Edited by Rafael
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  54
  • Reputation:   4
  • Joined:  01/09/12
  • Last Seen:  

If i could get someone to add rates and stuff, would i be able to post the modifications? only on this post tho so people know that you released it

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  07/08/12
  • Last Seen:  

Yes, you may post it. And if you want, you may also create a new topic for your modification ^^. That's something I would love to see, someone improving this script, not just using it...

And it's not hard to add rates to the script, but the truth is you don't need to edit the script to put rates. I'm gonna give you an example:

- script #exp_ratio -1,{

OnInit: // configurations
set .BaseRatio, 100; // gives more 100% of BaseExp
set .JobRatio, 100; // gives more 100% of JobExp
end;

OnNPCKillEvent:
if (getgmlevel() >= 1)
{
   set BaseExp, BaseExp + .BaseRatio * getmonsterinfo (killedrid, 3) / 100;
   set JobExp, JobExp + .JobRatio * getmonsterinfo (killedrid, 4) / 100;
}
end;

}

But if you still prefer to edit VipLib, VipManager or VipAdmin to add this feature, I recommend you to wait for some hours, because today I'm gonna release a new version of VipLib/VipManager. And later, a new version of VipAdmin, compatible to the new version of VipLib.

@edit

Maybe it's better use getgroupid() instead of getgmlevel().

Edited by Rafael
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

How to make this script for 1 VIP Group only? For group 1 (GM Level 1)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  54
  • Reputation:   4
  • Joined:  01/09/12
  • Last Seen:  

Let me know when its edited :3 ill download the new one and ill get someone to help it, but il add the script you said when i got the updated to test it. thanks!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  07/08/12
  • Last Seen:  

@uDe

Just give only group 1 to the players. You aren't forced to use the other groups =D.

@Dark

I've already released the script, but I still didn't translate it to english, so I can't post it here yet.

I still need to clean up the code, but it's already functional. I tried to mantain some compatibility to eAthena and to old revisions of Cronus, so the code got a little confusing. I might remove this compatibility and make two separated versions later. For now, if you know portuguese, you can visit my topic here and try VipLib v1.2b. The new version is a join of VipLib and VipManager, so there will be no new versions of VipManager. And I prefered to publish the VipLib as the main script and put VipAdmin as a secondary script, since it's not entirely required (a lot of people prefer to create an item which gives VIP, or an npc that sells VIP for cash, instead of giving the VIP manually with VipAdmin, so the VipManager was enough).

@edit

I also fixed some bugs / problems. The message saying "your group was changed" was annoying, so it only changes group when it's really necessary. Also, when trying to read cash of a Game Master, the script forced him to become a normal player (until he logs out). Now it doesn't happen.

For the new version, you will need to use level 0 for all VIP groups. That's how the script distinguishes players from GMs. But if you are using a higher level, you need to use a script like this:

- script changeMinGMLevel#vipLib -1,{
OnInit:
   set $@AM_Vip_GMLevel, <minimum level to consider the player a GM>;
   end;
}

PS: sorry for bad english

Edited by Rafael
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  54
  • Reputation:   4
  • Joined:  01/09/12
  • Last Seen:  

i can sorter translate it, but it wont be in script form, i mean like this

//=========================================
// AccountManager :: VipLib v1.2b
// Desenvolvido por Rafael Perrella
//=========================================
// Para torná-lo compatível com versões antigas do emulador, substitua getgroupid() por getgmlevel()
// e crie um npc que seta $@AM_Vip_OldRev para 1 e $@AM_Vip_GMLevel para 20 ao iniciar o servidor
// vip_add (amount, group_id=1, uid=getcharid(3))
function script vip_add {
set .@varName$, "$AM_Vip" +  getarg (2, getcharid (3)) + "[" + getarg (1, 1) + "]";
callfunc ("vip_update",  getarg (2, getcharid (3)), 0);
setd .@varName$, (getd (.@varName$) + getarg (0) > 0) ? getd (.@varName$) + getarg (0) : 0;
return callfunc ("vip_update",  getarg (2, getcharid (3)));
}

And

//=========================================
//:: AccountManager VipLib v 1.2 (
//Developed by Rafael Perrella
//=========================================
//To make it compatible with older versions of the emulator, replace getgroupid () by getgmlevel ()
//and create an npc that arrow $ @ AM_Vip_OldRev for 1 and $ @ AM_Vip_GMLevel for 20 when starting the server
//vip_add (amount, group_id = 1, uid = getcharid (3))
function vip_add {script
set @ $ varName, "$ AM_Vip" + getarg (2, getcharid (3)) + "[" + getarg (1, 1) + "]";
callfunc ("vip_update", getarg (2, getcharid (3)), 0);
setd. @ $ varName, (getd (. @ $ varName) + getarg (0) > 0)? getd (. @ $ varName) + getarg (0): 0;
return callfunc ("vip_update", getarg (2, getcharid (3)));
}

If its any good, lemme know and il try to do the rest

Edited by DarkWhoteva
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  07/08/12
  • Last Seen:  

If you understand the translation, then that's good enough =P.

Just be careful to not translate the code. I can see you replaced ".@" for "@ $ " or "$ @ ".

But the only things that need translation, for now, are the messages in vipm_npc and vipm_format_time, because I will release a new version later (I'm programming myself to do it next Saturday, but not sure), and I guess it would be boring having to translate it again =/.

If you translate, do not forget to put your credits below mine ("Translation by DarkWhoteva" or something like this).

I will be busy for exactly 17 days starting from tomorrow, but I'm trying to reserve some time for the script.

@edit

It's 8:32 am here in BR now, and I still didn't sleep. I'm going now, so don't wait for an answer before 16 o'clock (GMT -3).

Edited by Rafael
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  54
  • Reputation:   4
  • Joined:  01/09/12
  • Last Seen:  

ive done roughly half of it. finishing it tonight then il put it up for you to have a look.

Edit: Did the edit, did a slight boo boo with this

setarray .unit$, " month"," months", " day"," days", " hour"," hourss", " minute"," minutes", " second"," seconds";

just the hourss part.

did the rest. lemmek now if that was all that needed to be english

Edited by DarkWhoteva
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

@edit

I also fixed some bugs / problems. The message saying "your group was changed" was annoying, so it only changes group when it's really necessary. Also, when trying to read cash of a Game Master, the script forced him to become a normal player (until he logs out). Now it doesn't happen.

I still get the massage. How to fix it?

FBMqK.png

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  07/08/12
  • Last Seen:  

@Dark

Yes. The VipAdmin already has a translation, but I need to update it. I'll do it today.

@uDe

You are probably using the wrong version of VipLib. I still didn't update the topic, I'll do it today too.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

@Dark

Yes. The VipAdmin already has a translation, but I need to update it. I'll do it today.

@uDe

You are probably using the wrong version of VipLib. I still didn't update the topic, I'll do it today too.

Please update then... /pat

This script is very useful. /no1

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   2
  • Joined:  07/08/12
  • Last Seen:  

@Dark

Please, post the translation. I will update the main post with it.

I've updated VipAdmin too: http://rafaworks.zzl.org/root/scripts/accountmanager/npc/vipadmin/en.v1.2a.txt

Saturday I'll finish the new version of VipLib, then I will create a better VipAdmin. Since the old scripts are compatible to the new ones, it won't be a problem if you are already using the current version of VipLib and wanna update.

Edit:

I did not test the VipAdmin. Hope it has no bugs =X.

Edited by Rafael
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

I've updated VipAdmin too: http://rafaworks.zzl...in/en.v1.2a.txt

Can I use this VipAdmin v1.2a without VipLib v1.2b? Or I need to wait until the new VipLib release?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...