Posts: 224
Threads: 54
Joined: Mar 2011
Reputation:
2
(09-18-2012, 19:25)OzonE Wrote: Code: WebClient wc = new WebClient();
string download = wc.DownloadString("http://yourhost.com/RegisteredXUIDs.txt");
string[] downloads = download.Split(',');
OnCheckBan()
if downloads does not Contain Client.XUID
dropclient client.name
Maybe?
Thank you but i must add all xuid to txt files i want the plugin check my data base automaticaly.
In pesian:
dastet talla dadash mamnomn vali in oni nist ke man mikham intori vasam sakhte yekari kon ke be data base vasl beshe az to data base bekhob dagifan mesle hamoni ke to poste aval dadam.
mer30
Posts: 285
Threads: 15
Joined: Nov 2011
Reputation:
12
Compile this
CSHARP Code
using System; using System.Collections.Generic; using System.Linq; using System.Text; using MySql.Data; using MySql.Data.MySqlClient; using System.Windows.Forms; using Addon; namespace duhhh { public class Class1 : CPlugin { MySqlConnection connection; List <int> connected = new List <int>(); public override void OnPlayerSpawned(ServerClient Client) { foreach (int i in connected) { if (GetClient(i).ClientNum == Client.ClientNum) { ServerSay("Welcome " + Client.Name + " from website!", true); connected.Remove(Client.ClientNum); } } base.OnPlayerSpawned(Client); } public override void OnServerLoad() { connection = new MySqlConnection (string. Format("SERVER={0};DATABASE={1};UID={2};PASSWORD={3};", GetServerCFG ("XUID Welcome", "SERVER", string. Empty), GetServerCFG ("XUID Welcome", "DB", string. Empty), GetServerCFG ("XUID Welcome", "USER", string. Empty), GetServerCFG ("XUID Welcome", "PASSWORD", string. Empty))); connection.Open(); ServerPrint("MySQL welcome by archit loaded!"); base.OnServerLoad(); } public override void OnPlayerConnect(ServerClient Client) { MySqlCommand command = connection.CreateCommand(); MySqlDataReader Reader; command.CommandText = string.Format("select * from {0} WHERE {1} = '{2}'", GetServerCFG("XUID Welcome", "table", string.Empty), GetServerCFG("XUID Welcome", "xuid tab", string.Empty), Client.XUID); Reader = command.ExecuteReader(); string thisrow = ""; while (Reader.Read()) { for (int i = 0; i < Reader.FieldCount; i++) thisrow += Reader.GetValue(i).ToString(); } if (!string.IsNullOrEmpty(thisrow)) { connected.Add(Client.ClientNum); } Reader.Close(); base.OnPlayerConnect(Client); } } }
Add this to sv_config.ini
Code: [XUID Welcome]
SERVER=localhost
//server of mysql
DB=b3_mw3
//databse name
USER=test1
//user
PASSWORD=test1
//password
table=clients
//table containing xuid
xuid tab=guid
//the whatever it is called containing xuids
Posts: 224
Threads: 54
Joined: Mar 2011
Reputation:
2
09-19-2012, 18:15
(This post was last modified: 09-19-2012, 19:40 by raminr63.)
Thank you very much.
in compile i have this error:
Error 1 'duhhh.Class1.OnPlayerSpawned(Addon.ServerClient)': no suitable method found to override C:\Visual Studio 2008\Projects\register\register\Class1.cs 16 30 register
by using last version its solved
Posts: 224
Threads: 54
Joined: Mar 2011
Reputation:
2
09-19-2012, 19:15
(This post was last modified: 09-19-2012, 19:40 by raminr63.)
Thanks
and is it possible to add a code for:
when player xuid not matched or not exist in data base them the player kicked and after kicked this message shown to him:
message : your xuid not exist in our database pleas register in my-site then save your xuid -- "playexuid" -- in your profile.
as you know in mw3 its not easy for everyone to find his XUID so after the player kicked if the xuid showed to him in message then players can save his XUID with easy way .
thank you.
Posts: 285
Threads: 15
Joined: Nov 2011
Reputation:
12
09-20-2012, 04:41
(This post was last modified: 09-20-2012, 04:51 by archit.)
Done
CHSARP Code
using System; using System.Collections.Generic; using MySql.Data.MySqlClient; using Addon; namespace duhhh { public class Class1 : CPlugin { MySqlConnection connection; List<string> connected = new List<string>(); public override void OnPlayerSpawned(ServerClient Client) { foreach (string XUID in connected) { if (XUID == Client.XUID) { ServerSay("Welcome " + Client.Name + " from website!", true); connected.Remove(XUID); } } base.OnPlayerSpawned(Client); } public override void OnServerLoad() { connection = new MySqlConnection(string.Format("SERVER={0};DATABASE={1};UID={2};PASSWORD={3};", GetServerCFG("XUID Welcome", "SERVER", string.Empty), GetServerCFG("XUID Welcome", "DB", string.Empty), GetServerCFG("XUID Welcome", "USER", string.Empty), GetServerCFG("XUID Welcome", "PASSWORD", string.Empty))); connection.Open(); ServerPrint("MySQL welcome by archit loaded!"); base.OnServerLoad(); } public override string OnCheckBan(string XUID) { MySqlCommand command = connection.CreateCommand(); MySqlDataReader Reader; command.CommandText = string.Format("select * from {0} WHERE {1} = '{2}'", GetServerCFG("XUID Welcome", "table", string.Empty), GetServerCFG("XUID Welcome", "xuid tab", string.Empty), XUID); Reader = command.ExecuteReader(); string thisrow = ""; while (Reader.Read()) { for (int i = 0; i < Reader.FieldCount; i++) thisrow += Reader.GetValue(i).ToString(); } Reader.Close(); if (!string.IsNullOrEmpty(thisrow)) { connected.Add(XUID); return base.OnCheckBan(XUID); } else { if (GetServerCFG("XUID Welcome", "kick message", null) != null) return GetServerCFG("XUID Welcome", "kick message", null) + " " + XUID; else return null; } } } }
UNTESTED and also add this to sv_config section of XUID Welcome
Code: kick message = add xuid to website
//change this message according to what you want XUID will be included at end
Posts: 224
Threads: 54
Joined: Mar 2011
Reputation:
2
Thank you your plugin is work perfectly .
|