11using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
42using I18N . West ;
53using MySql . Data . MySqlClient ;
6-
74using Rocket . Core . Logging ;
85using Steamworks ;
9- using System . Text ;
10- using System . Threading . Tasks ;
116
127namespace ZaupLeaderboard
138{
@@ -22,7 +17,7 @@ internal void CheckSchema()
2217 {
2318 try
2419 {
25- MySqlConnection mySqlConnection = this . createConnection ( ) ;
20+ MySqlConnection mySqlConnection = this . CreateConnection ( ) ;
2621 MySqlCommand mySqlCommand = mySqlConnection . CreateCommand ( ) ;
2722 mySqlCommand . CommandText = "show tables like '"
2823 + ZaupLeaderboard . Instance . Configuration . Instance . DatabaseTableName + "'" ;
@@ -80,7 +75,7 @@ internal void CheckSchema()
8075 Logger . LogException ( ex ) ;
8176 }
8277 }
83- private MySqlConnection createConnection ( )
78+ private MySqlConnection CreateConnection ( )
8479 {
8580 MySqlConnection result = null ;
8681 try
@@ -104,11 +99,11 @@ private MySqlConnection createConnection()
10499 }
105100 return result ;
106101 }
107- public byte onPlayerConnected ( CSteamID id , string name )
102+ public byte OnPlayerConnected ( CSteamID id , string name )
108103 {
109104 try
110105 {
111- MySqlConnection mySqlConnection = this . createConnection ( ) ;
106+ MySqlConnection mySqlConnection = this . CreateConnection ( ) ;
112107 MySqlCommand mySqlCommand = mySqlConnection . CreateCommand ( ) ;
113108 mySqlCommand . CommandText = "insert into `"
114109 + ZaupLeaderboard . Instance . Configuration . Instance . DatabaseTableName
@@ -127,11 +122,105 @@ public byte onPlayerConnected(CSteamID id, string name)
127122 return 0 ;
128123 }
129124 }
125+
126+ public int GetPlayerKills ( string id )
127+ {
128+ int result = 0 ;
129+ try
130+ {
131+ MySqlConnection mySqlConnection = this . CreateConnection ( ) ;
132+ MySqlCommand mySqlCommand = mySqlConnection . CreateCommand ( ) ;
133+ string databaseTableName = ZaupLeaderboard . Instance . Configuration . Instance . DatabaseTableName ;
134+ mySqlCommand . CommandText = string . Concat ( new string [ ]
135+ {
136+ "select `playerkills` from `" ,
137+ databaseTableName ,
138+ "` where `steamId` = '" ,
139+ id ,
140+ "'"
141+ } ) ;
142+ mySqlConnection . Open ( ) ;
143+ object obj = mySqlCommand . ExecuteScalar ( ) ;
144+ if ( obj != null )
145+ {
146+ int . TryParse ( obj . ToString ( ) , out result ) ;
147+ }
148+ mySqlConnection . Close ( ) ;
149+ }
150+ catch ( Exception ex )
151+ {
152+ Logger . LogException ( ex , null ) ;
153+ }
154+ return result ;
155+ }
156+
157+ public int GetZombieKills ( string id )
158+ {
159+ int result = 0 ;
160+ try
161+ {
162+ MySqlConnection mySqlConnection = this . CreateConnection ( ) ;
163+ MySqlCommand mySqlCommand = mySqlConnection . CreateCommand ( ) ;
164+ string databaseTableName = ZaupLeaderboard . Instance . Configuration . Instance . DatabaseTableName ;
165+ mySqlCommand . CommandText = string . Concat ( new string [ ]
166+ {
167+ "select `zombiekills` from `" ,
168+ databaseTableName ,
169+ "` where `steamId` = '" ,
170+ id ,
171+ "'"
172+ } ) ;
173+ mySqlConnection . Open ( ) ;
174+ object obj = mySqlCommand . ExecuteScalar ( ) ;
175+ if ( obj != null )
176+ {
177+ int . TryParse ( obj . ToString ( ) , out result ) ;
178+ }
179+ mySqlConnection . Close ( ) ;
180+ }
181+ catch ( Exception ex )
182+ {
183+ Logger . LogException ( ex , null ) ;
184+ }
185+ return result ;
186+ }
187+
188+ public int GetZombieMegaKills ( string id )
189+ {
190+ int result = 0 ;
191+ try
192+ {
193+ MySqlConnection mySqlConnection = this . CreateConnection ( ) ;
194+ MySqlCommand mySqlCommand = mySqlConnection . CreateCommand ( ) ;
195+ string databaseTableName = ZaupLeaderboard . Instance . Configuration . Instance . DatabaseTableName ;
196+ mySqlCommand . CommandText = string . Concat ( new string [ ]
197+ {
198+ "select `zombiekillsmega` from `" ,
199+ databaseTableName ,
200+ "` where `steamId` = '" ,
201+ id ,
202+ "'"
203+ } ) ;
204+ mySqlConnection . Open ( ) ;
205+ object obj = mySqlCommand . ExecuteScalar ( ) ;
206+ if ( obj != null )
207+ {
208+ int . TryParse ( obj . ToString ( ) , out result ) ;
209+ }
210+ mySqlConnection . Close ( ) ;
211+ }
212+ catch ( Exception ex )
213+ {
214+ Logger . LogException ( ex , null ) ;
215+ }
216+ return result ;
217+ }
218+
130219 public byte UpdateTable ( CSteamID id , string sql )
131220 {
132221 try
133222 {
134- MySqlConnection mySqlConnection = this . createConnection ( ) ;
223+ MySqlConnection mySqlConnection = this . CreateConnection ( ) ;
135224 MySqlCommand mySqlCommand = mySqlConnection . CreateCommand ( ) ;
136225 mySqlCommand . CommandText = sql ;
137226 mySqlConnection . Open ( ) ;
@@ -149,7 +238,7 @@ public uint GetPvpStreak(CSteamID id)
149238 {
150239 try
151240 {
152- MySqlConnection mySqlConnection = this . createConnection ( ) ;
241+ MySqlConnection mySqlConnection = this . CreateConnection ( ) ;
153242 MySqlCommand mySqlCommand = mySqlConnection . CreateCommand ( ) ;
154243 mySqlCommand . CommandText = "select `toppvpstreak` from `"
155244 + ZaupLeaderboard . Instance . Configuration . Instance . DatabaseTableName
0 commit comments