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 PlayerName, SuscribtionDate; public byte Days = 0, VIPLevel = 0; }
class VipTable { public static Dictionary<string, VipVariables> VipList = new Dictionary<string, VipVariables>(); 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.PlayerName, vip); } Reader.Close(); Reader.Dispose(); Program.WriteLine("All Vip Players Are Loaded."); }
public static void SavePlayer(Client.GameState client, byte VIPLevel, byte 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 > 0 ? 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
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
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.
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
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
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.
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 ?
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.
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.
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.
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
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.