Register for your free account! | Forgot your password?

You last visited: Today at 22:52

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



VIP Subscription System

Discussion on VIP Subscription System within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
VIP Subscription System

sm1 asked me to do that system for him so i finished it and Decided to Release it For all members in case sm1 wanted to add it too ... anyways its pretty easy to be added

This Guide Is For Beginers ..Im Sure All Expert Members dont need Explaination for these methods


Lets Start By Database
PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 
Conquer_Online_Server.Database
{
  public class 
VipVariables
  
{
    public 
string PlayerNameSuscribtionDate;
    public 
byte Days 0VIPLevel 0;
  }

  class 
VipTable
  
{
    public static 
Dictionary<stringVipVariablesVipList = new Dictionary<stringVipVariables>();
    public static 
void LoadAllVips()
    {
      
VipList.Clear();
      
MySqlCommand Cmd = new MySqlCommand(MySqlCommandType.SELECT);
      
Cmd.Select("VIP");
      
MySqlReader Reader = new MySqlReader(Cmd);
      while (
Reader.Read())
      {
        
VipVariables vip = new VipVariables();
        
vip.PlayerName Reader.ReadString("PlayerName");
        
vip.SuscribtionDate Reader.ReadString("SuscribtionDate");
        
vip.Days Reader.ReadByte("Days");
        
vip.VIPLevel Reader.ReadByte("VIPLevel");
        
VipList.Add(vip.PlayerNamevip);
       }
       
Reader.Close();
       
Reader.Dispose();
       
Program.WriteLine("All Vip Players Are Loaded.");
    }

    public static 
void SavePlayer(Client.GameState clientbyte VIPLevelbyte Days)
    {
      new 
MySqlCommand(MySqlCommandType.INSERT).Insert("VIP").Insert("PlayerName"client.Entity.Name).Insert("SuscribtionDate"DateTime.Now.ToShortTimeString()).Insert("VIPLevel"VIPLevel).Insert("Days"Days).Execute();
      
LoadAllVips();
    }

    public static 
void Delete(string PlayerName)
    {
      new 
MySqlCommand(MySqlCommandType.DELETE).Delete("VIP""PlayerName",PlayerName).Execute();
      
Program.WriteLine(PlayerName "'s Vip Suscribtion is Expired");
    }
  }

The Add that Line In GameState.cs
PHP Code:
public Database.VipVariables VIPInformation = new Database.VipVariables(); 
Add this Line in program.cs ... that line Loads All VIP values inside VIP Table when server starts
PHP Code:
Database.VipTable.LoadAllVips(); 
This Void Should Be Called When Restarting The Server in order to Decrease the Suscribtion Days by 1
PHP Code:
static void VIPDaysReduction()
{
  foreach (var 
VIPMember in Database.VipTable.VipList.Values)
  {
    
byte Days VIPMember.Days;
    new 
MySqlCommand(MySqlCommandType.UPDATE).Update("VIP").Set("Days"Days Days-- : 0).Where("PlayerName"VIPMember.PlayerName).Execute();
   }


Add this In EntityTable.cs To Check If The Player is Suscribed IN VIP .. if Days == 0 This Means that his Suscribtion is Expired So Deleting This Player From VIP Database
PHP Code:
if (Database.VipTable.VipList.ContainsKey(client.Entity.Name))
{
  
client.VIPInformation Database.VipTable.VipList[client.Entity.Name];
  if (
client.VIPInformation.Days == 0)
  {
    
client.SendMessage("Your VIP Suscribtion Has Expired"Message.TopLeft);
    
Database.VipTable.Delete(client.Entity.Name);
  }

NOTE : SendMessage is My Method of Sending Messages so Dont use Mine Or you are going to have Errors so Replace it With Yours


Add it In LoginMessages Void Inside PacketHandler.cs To Send Vip Packet to Player if he is VIP
PHP Code:
client.Entity.VIPLevel client.VIPInformation.VIPLevel;
if (
client.Entity.VIPLevel 0)
{
  
client.Send(new VIPAdvanced(true) { UID client.Entity.UID });

NOTE : You Should Handle The way of Adding Players In Database Yourself Either using Commands , Website or w.e ur way is ..thats y i didnt do the SavePlayer Method Calling

Then you are done with adding the System
Hope it helps you guyz

VIP Table in Attachment .. just Upload it to your Server Database

BTW I Dont Mind Sharing My Codes As long As you are giving me The Credits

Regards
Shadowman123
Attached Files
File Type: rar VIPDatabase.rar (467 Bytes, 73 views)
shadowman123 is offline  
Thanks
1 User
Old 09/16/2013, 22:43   #2
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,161
Just to let you know, save the entity ID instead of the name. Not only is it smaller in the database, but if the player changes name for example, other things linked to the character won't follow.
_Emme_ is offline  
Old 09/16/2013, 22:51   #3
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Quote:
Originally Posted by 'Emil View Post
Just to let you know, save the entity ID instead of the name. Not only is it smaller in the database, but if the player changes name for example, other things linked to the character won't follow.
well u r Right ... but if sm1 changed his name then the system should Change his name inside VIP Table too .. so its not a big Deal .. beside that Personally i'd like to know who Exactly is VIP by checking in Table i know that rather than getting Players UID then going to Entities but u gave good Note ...

NOTE :-
I Accept Any Constructive Critisize So Feel Free to Do that
shadowman123 is offline  
Old 09/16/2013, 23:25   #4
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Quote:
Originally Posted by Y u k i View Post
Why wouldnt you query if the player is VIP on Login? You cache the table once on startup.. why? If your server is ****** enough to require a restart every 24h nobody should waste money on buying VIP.
About Restarting Server i dont see any problem in Restarting Server .. btw Restarting a Server Doesnt mean that its ****** Or bad .. Most of Online Games do Daily Restart Servers ... if i didnt Restart my server it would consume Alot of memory .. for example i left the Application On For one week .. do u imagine how much memory will be consumed ? ..especially that each player consumes about 30 MB when Login

About Y i sent VIP Checker when player Logins .. when player login if he is VIP i should Send him VIP Packet so best Time to check if player is VIP or not is when he Logins

i didnt understand this question You cache the table once on startup.. why? could u tell me what u mean

Thx Alot for Commenting on My Cods i like Discussion
shadowman123 is offline  
Old 09/16/2013, 23:59   #5
 
elite*gold: 0
Join Date: May 2011
Posts: 648
Received Thanks: 413
Quote:
Originally Posted by shadowman123 View Post
About Restarting Server i dont see any problem in Restarting Server .. btw Restarting a Server Doesnt mean that its Shitty Or bad .. Most of Online Games do Daily Restart Servers ... if i didnt Restart my server it would consume Alot of memory .. for example i left the Application On For one week .. do u imagine how much memory will be consumed ? ..especially that each player consumes about 30 MB when Login

About Y i sent VIP Checker when player Logins .. when player login if he is VIP i should Send him VIP Packet so best Time to check if player is VIP or not is when he Logins

i didnt understand this question You cache the table once on startup.. why? could u tell me what u mean

Thx Alot for Commenting on My Cods i like Discussion
Well, About that Memory... Why would your Server not free up memory after a Client disconnects? and 30 MB per Client? There must be something going badly wrong.

I mean like doing
PHP Code:
MySqlCommand Cmd = new MySqlCommand(MySqlCommandType.SELECT);
      
Cmd.Select("VIP""PLAYERNAME OR UID"); 
everythime a Player connects, but only for that one Player. Your MySQL system looks weird to me tbh but what do i know.

I´d first asure that the server runs decently (not taking up 30mb per client - thats ridiculos) then implement more "features"

MySQL shouldnt have a problem with a few hundret to thousand queries. AND! You would save some KB on memory, because there is no need to store that information once the check completed.
Y u k i is offline  
Thanks
1 User
Old 09/17/2013, 00:32   #6
 
abdoumatrix's Avatar
 
elite*gold: 0
Join Date: Jul 2008
Posts: 874
Received Thanks: 239
Nice Job u can do better i think u was bored and busy

this is much better than the Day--

abdoumatrix is offline  
Old 09/17/2013, 00:53   #7
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Quote:
Originally Posted by Y u k i View Post
Well, About that Memory... Why would your Server not free up memory after a Client disconnects? and 30 MB per Client? There must be something going badly wrong.

I mean like doing
PHP Code:
MySqlCommand Cmd = new MySqlCommand(MySqlCommandType.SELECT);
      
Cmd.Select("VIP""PLAYERNAME OR UID"); 
everythime a Player connects, but only for that one Player. Your MySQL system looks weird to me tbh but what do i know.

I´d first asure that the server runs decently (not taking up 30mb per client - thats ridiculos) then implement more "features"

MySQL shouldnt have a problem with a few hundret to thousand queries. AND! You would save some KB on memory, because there is no need to store that information once the check completed.
i have to tell you 3 Things :-
first is thanq alot of clarifying things to me .. i didnt know that MYSQL having problem with Queries Bet Hundreds and Thousands ...

Second you are right i should load each player separately ...would be easier

Third all the recent released sources contains Two Classes which do MemoryCompress and CPU Reduction ..i already added them and player login just take about 1 MB by using this system but i saw sm1 saying that its very very bad to use smthing like that as it affects on server Efficiency badly ...so idk what to do ... and by the way i guess Inproper use of programming Types is the main reason of taking that much Size of Memory ( 30 MB or so ) ..so by replacing types with the Best Choice i can go Lower than that .. Right ?
shadowman123 is offline  
Old 09/17/2013, 02:27   #8
 
Smallxmac's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 105
Received Thanks: 13
I'm not sure how good of a way I did it, but when ever someone gets a vip subscription it adds 31 days to the current date and then save the new date in the database it then also goes on and puts a 1 in the VIP column. When the client logs it will check if VIP is = to 1 if so it will check the date to make sure it is still valid, if not it sets the date to nothing and then makes VIP 0. By doing it this way you do not have to load what you do not need.
Smallxmac is offline  
Old 09/17/2013, 02:47   #9
 
elite*gold: 0
Join Date: Mar 2006
Posts: 47
Received Thanks: 1
Where do we add the first step that you say "let's start by database"...?
vtnc2 is offline  
Old 09/17/2013, 03:07   #10
 
Smallxmac's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 105
Received Thanks: 13
I would only guess the database folder in the source make a new Code file and put that in there, I would not suggest just copying all this **** down. Learn what it is doing and understand it.
Smallxmac is offline  
Old 09/17/2013, 04:48   #11
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
After executing a mysql command does it close the connection? Seems like you're keeping the connection open.
Super Aids is offline  
Old 09/17/2013, 05:28   #12
 
Smallxmac's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 105
Received Thanks: 13
I'm not sure if I am is right or wrong but I have seen so many examples that never seem to close in that class. I think the MysqlCommand closes it after it is done so you do not have to keep calling the connection to be closed. But hey, I may be wrong lol I have not even looked at it. That just seems like the logical thing to do.
Smallxmac is offline  
Old 09/17/2013, 05:59   #13
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Quote:
Originally Posted by Super Aids View Post
After executing a mysql command does it close the connection? Seems like you're keeping the connection open.
im using Kill Connection method that FANG Released long while ago .. running in 1 sec Run Time Thread .. i know its now what should be Done .. but ill Fix that Later
shadowman123 is offline  
Old 09/17/2013, 06:11   #14
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
Why are people using such horrible wrapper that requires that? You should ALWAYS close a connection as soon as you have executed a query.
Super Aids is offline  
Old 09/17/2013, 06:54   #15
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
ill Fix that ASAP .. Thx Alot for your comments guyz .. it helped me Alot
shadowman123 is offline  
Reply


Similar Threads Similar Threads
Twitch.tv subscription
06/16/2013 - Twitch Trading - 1 Replies
Hi, da die subscribe Funktion via Paypal in Deutschland nicht funktioniert suche ich nach einem freundlichen User mit Kreditkarte der diese auf meinem twitch.tv Account durchführen könnte für den Channel twitch.tv/sivhd. Wer auch immer sich bereit erklärt soll natürlich nicht unbelohnt bleiben und kriegt das Geld+einen gewissen Aufschlag überwiesen. Kontakt: Skype: malteman3007
Best Non-subscription bot
05/27/2013 - Guild Wars 2 - 6 Replies
As the title says I'm looking for a bot that is a one time purchase and not a subscription based bot. For example: not GW2 Minion not Firy not GW2 ViperBot not gw2mimic not MacroGoblin Thank you for your suggestions
[WTS] 60 Day Subscription Card
11/14/2012 - Star Wars: The Old Republic Trading - 0 Replies
I have two for sale. I'm willing to trade for a GW2 account or 16 euros per card. Let me know if you're interested. I accept paypal.
[WTS] Retail acc (EU), still have subscription
05/05/2012 - World of Warcraft Trading - 3 Replies
>.<



All times are GMT +2. The time now is 22:52.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.