· 8 years ago · Oct 07, 2017, 10:12 AM
1#include <amxmodx>
2#include <cstrike>
3#include <colorchat>
4#include <fun>
5#include <fakemeta>
6#include <hamsandwich>
7
8//#define USE_SQL
9
10#if defined USE_SQL
11#include <sqlx>
12#include <geoip>
13#endif
14
15#define KZ_LEVEL ADMIN_KICK
16#define MSG MSG_ONE_UNRELIABLE
17#define MAX_ENTITYS 900+15*32
18#define IsOnLadder(%1) (pev(%1, pev_movetype) == MOVETYPE_FLY)
19#define VERSION "2.31"
20
21#define SCOREATTRIB_NONE 0
22#define SCOREATTRIB_DEAD ( 1 << 0 )
23#define SCOREATTRIB_BOMB ( 1 << 1 )
24#define SCOREATTRIB_VIP ( 1 << 2 )
25
26new const FL_ONGROUND2 = ( FL_ONGROUND | FL_PARTIALGROUND | FL_INWATER | FL_CONVEYOR | FL_FLOAT )
27new const KZ_STARTFILE[] = "start.ini"
28new const KZ_STARTFILE_TEMP[] = "temp_start.ini"
29
30#if defined USE_SQL
31new Handle:g_SqlTuple
32new Handle:SqlConnection
33new g_Error[512]
34new kz_sql_host
35new kz_sql_user
36new kz_sql_pass
37new kz_sql_db
38new kz_sql_name
39new kz_sql_files
40#else
41new Float:Pro_Times[24]
42new Pro_AuthIDS[24][32]
43new Pro_Names[24][32]
44new Pro_Date[24][32]
45new Float:Noob_Tiempos[24]
46new Noob_AuthIDS[24][32]
47new Noob_Names[24][32]
48new Noob_Date[24][32]
49new Noob_CheckPoints[24]
50new Noob_GoChecks[24]
51new Noob_Weapon[24][32]
52#endif
53
54new Float:Checkpoints[33][2][3]
55new Float:timer_time[33]
56new Float:g_pausetime[33]
57new Float:antihookcheat[33]
58new Float:SpecLoc[33][3]
59new Float:NoclipPos[33][3]
60new Float:PauseOrigin[33][3]
61new Float:SavedStart[33][3]
62new hookorigin[33][3]
63new Float:DefaultStartPos[3]
64
65new Float:SavedTime[33]
66new SavedChecks[33]
67new SavedGoChecks[33]
68new SavedScout[33]
69new SavedOrigins[33][3]
70
71new bool:g_bCpAlternate[33]
72new bool:timer_started[33]
73new bool:IsPaused[33]
74new bool:WasPaused[33]
75new bool:firstspawn[33]
76new bool:canusehook[33]
77new bool:ishooked[33]
78new bool:user_has_scout[33]
79new bool:NightVisionUse[33]
80new bool:HealsOnMap
81new bool:gWaterEntity[MAX_ENTITYS]
82new bool:gWaterFound
83new bool:DefaultStart
84new bool:AutoStart[33]
85
86new Trie:g_tStarts
87new Trie:g_tStops;
88
89new checknumbers[33]
90new gochecknumbers[33]
91new chatorhud[33]
92new ShowTime[33]
93new MapName[64]
94new Kzdir[128]
95new SavePosDir[128]
96new prefix[33]
97#if !defined USE_SQL
98new Topdir[128]
99#endif
100
101new kz_checkpoints
102new kz_cheatdetect
103new kz_spawn_mainmenu
104new kz_show_timer
105new kz_chatorhud
106new kz_hud_color
107new kz_chat_prefix
108new hud_message
109new kz_other_weapons
110new kz_maxspeedmsg
111new kz_drop_weapons
112new kz_remove_drops
113new kz_pick_weapons
114new kz_reload_weapons
115new kz_use_radio
116new kz_hook_prize
117new kz_hook_sound
118new kz_hook_speed
119new kz_pause
120new kz_noclip_pause
121new kz_nvg
122new kz_nvg_colors
123new kz_vip
124new kz_respawn_ct
125new kz_save_pos
126new kz_save_pos_gochecks
127new kz_spec_saves
128new kz_save_autostart
129new kz_top15_authid
130new Sbeam = 0
131
132new const other_weapons[8] =
133{
134 CSW_SCOUT, CSW_P90, CSW_FAMAS, CSW_SG552,
135 CSW_M4A1, CSW_M249, CSW_AK47, CSW_AWP
136}
137
138new const other_weapons_name[8][] =
139{
140 "weapon_scout", "weapon_p90", "weapon_famas", "weapon_sg552",
141 "weapon_m4a1", "weapon_m249", "weapon_ak47", "weapon_awp"
142}
143
144new const g_weaponsnames[][] =
145{
146 "", // NULL
147 "p228", "shield", "scout", "hegrenade", "xm1014", "c4",
148 "mac10", "aug", "smokegrenade", "elite", "fiveseven",
149 "ump45", "sg550", "galil", "famas", "usp", "glock18",
150 "awp", "mp5navy", "m249", "m3", "m4a1", "tmp", "g3sg1",
151 "flashbang", "deagle", "sg552", "ak47", "knife", "p90",
152 "glock", "elites", "fn57", "mp5", "vest", "vesthelm",
153 "flash", "hegren", "sgren", "defuser", "nvgs", "primammo",
154 "secammo", "km45", "9x19mm", "nighthawk", "228compact",
155 "12gauge", "autoshotgun", "mp", "c90", "cv47", "defender",
156 "clarion", "krieg552", "bullpup", "magnum", "d3au1",
157 "krieg550"
158}
159
160new const g_block_commands[][]=
161{
162 "buy", "buyammo1", "buyammo2", "buyequip",
163 "cl_autobuy", "cl_rebuy", "cl_setautobuy", "cl_setrebuy"
164
165}
166
167#if defined USE_SQL
168enum
169{
170 TOP_NULL,
171 PRO_TOP,
172 NUB_TOP,
173 LAST_PRO10,
174 PRO_RECORDS,
175 PLAYERS_RANKING,
176 MAPS_STATISTIC
177}
178#endif
179
180// =================================================================================================
181
182public plugin_init()
183{
184 register_plugin("ProKreedz", VERSION, "nucLeaR & p4ddY")
185
186 kz_checkpoints = register_cvar("kz_checkpoints","1")
187 kz_cheatdetect = register_cvar("kz_cheatdetect","1")
188 kz_spawn_mainmenu = register_cvar("kz_spawn_mainmenu", "1")
189 kz_show_timer = register_cvar("kz_show_timer", "1")
190 kz_chatorhud = register_cvar("kz_chatorhud", "2")
191 kz_chat_prefix = register_cvar("kz_chat_prefix", "[KreedZ]")
192 kz_hud_color = register_cvar("kz_hud_color", "12 122 221")
193 kz_other_weapons = register_cvar("kz_other_weapons","1")
194 kz_drop_weapons = register_cvar("kz_drop_weapons", "0")
195 kz_remove_drops = register_cvar("kz_remove_drops", "1")
196 kz_pick_weapons = register_cvar("kz_pick_weapons", "0")
197 kz_reload_weapons = register_cvar("kz_reload_weapons", "0")
198 kz_maxspeedmsg = register_cvar("kz_maxspeedmsg","1")
199 kz_hook_prize = register_cvar("kz_hook_prize","1")
200 kz_hook_sound = register_cvar("kz_hook_sound","1")
201 kz_hook_speed = register_cvar("kz_hook_speed", "300.0")
202 kz_use_radio = register_cvar("kz_use_radio", "0")
203 kz_pause = register_cvar("kz_pause", "1")
204 kz_noclip_pause = register_cvar("kz_noclip_pause", "1")
205 kz_nvg = register_cvar("kz_nvg","1")
206 kz_nvg_colors = register_cvar("kz_nvg_colors","5 0 255")
207 kz_vip = register_cvar("kz_vip","1")
208 kz_respawn_ct = register_cvar("kz_respawn_ct", "1")
209 kz_spec_saves = register_cvar("kz_spec_saves", "1")
210 kz_save_autostart = register_cvar("kz_save_autostart", "1")
211 kz_top15_authid = register_cvar("kz_top15_authid", "1")
212 kz_save_pos = register_cvar("kz_save_pos", "1")
213 kz_save_pos_gochecks = register_cvar("kz_save_pos_gochecks", "1")
214
215 #if defined USE_SQL
216 kz_sql_host = register_cvar("kz_sql_host", "") // Host of DB
217 kz_sql_user = register_cvar("kz_sql_user", "") // Username of DB
218 kz_sql_pass = register_cvar("kz_sql_pass", "", FCVAR_PROTECTED) // Password for DB user
219 kz_sql_db = register_cvar("kz_sql_db", "") // DB Name for the top 15
220 kz_sql_name = register_cvar("kz_sql_server", "") // Name of server
221 kz_sql_files = register_cvar("kz_sql_files", "") // Path of the PHP files
222 #endif
223
224 register_clcmd("/cp","CheckPoint")
225 register_clcmd("drop", "BlockDrop")
226 register_clcmd("/gc", "GoCheck")
227 register_clcmd("+hook","hook_on",KZ_LEVEL)
228 register_clcmd("-hook","hook_off",KZ_LEVEL)
229 register_concmd("kz_hook","give_hook", KZ_LEVEL, "<name|#userid|steamid|@ALL> <on/off>")
230 register_concmd("nightvision","ToggleNVG")
231 register_clcmd("radio1", "BlockRadio")
232 register_clcmd("radio2", "BlockRadio")
233 register_clcmd("radio3", "BlockRadio")
234 register_clcmd("/tp","GoCheck")
235
236 kz_register_saycmd("cp","CheckPoint",0)
237 kz_register_saycmd("chatorhud", "ChatHud", 0)
238 kz_register_saycmd("ct","ct",0)
239 kz_register_saycmd("gc", "GoCheck",0)
240 kz_register_saycmd("gocheck", "GoCheck",0)
241 kz_register_saycmd("god", "GodMode",0)
242 kz_register_saycmd("godmode", "GodMode", 0)
243 kz_register_saycmd("kz", "kz_menu", 0)
244 kz_register_saycmd("menu","kz_menu", 0)
245 kz_register_saycmd("nc", "noclip", 0)
246 kz_register_saycmd("noclip", "noclip", 0)
247 kz_register_saycmd("noob10", "NoobTop_show", 0)
248 kz_register_saycmd("noob15", "NoobTop_show", 0)
249 kz_register_saycmd("nub10", "NoobTop_show", 0)
250 kz_register_saycmd("nub15", "NoobTop_show", 0)
251 kz_register_saycmd("pause", "Pause", 0)
252 kz_register_saycmd("pro10", "ProTop_show", 0)
253 kz_register_saycmd("pro15", "ProTop_show", 0)
254 kz_register_saycmd("reset", "reset_checkpoints", 0)
255 kz_register_saycmd("respawn", "goStart", 0)
256 kz_register_saycmd("savepos", "SavePos", 0)
257 kz_register_saycmd("scout", "cmdScout", 0)
258 kz_register_saycmd("setstart", "setStart", KZ_LEVEL)
259 kz_register_saycmd("showtimer", "ShowTimer_Menu", 0)
260 kz_register_saycmd("spec", "ct", 0)
261 kz_register_saycmd("start", "goStart", 0)
262 kz_register_saycmd("stuck", "Stuck", 0)
263 kz_register_saycmd("teleport", "GoCheck", 0)
264 kz_register_saycmd("timer", "ShowTimer_Menu", 0)
265 kz_register_saycmd("top15", "top15menu",0)
266 kz_register_saycmd("top10", "top15menu",0)
267 kz_register_saycmd("tp", "GoCheck",0)
268 kz_register_saycmd("usp", "cmdUsp", 0)
269 kz_register_saycmd("weapons", "weapons", 0)
270 kz_register_saycmd("guns", "weapons", 0)
271
272 #if defined USE_SQL
273 kz_register_saycmd("prorecords", "ProRecs_show", 0)
274 kz_register_saycmd("prorecs", "ProRecs_show", 0)
275 #endif
276
277 register_event("CurWeapon", "curweapon", "be", "1=1")
278 register_event( "StatusValue", "EventStatusValue", "b", "1>0", "2>0" );
279 RegisterHam( Ham_Use, "func_button", "fwdUse", 0)
280 RegisterHam( Ham_Killed, "player", "Ham_CBasePlayer_Killed_Post", 1)
281 RegisterHam( Ham_Touch, "weaponbox", "FwdSpawnWeaponbox" )
282 RegisterHam( Ham_Spawn, "player", "FwdHamPlayerSpawn", 1 )
283 RegisterHam( Ham_Touch, "weaponbox", "GroundWeapon_Touch")
284
285 register_message( get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib" )
286 register_dictionary("prokreedz.txt")
287 get_pcvar_string(kz_chat_prefix, prefix, 31)
288 get_mapname(MapName, 63)
289 set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
290 set_task(0.5,"timer_task",2000,"",0,"ab")
291 #if defined USE_SQL
292 set_task(0.2, "plugin_sql")
293 #endif
294
295 new kreedz_cfg[128], ConfigDir[64]
296 get_configsdir( ConfigDir, 64)
297 formatex(Kzdir,128, "%s/kz", ConfigDir)
298 if( !dir_exists(Kzdir) )
299 mkdir(Kzdir)
300
301 #if !defined USE_SQL
302 formatex(Topdir,128, "%s/top15", Kzdir)
303 if( !dir_exists(Topdir) )
304 mkdir(Topdir)
305 #endif
306
307 formatex(SavePosDir, 128, "%s/savepos", Kzdir)
308 if( !dir_exists(SavePosDir) )
309 mkdir(SavePosDir)
310
311 formatex(kreedz_cfg,128,"%s/kreedz.cfg", Kzdir)
312
313 if( file_exists( kreedz_cfg ) )
314 {
315 server_exec()
316 server_cmd("exec %s",kreedz_cfg)
317 }
318
319 for(new i = 0; i < sizeof(g_block_commands) ; i++)
320 register_clcmd(g_block_commands[i], "BlockBuy")
321
322 g_tStarts = TrieCreate( )
323 g_tStops = TrieCreate( )
324
325 new const szStarts[ ][ ] =
326 {
327 "counter_start", "clockstartbutton", "firsttimerelay", "but_start", "counter_start_button",
328 "multi_start", "timer_startbutton", "start_timer_emi", "gogogo"
329 }
330
331 new const szStops[ ][ ] =
332 {
333 "counter_off", "clockstopbutton", "clockstop", "but_stop", "counter_stop_button",
334 "multi_stop", "stop_counter", "m_counter_end_emi"
335 }
336
337 for( new i = 0; i < sizeof szStarts; i++ )
338 TrieSetCell( g_tStarts, szStarts[ i ], 1 )
339
340 for( new i = 0; i < sizeof szStops; i++ )
341 TrieSetCell( g_tStops, szStops[ i ], 1 )
342}
343
344#if defined USE_SQL
345public plugin_sql()
346{
347 new host[64], user[64], pass[64], db[64]
348
349 get_pcvar_string(kz_sql_host, host, 63)
350 get_pcvar_string(kz_sql_user, user, 63)
351 get_pcvar_string(kz_sql_pass, pass, 63)
352 get_pcvar_string(kz_sql_db, db, 63)
353
354 g_SqlTuple = SQL_MakeDbTuple(host, user, pass, db)
355
356 new ErrorCode
357 SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
358
359 if(!SqlConnection)
360 {
361 server_print("[KZ] TOP15 SQL: Could not connect to SQL database.!")
362 log_amx("[KZ] TOP15 SQL: Could not connect to SQL database.")
363 return pause("a")
364 }
365
366 new createinto[1001]
367 formatex(createinto, 1000, "CREATE TABLE IF NOT EXISTS `kz_pro15` (`mapname` varchar(64) NOT NULL, `authid` varchar(64) NOT NULL, `country` varchar(6) NOT NULL, `name` varchar(64) NOT NULL, `time` decimal(65,2) NOT NULL, `date` datetime NOT NULL, `weapon` varchar(64) NOT NULL, `server` varchar(64) NOT NULL)")
368 SQL_ThreadQuery(g_SqlTuple,"QueryHandle", createinto)
369 formatex(createinto, 1000, "CREATE TABLE IF NOT EXISTS `kz_nub15` (`mapname` varchar(64) NOT NULL, `authid` varchar(64) NOT NULL, `country` varchar(6) NOT NULL, `name` varchar(64) NOT NULL, `time`decimal(65,2) NOT NULL, `date` datetime NOT NULL, `weapon` varchar(64) NOT NULL, `server` varchar(64) NOT NULL, `checkpoints` real NOT NULL, `gocheck` real NOT NULL)")
370 SQL_ThreadQuery(g_SqlTuple,"QueryHandle", createinto)
371
372 return PLUGIN_CONTINUE
373}
374
375public QueryHandle(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
376{
377 if( iFailState != TQUERY_SUCCESS )
378 {
379 log_amx("[KZ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
380 ColorChat(0, GREEN, "[KZ]^x01: Warning the SQL Tops can not be saved.")
381 }
382
383 server_print("[KZ] Server Sending Info to SQL Server")
384
385 return PLUGIN_CONTINUE
386}
387#endif
388
389public plugin_precache()
390{
391 hud_message = CreateHudSyncObj()
392 RegisterHam( Ham_Spawn, "func_door", "FwdHamDoorSpawn", 1 )
393 precache_sound("weapons/xbow_hit2.wav")
394 Sbeam = precache_model("sprites/laserbeam.spr")
395}
396
397public plugin_cfg()
398{
399 #if !defined USE_SQL
400 for (new i = 0 ; i < 15; ++i)
401 {
402 Pro_Times[i] = 999999999.00000;
403 Noob_Tiempos[i] = 999999999.00000;
404 }
405
406 read_pro15()
407 read_Noob15()
408 #endif
409
410 new startcheck[100], data[256], map[64], x[13], y[13], z[13];
411 formatex(startcheck, 99, "%s/%s", Kzdir, KZ_STARTFILE)
412 new f = fopen(startcheck, "rt" )
413 while( !feof( f ) )
414 {
415 fgets( f, data, sizeof data - 1 )
416 parse( data, map, 63, x, 12, y, 12, z, 12)
417
418 if( equali( map, MapName ) )
419 {
420 DefaultStartPos[0] = str_to_float(x)
421 DefaultStartPos[1] = str_to_float(y)
422 DefaultStartPos[2] = str_to_float(z)
423
424 DefaultStart = true
425 break;
426 }
427 }
428 fclose(f)
429
430 new ent = -1;
431 while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_water") ) != 0 )
432 {
433 if( !gWaterFound )
434 {
435 gWaterFound = true;
436 }
437
438 gWaterEntity[ent] = true;
439 }
440
441 ent = -1;
442 while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_illusionary") ) != 0 )
443 {
444 if( pev( ent, pev_skin ) == CONTENTS_WATER )
445 {
446 if( !gWaterFound )
447 {
448 gWaterFound = true;
449 }
450
451 gWaterEntity[ent] = true;
452 }
453 }
454
455 ent = -1;
456 while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_conveyor") ) != 0 )
457 {
458 if( pev( ent, pev_spawnflags ) == 3 )
459 {
460 if( !gWaterFound )
461 {
462 gWaterFound = true;
463 }
464
465 gWaterEntity[ent] = true;
466 }
467 }
468}
469
470public client_command(id)
471{
472
473 new sArg[13];
474 if( read_argv(0, sArg, 12) > 11 )
475 {
476 return PLUGIN_CONTINUE;
477 }
478
479 for( new i = 0; i < sizeof(g_weaponsnames); i++ )
480 {
481 if( equali(g_weaponsnames[i], sArg, 0) )
482 {
483 return PLUGIN_HANDLED;
484 }
485 }
486 return PLUGIN_CONTINUE;
487}
488
489// =================================================================================================
490// Global Functions
491// =================================================================================================
492
493public Pause(id)
494{
495 if(!(pev(id, pev_flags) & FL_ONGROUND2) && !IsOnLadder(id))
496 {
497 client_print(id, print_center, "This command is not available to you at this point")
498 return PLUGIN_HANDLED
499 }
500 if (get_pcvar_num(kz_pause) == 0)
501 {
502 kz_chat(id, "%L", id, "KZ_PAUSE_DISABLED")
503
504 return PLUGIN_HANDLED
505 }
506
507 if(! is_user_alive(id) )
508 {
509 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
510
511 return PLUGIN_HANDLED
512 }
513
514
515 if(!IsPaused[id])
516 {
517 if(! timer_started[id])
518 {
519 kz_chat(id, "%L", id, "KZ_TIMER_NOT_STARTED")
520 return PLUGIN_HANDLED
521 }
522
523 g_pausetime[id] = get_gametime() - timer_time[id]
524 timer_time[id] = 0.0
525 IsPaused[id] = true
526 kz_chat(id, "%L", id, "KZ_PAUSE_ON")
527 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
528 pev(id, pev_origin, PauseOrigin[id])
529
530 }
531 else
532 {
533 if(timer_started[id])
534 {
535 kz_chat(id, "%L", id, "KZ_PAUSE_OFF")
536 if(get_user_noclip(id))
537 noclip(id)
538 timer_time[id] = get_gametime() - g_pausetime[id]
539 }
540 IsPaused[id] = false
541 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
542 }
543
544 return PLUGIN_HANDLED
545}
546
547public timer_task()
548{
549 if ( get_pcvar_num(kz_show_timer) > 0 )
550 {
551 new Alive[32], Dead[32], alivePlayers, deadPlayers;
552 get_players(Alive, alivePlayers, "ach")
553 get_players(Dead, deadPlayers, "bch")
554 for(new i=0;i<alivePlayers;i++)
555 {
556 if( timer_started[Alive[i]])
557 {
558 new Float:kreedztime = get_gametime() - (IsPaused[Alive[i]] ? get_gametime() - g_pausetime[Alive[i]] : timer_time[Alive[i]])
559
560 if( ShowTime[Alive[i]] == 1 )
561 {
562 new colors[12], r[4], g[4], b[4];
563 new imin = floatround(kreedztime / 60.0,floatround_floor)
564 new isec = floatround(kreedztime - imin * 60.0,floatround_floor)
565 get_pcvar_string(kz_hud_color, colors, 11)
566 parse(colors, r, 3, g, 3, b, 4)
567
568 set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), 0.40, 0.10, 0, 0.0, 1.0, 0.0, 0.0, 1)
569 show_hudmessage(Alive[i], "Time: %02d:%02d | CPs: %d | TPs: %d %s ",imin, isec,checknumbers[Alive[i]], gochecknumbers[Alive[i]], IsPaused[Alive[i]] ? "| *Paused*" : "")
570 }
571 else
572 if( ShowTime[Alive[i]] == 2 )
573 {
574 kz_showtime_roundtime(Alive[i], floatround(kreedztime))
575 }
576 }
577
578 }
579 for(new i=0;i<deadPlayers;i++)
580 {
581 new specmode = pev(Dead[i], pev_iuser1)
582 if(specmode == 2 || specmode == 4)
583 {
584 new target = pev(Dead[i], pev_iuser2)
585 if(target != Dead[i])
586 if(is_user_alive(target) && timer_started[target])
587 {
588 new name[32], colors[12], r[4], g[4], b[4];
589 get_user_name (target, name, 31)
590
591 new Float:kreedztime = get_gametime() - (IsPaused[target] ? get_gametime() - g_pausetime[target] : timer_time[target])
592 new imin = floatround(kreedztime / 60.0,floatround_floor)
593 new isec = floatround(kreedztime - imin * 60.0,floatround_floor)
594
595 get_pcvar_string(kz_hud_color, colors, 11)
596 parse(colors, r, 3, g, 3, b, 4)
597
598 set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), 0.27, 0.17, 0, 0.0, 1.0, 0.0, 0.0, 1)
599 show_hudmessage(Dead[i], "Time: %02d:%02d | CPs: %d | TPs: %d %s ",imin, isec, checknumbers[target], gochecknumbers[target], IsPaused[target] ? "| *Paused*" : "")
600 }
601 }
602 }
603 }
604}
605
606// ============================ Block Commands ================================
607
608
609public BlockRadio(id)
610{
611 if (get_pcvar_num(kz_use_radio) == 1)
612 return PLUGIN_CONTINUE
613 return PLUGIN_HANDLED
614}
615
616public BlockDrop(id)
617{
618 if (get_pcvar_num(kz_drop_weapons) == 1)
619 return PLUGIN_CONTINUE
620 return PLUGIN_HANDLED
621}
622
623public BlockBuy(id)
624{
625 return PLUGIN_HANDLED
626}
627
628public CmdRespawn(id)
629{
630 if ( get_user_team(id) == 3 )
631 return PLUGIN_HANDLED
632 else
633 ExecuteHamB(Ham_CS_RoundRespawn, id)
634
635 return PLUGIN_HANDLED
636}
637
638public ChatHud(id)
639{
640 if(get_pcvar_num(kz_chatorhud) == 0)
641 {
642 ColorChat(id, GREEN, "%s^x01 %L", id, "KZ_CHECKPOINT_OFF", prefix)
643 return PLUGIN_HANDLED
644 }
645 if(chatorhud[id] == -1)
646 ++chatorhud[id];
647
648 ++chatorhud[id];
649
650 if(chatorhud[id] == 3)
651 chatorhud[id] = 0;
652 else
653 kz_chat(id, "%L", id, "KZ_CHATORHUD", chatorhud[id] == 1 ? "Chat" : "HUD")
654
655 return PLUGIN_HANDLED
656}
657
658public ct(id)
659{
660 new CsTeams:team = cs_get_user_team(id)
661 if (team == CS_TEAM_CT)
662 {
663 if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) && timer_started[id] )
664 return PLUGIN_HANDLED
665
666 if (get_pcvar_num(kz_spec_saves) == 1)
667 {
668 pev(id, pev_origin, SpecLoc[id])
669
670 if ( timer_started[id] )
671 {
672 if ( IsPaused[id] )
673 {
674 Pause(id)
675 WasPaused[id]=true
676 }
677
678 g_pausetime[id] = get_gametime() - timer_time[id]
679 timer_time[id] = 0.0
680 kz_chat(id, "%L", id, "KZ_PAUSE_ON")
681 }
682 }
683
684 cs_set_user_team(id,CS_TEAM_SPECTATOR)
685 set_pev(id, pev_solid, SOLID_NOT)
686 set_pev(id, pev_movetype, MOVETYPE_FLY)
687 set_pev(id, pev_effects, EF_NODRAW)
688 set_pev(id, pev_deadflag, DEAD_DEAD)
689 }
690 else
691 {
692 cs_set_user_team(id,CS_TEAM_CT)
693 set_pev(id, pev_effects, 0)
694 set_pev(id, pev_movetype, MOVETYPE_WALK)
695 set_pev(id, pev_deadflag, DEAD_NO)
696 set_pev(id, pev_takedamage, DAMAGE_AIM)
697 CmdRespawn(id)
698 give_item(id,"weapon_knife")
699 give_item(id,"weapon_usp")
700 cs_set_user_bpammo(id, CSW_USP, 36)
701
702 if (get_pcvar_num(kz_spec_saves) == 1)
703 {
704 set_pev(id, pev_origin, SpecLoc[id])
705 if ( timer_started [id] )
706 timer_time[id] = get_gametime() - g_pausetime[id] + timer_time[id]
707 if( WasPaused[id] )
708 {
709 Pause(id)
710 WasPaused[id]=false
711 }
712 }
713 }
714 return PLUGIN_HANDLED
715}
716
717
718//=================== Weapons ==============
719public curweapon(id)
720{
721 /*
722 if(get_pcvar_num(kz_maxspeedmsg) == 1 && is_user_alive(id))
723 {
724 new clip, ammo, speed,
725 switch(get_user_weapon(id,clip,ammo))
726 {
727 case CSW_SCOUT: speed = 260
728 case CSW_C4, CSW_P228, CSW_MAC10, CSW_MP5NAVY, CSW_USP, CSW_TMP, CSW_FLASHBANG, CSW_DEAGLE, CSW_GLOCK18, CSW_SMOKEGRENADE, CSW_ELITE, CSW_FIVESEVEN, CSW_UMP45, CSW_HEGRENADE, CSW_KNIFE: speed = 250
729 case CSW_P90: speed = 245
730 case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS: speed = 240
731 case CSW_SG552: speed = 235
732 case CSW_M3, CSW_M4A1: speed= 230
733 case CSW_AK47: speed = 221
734 case CSW_M249: speed = 220
735 case CSW_G3SG1, CSW_SG550, CSW_AWP: speed = 210
736 }
737 kz_hud_message(id,"%L",id, "KZ_WEAPONS_SPEED",speed)
738 }
739*/
740 static last_weapon[33];
741 static weapon_active, weapon_num
742 weapon_active = read_data(1)
743 weapon_num = read_data(2)
744
745 if( ( weapon_num != last_weapon[id] ) && weapon_active && get_pcvar_num(kz_maxspeedmsg) == 1)
746 {
747 last_weapon[id] = weapon_num;
748
749 static Float:maxspeed;
750 pev(id, pev_maxspeed, maxspeed );
751
752 if( maxspeed < 0.0 )
753 maxspeed = 250.0;
754
755 kz_hud_message(id,"%L",id, "KZ_WEAPONS_SPEED",floatround( maxspeed, floatround_floor ));
756 }
757 return PLUGIN_HANDLED
758}
759
760public weapons(id)
761{
762 if(!is_user_alive(id))
763 {
764 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
765 return PLUGIN_HANDLED
766 }
767
768 if(get_pcvar_num(kz_other_weapons) == 0)
769 {
770 kz_chat(id, "%L", id, "KZ_OTHER_WEAPONS_ZERO")
771 return PLUGIN_HANDLED
772 }
773
774 if (timer_started[id])
775 {
776 kz_chat(id, "%L", id, "KZ_WEAPONS_IN_RUN")
777 return PLUGIN_HANDLED
778 }
779
780 for(new i = 0; i < 8; i++)
781 if( !user_has_weapon(id, other_weapons[i]) )
782 {
783 new item;
784 item = give_item(id, other_weapons_name[i] );
785 cs_set_weapon_ammo(item, 0);
786 }
787
788 if( !user_has_weapon(id, CSW_USP) )
789 cmdUsp(id)
790
791 return PLUGIN_HANDLED
792}
793
794
795// ========================= Scout =======================
796public cmdScout(id)
797{
798 if (timer_started[id])
799 user_has_scout[id] = true
800
801 strip_user_weapons(id)
802 give_item(id,"weapon_usp")
803 give_item(id,"weapon_knife")
804 if( !user_has_weapon(id, CSW_SCOUT))
805 give_item(id,"weapon_scout")
806
807 return PLUGIN_HANDLED
808}
809
810public cmdUsp(id)
811{
812 give_item(id,"weapon_usp")
813 give_item(id,"weapon_knife")
814
815 return PLUGIN_HANDLED
816}
817
818// ========================== Start location =================
819
820public goStart(id)
821{
822 if( !is_user_alive( id ) )
823 {
824 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
825 return PLUGIN_HANDLED
826 }
827
828 if (IsPaused[id])
829 {
830 kz_chat(id, "%L", id, "KZ_TELEPORT_PAUSE")
831 return PLUGIN_HANDLED
832 }
833
834 if(get_pcvar_num(kz_save_autostart) == 1 && AutoStart [id] )
835 {
836 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
837 set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
838 set_pev(id, pev_origin, SavedStart [id] )
839
840 kz_chat(id, "%L", id, "KZ_START")
841 }
842 else if ( DefaultStart )
843 {
844 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
845 set_pev(id, pev_origin, DefaultStartPos)
846
847 kz_chat(id, "%L", id, "KZ_START")
848 }
849 else
850 {
851 kz_chat(id, "%L", id, "KZ_NO_START")
852
853 CmdRespawn(id)
854 }
855
856 return PLUGIN_HANDLED
857}
858
859public setStart(id)
860{
861 if (! (get_user_flags( id ) & KZ_LEVEL ))
862 {
863 kz_chat(id, "%L", id, "KZ_NO_ACCESS")
864 return PLUGIN_HANDLED
865 }
866
867 new Float:origin[3]
868 pev(id, pev_origin, origin)
869 kz_set_start(MapName, origin)
870 AutoStart[id] = false;
871 ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_SET_START")
872
873 return PLUGIN_HANDLED
874}
875
876// ========= Respawn CT if dies ========
877
878public Ham_CBasePlayer_Killed_Post(id)
879{
880 if(get_pcvar_num(kz_respawn_ct) == 1)
881 {
882 if( cs_get_user_team(id) == CS_TEAM_CT )
883 {
884 set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)
885 cs_set_user_deaths(id, 0)
886 set_user_frags(id, 0)
887 }
888 }
889}
890
891
892// ============================= NightVision ================================================
893
894public ToggleNVG(id)
895{
896
897 if( get_pcvar_num(kz_nvg) == 0 || !is_user_alive(id))
898 return PLUGIN_CONTINUE;
899
900 if ( NightVisionUse[id] )
901 StopNVG(id)
902 else
903 StartNVG(id)
904
905 return PLUGIN_HANDLED
906}
907
908public StartNVG(id)
909{
910 emit_sound(id,CHAN_ITEM,"items/nvg_on.wav",1.0,ATTN_NORM,0,PITCH_NORM)
911 set_task(0.1,"RunNVG",id+111111,_,_,"b")
912 NightVisionUse[id] = true;
913
914 return PLUGIN_HANDLED
915}
916
917public StopNVG(id)
918{
919 emit_sound(id,CHAN_ITEM,"items/nvg_off.wav",1.0,ATTN_NORM,0,PITCH_NORM)
920 remove_task(id+111111)
921 NightVisionUse[id] = false;
922
923 return PLUGIN_HANDLED
924}
925
926
927public RunNVG(taskid)
928{
929 new id = taskid - 111111
930
931 if (!is_user_alive(id)) return
932
933 new origin[3]
934 get_user_origin(id,origin,3)
935
936 new color[17];
937 get_pcvar_string(kz_nvg_colors,color,16);
938
939 new iRed[5], iGreen[7], iBlue[5]
940 parse(color,iRed,4,iGreen ,6,iBlue,4)
941
942 message_begin(MSG, SVC_TEMPENTITY, _, id)
943 write_byte(TE_DLIGHT)
944 write_coord(origin[0])
945 write_coord(origin[1])
946 write_coord(origin[2])
947 write_byte(80)
948 write_byte(str_to_num(iRed))
949 write_byte(str_to_num(iGreen))
950 write_byte(str_to_num(iBlue))
951 write_byte(2)
952 write_byte(0)
953 message_end()
954}
955
956// ============================ Hook ==============================================================
957
958public give_hook(id)
959{
960 if (!( get_user_flags( id ) & KZ_LEVEL ))
961 return PLUGIN_HANDLED
962
963 new szarg1[32], szarg2[8], bool:mode
964 read_argv(1,szarg1,32)
965 read_argv(2,szarg2,32)
966 if(equal(szarg2,"on"))
967 mode = true
968
969 if(equal(szarg1,"@ALL"))
970 {
971 new Alive[32], alivePlayers
972 get_players(Alive, alivePlayers, "ach")
973 for(new i;i<alivePlayers;i++)
974 {
975 canusehook[i] = mode
976 if(mode)
977 ColorChat(i, GREEN, "%s^x01, %L.", prefix, i, "KZ_HOOK")
978 }
979 }
980 else
981 {
982 new pid = find_player("bl",szarg1);
983 if(pid > 0)
984 {
985 canusehook[pid] = mode
986 if(mode)
987 {
988 ColorChat(pid, GREEN, "%s^x01 %L.", prefix, pid, "KZ_HOOK")
989 }
990 }
991 }
992
993 return PLUGIN_HANDLED
994}
995
996public hook_on(id)
997{
998 if( !is_user_alive(id) )
999 return PLUGIN_HANDLED
1000
1001 if (IsPaused[id])
1002 {
1003 kz_chat(id, "%L", id, "KZ_HOOK_PAUSE")
1004 return PLUGIN_HANDLED
1005 }
1006
1007 detect_cheat(id,"Hook")
1008 get_user_origin(id,hookorigin[id],3)
1009 ishooked[id] = true
1010 antihookcheat[id] = get_gametime()
1011
1012 if (get_pcvar_num(kz_hook_sound) == 1)
1013 emit_sound(id,CHAN_STATIC,"weapons/xbow_hit2.wav",1.0,ATTN_NORM,0,PITCH_NORM)
1014
1015 set_task(0.1,"hook_task",id,"",0,"ab")
1016 hook_task(id)
1017
1018 return PLUGIN_HANDLED
1019}
1020
1021public hook_off(id)
1022{
1023 remove_hook(id)
1024
1025 return PLUGIN_HANDLED
1026}
1027
1028public hook_task(id)
1029{
1030 if(!is_user_connected(id) || !is_user_alive(id))
1031 remove_hook(id)
1032
1033 remove_beam(id)
1034 draw_hook(id)
1035
1036 new origin[3], Float:velocity[3]
1037 get_user_origin(id,origin)
1038 new distance = get_distance(hookorigin[id],origin)
1039 velocity[0] = (hookorigin[id][0] - origin[0]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
1040 velocity[1] = (hookorigin[id][1] - origin[1]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
1041 velocity[2] = (hookorigin[id][2] - origin[2]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
1042
1043 set_pev(id,pev_velocity,velocity)
1044}
1045
1046public draw_hook(id)
1047{
1048 message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
1049 write_byte(1) // TE_BEAMENTPOINT
1050 write_short(id) // entid
1051 write_coord(hookorigin[id][0]) // origin
1052 write_coord(hookorigin[id][1]) // origin
1053 write_coord(hookorigin[id][2]) // origin
1054 write_short(Sbeam) // sprite index
1055 write_byte(0) // start frame
1056 write_byte(0) // framerate
1057 write_byte(random_num(1,100)) // life
1058 write_byte(random_num(1,20)) // width
1059 write_byte(random_num(1,0)) // noise
1060 write_byte(random_num(1,255)) // r
1061 write_byte(random_num(1,255)) // g
1062 write_byte(random_num(1,255)) // b
1063 write_byte(random_num(1,500)) // brightness
1064 write_byte(random_num(1,200)) // speed
1065 message_end()
1066}
1067
1068public remove_hook(id)
1069{
1070 if(task_exists(id))
1071 remove_task(id)
1072 remove_beam(id)
1073 ishooked[id] = false
1074}
1075
1076public remove_beam(id)
1077{
1078 message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
1079 write_byte(99) // TE_KILLBEAM
1080 write_short(id)
1081 message_end()
1082}
1083
1084
1085//============================ VIP In ScoreBoard =================================================
1086
1087public MessageScoreAttrib( iMsgID, iDest, iReceiver )
1088{
1089 if( get_pcvar_num(kz_vip) )
1090 {
1091 new iPlayer = get_msg_arg_int( 1 )
1092 if( is_user_alive( iPlayer ) && ( get_user_flags( iPlayer ) & KZ_LEVEL ) )
1093 {
1094 set_msg_arg_int( 2, ARG_BYTE, SCOREATTRIB_VIP );
1095 }
1096 }
1097}
1098
1099public EventStatusValue( const id )
1100{
1101
1102 new szMessage[ 34 ], Target, aux
1103 get_user_aiming(id, Target, aux)
1104 if (is_user_alive(Target))
1105 {
1106 formatex( szMessage, 33, "1 %s: %%p2", get_user_flags( Target ) & KZ_LEVEL ? "VIP" : "Player" )
1107 message_begin( MSG, get_user_msgid( "StatusText" ) , _, id )
1108 write_byte( 0 )
1109 write_string( szMessage )
1110 message_end( )
1111 }
1112}
1113
1114public detect_cheat(id,reason[])
1115{
1116 if(timer_started[id] && get_pcvar_num(kz_cheatdetect) == 1)
1117 {
1118 timer_started[id] = false
1119 if(IsPaused[id])
1120 {
1121 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1122 IsPaused[id] = false
1123 }
1124 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
1125 kz_showtime_roundtime(id, 0)
1126 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_CHEAT_DETECT", reason)
1127 }
1128}
1129
1130// =================================================================================================
1131// Cmds
1132// =================================================================================================
1133
1134public CheckPoint(id)
1135{
1136 if(!(pev(id, pev_flags) & FL_ONGROUND2) && !IsOnLadder(id))
1137 {
1138 client_print(id, print_center, "This command is not available to you at this point")
1139 return PLUGIN_HANDLED
1140 }
1141 if( !is_user_alive( id ) )
1142 {
1143 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1144 return PLUGIN_HANDLED
1145 }
1146
1147 if(get_pcvar_num(kz_checkpoints) == 0)
1148 {
1149 kz_chat(id, "%L", id, "KZ_CHECKPOINT_OFF")
1150 return PLUGIN_HANDLED
1151 }
1152
1153 if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) && !IsOnLadder(id))
1154 {
1155 kz_chat(id, "%L", id, "KZ_CHECKPOINT_AIR")
1156 return PLUGIN_HANDLED
1157 }
1158
1159 if( IsPaused[id] )
1160 {
1161 kz_chat(id, "%L", id, "KZ_CHECKPOINT_PAUSE")
1162 return PLUGIN_HANDLED
1163 }
1164
1165 pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id] ? 1 : 0])
1166 g_bCpAlternate[id] = !g_bCpAlternate[id]
1167 checknumbers[id]++
1168
1169 kz_chat(id, "%L", id, "KZ_CHECKPOINT", checknumbers[id])
1170
1171 return PLUGIN_HANDLED
1172}
1173
1174public GoCheck(id)
1175{
1176 if( !is_user_alive( id ) )
1177 {
1178 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1179 return PLUGIN_HANDLED
1180 }
1181
1182 if( checknumbers[id] == 0 )
1183 {
1184 kz_chat(id, "%L", id, "KZ_NOT_ENOUGH_CHECKPOINTS")
1185 return PLUGIN_HANDLED
1186 }
1187
1188 if( IsPaused[id] )
1189 {
1190 kz_chat(id, "%L", id, "KZ_TELEPORT_PAUSE")
1191 return PLUGIN_HANDLED
1192 }
1193
1194 set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} );
1195 set_pev( id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 } );
1196 set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING );
1197 set_pev( id, pev_fuser2, 0.0 );
1198 engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 } );
1199 set_pev(id, pev_origin, Checkpoints[ id ][ !g_bCpAlternate[id] ] )
1200 gochecknumbers[id]++
1201
1202 kz_chat(id, "%L", id, "KZ_GOCHECK", gochecknumbers[id])
1203
1204 return PLUGIN_HANDLED
1205}
1206
1207public Stuck(id)
1208{
1209 if( !is_user_alive( id ) )
1210 {
1211 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1212 return PLUGIN_HANDLED
1213 }
1214
1215 if( checknumbers[id] < 2 )
1216 {
1217 kz_chat(id, "%L", id, "KZ_NOT_ENOUGH_CHECKPOINTS")
1218 return PLUGIN_HANDLED
1219 }
1220
1221 set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} )
1222 set_pev( id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
1223 set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
1224 set_pev( id, pev_fuser2, 0.0 )
1225 engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 } )
1226 set_pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id]] )
1227 g_bCpAlternate[id] = !g_bCpAlternate[id];
1228 gochecknumbers[id]++
1229
1230 kz_chat(id, "%L", id, "KZ_GOCHECK", gochecknumbers[id])
1231
1232 return PLUGIN_HANDLED;
1233}
1234
1235// =================================================================================================
1236
1237public reset_checkpoints(id)
1238{
1239 checknumbers[id] = 0
1240 gochecknumbers[id] = 0
1241 timer_started[id] = false
1242 timer_time[id] = 0.0
1243 user_has_scout[id] = false
1244 if(IsPaused[id])
1245 {
1246 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1247 IsPaused[id] = false
1248 }
1249 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
1250 kz_showtime_roundtime(id, 0)
1251
1252 return PLUGIN_HANDLED
1253}
1254
1255public noclip(id)
1256{
1257 if(!is_user_alive(id))
1258 {
1259 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1260 return PLUGIN_HANDLED
1261 }
1262 new noclip = !get_user_noclip(id)
1263 set_user_noclip(id, noclip)
1264 if(IsPaused[id] && (get_pcvar_num(kz_noclip_pause) == 1))
1265 {
1266 if(noclip)
1267 {
1268 pev(id, pev_origin, NoclipPos[id])
1269 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1270 }
1271 else
1272 {
1273 set_pev(id, pev_origin, NoclipPos[id])
1274 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
1275 }
1276 }
1277 else if(noclip)
1278 detect_cheat(id,"Noclip")
1279 kz_chat(id, "%L", id, "KZ_NOCLIP" , noclip ? "ON" : "OFF")
1280
1281 return PLUGIN_HANDLED
1282}
1283
1284public GodMode(id)
1285{
1286 if(!is_user_alive(id))
1287 {
1288 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1289 return PLUGIN_HANDLED
1290 }
1291
1292 new godmode = !get_user_godmode(id)
1293 set_user_godmode(id, godmode)
1294 if(godmode)
1295 detect_cheat(id,"God Mode")
1296 kz_chat(id, "%L", id, "KZ_GODMODE" , godmode ? "ON" : "OFF")
1297
1298 return PLUGIN_HANDLED
1299}
1300
1301stock kz_set_start(const map[], Float:origin[3])
1302{
1303 new realfile[128], tempfile[128], formatorigin[50]
1304 formatex(realfile, 127, "%s/%s", Kzdir, KZ_STARTFILE)
1305 formatex(tempfile, 127, "%s/%s", Kzdir, KZ_STARTFILE_TEMP)
1306 formatex(formatorigin, 49, "%f %f %f", origin[0], origin[1], origin[2])
1307
1308 DefaultStartPos = origin
1309 DefaultStart = true
1310
1311 new file = fopen(tempfile, "wt")
1312 new vault = fopen(realfile, "rt")
1313
1314 new data[128], key[64]
1315 new bool:replaced = false
1316
1317 while( !feof(vault) )
1318 {
1319 fgets(vault, data, 127)
1320 parse(data, key, 63)
1321
1322 if( equal(key, map) && !replaced )
1323 {
1324 fprintf(file, "%s %s^n", map, formatorigin)
1325
1326 replaced = true
1327 }
1328 else
1329 {
1330 fputs(file, data)
1331 }
1332 }
1333
1334 if( !replaced )
1335 {
1336 fprintf(file, "%s %s^n", map, formatorigin)
1337 }
1338
1339 fclose(file)
1340 fclose(vault)
1341
1342 delete_file(realfile)
1343 while( !rename_file(tempfile, realfile, 1) ) {}
1344}
1345
1346stock kz_showtime_roundtime(id, time)
1347{
1348 if( is_user_connected(id) )
1349 {
1350 message_begin(MSG, get_user_msgid( "RoundTime" ), _, id);
1351 write_short(time + 1);
1352 message_end();
1353 }
1354}
1355
1356stock kz_chat(id, const message[], {Float,Sql,Result,_}:...)
1357{
1358 new cvar = get_pcvar_num(kz_chatorhud)
1359 if(cvar == 0)
1360 return PLUGIN_HANDLED
1361
1362 new msg[180], final[192]
1363 if (cvar == 1 && chatorhud[id] == -1 || chatorhud[id] == 1)
1364 {
1365 vformat(msg, 179, message, 3)
1366 formatex(final, 191, "%s^x01 %s", prefix, msg)
1367 kz_remplace_colors(final, 191)
1368 ColorChat(id, GREEN, "%s", final)
1369 }
1370 else if( cvar == 2 && chatorhud[id] == -1 || chatorhud[id] == 2)
1371 {
1372 vformat(msg, 179, message, 3)
1373 replace_all(msg, 191, "^x01", "")
1374 replace_all(msg, 191, "^x03", "")
1375 replace_all(msg, 191, "^x04", "")
1376 replace_all(msg, 191, ".", "")
1377 kz_hud_message(id, "%s", msg)
1378 }
1379
1380 return 1
1381}
1382
1383stock kz_print_config(id, const msg[])
1384{
1385 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, id);
1386 write_byte(id);
1387 write_string(msg);
1388 message_end();
1389}
1390
1391stock kz_remplace_colors(message[], len)
1392{
1393 replace_all(message, len, "!g", "^x04")
1394 replace_all(message, len, "!t", "^x03")
1395 replace_all(message, len, "!y", "^x01")
1396}
1397
1398stock kz_hud_message(id, const message[], {Float,Sql,Result,_}:...)
1399{
1400 static msg[192], colors[12], r[4], g[4], b[4];
1401 vformat(msg, 191, message, 3);
1402
1403 get_pcvar_string(kz_hud_color, colors, 11)
1404 parse(colors, r, 3, g, 3, b, 4)
1405
1406 set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), -1.0, 0.90, 0, 0.0, 2.0, 0.0, 1.0, -1);
1407 ShowSyncHudMsg(id, hud_message, msg);
1408}
1409
1410stock kz_register_saycmd(const saycommand[], const function[], flags)
1411{
1412 new temp[64]
1413 formatex(temp, 63, "say /%s", saycommand)
1414 register_clcmd(temp, function, flags)
1415 formatex(temp, 63, "say .%s", saycommand)
1416 register_clcmd(temp, function, flags)
1417 formatex(temp, 63, "say_team /%s", saycommand)
1418 register_clcmd(temp, function, flags)
1419 formatex(temp, 63, "say_team .%s", saycommand)
1420 register_clcmd(temp, function, flags)
1421}
1422
1423stock get_configsdir(name[],len)
1424{
1425 return get_localinfo("amxx_configsdir",name,len);
1426}
1427
1428#if defined USE_SQL
1429stock GetNewRank(id, type)
1430{
1431 new createinto[1001]
1432
1433 new cData[2]
1434 cData[0] = id
1435 cData[1] = type
1436
1437 formatex(createinto, 1000, "SELECT authid FROM `%s` WHERE mapname='%s' ORDER BY time LIMIT 15", type == PRO_TOP ? "kz_pro15" : "kz_nub15", MapName)
1438 SQL_ThreadQuery(g_SqlTuple, "GetNewRank_QueryHandler", createinto, cData, 2)
1439}
1440
1441stock kz_update_plrname(id)
1442{
1443 new createinto[1001], authid[32], name[32]
1444 get_user_authid(id, authid, 31)
1445 get_user_name(id, name, 31)
1446
1447 replace_all(name, 31, "\", "")
1448 replace_all(name, 31, "`", "")
1449 replace_all(name, 31, "'", "")
1450
1451 if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
1452 return 0;
1453 else
1454 {
1455 formatex(createinto, 1000, "UPDATE `kz_pro15` SET name='%s' WHERE authid='%s'", name, authid)
1456 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
1457 formatex(createinto, 1000, "UPDATE `kz_nub15` SET name='%s' WHERE authid='%s'", name, authid)
1458 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
1459 }
1460 return 1
1461}
1462#endif
1463
1464public FwdSpawnWeaponbox( iEntity )
1465{
1466 if(get_pcvar_num(kz_remove_drops) == 1)
1467 {
1468 set_pev( iEntity, pev_flags, FL_KILLME )
1469 dllfunc( DLLFunc_Think, iEntity )
1470 }
1471
1472 return HAM_IGNORED
1473}
1474
1475public FwdHamDoorSpawn( iEntity )
1476{
1477 static const szNull[ ] = "common/null.wav";
1478
1479 new Float:flDamage;
1480 pev( iEntity, pev_dmg, flDamage );
1481
1482 if( flDamage < -999.0 ) {
1483 set_pev( iEntity, pev_noise1, szNull );
1484 set_pev( iEntity, pev_noise2, szNull );
1485 set_pev( iEntity, pev_noise3, szNull );
1486
1487 if( !HealsOnMap )
1488 HealsOnMap = true
1489 }
1490}
1491
1492public FwdHamPlayerSpawn( id )
1493{
1494
1495 if( !is_user_alive( id ) )
1496 return;
1497
1498 if(firstspawn[id])
1499 {
1500 ColorChat(id, GREEN, "%s^x01 IP:^x04 85.217.196.76:27030", prefix)
1501
1502 if(get_pcvar_num(kz_checkpoints) == 0)
1503 ColorChat(id, GREEN, "%s^x01 %L", id, "KZ_CHECKPOINT_OFF", prefix)
1504
1505
1506 if(Verif(id,1) && get_pcvar_num(kz_save_pos) == 1)
1507 savepos_menu(id)
1508 else if(get_pcvar_num(kz_spawn_mainmenu) == 1)
1509 kz_menu (id)
1510 }
1511 firstspawn[id] = false
1512
1513
1514 if( !user_has_weapon(id,CSW_KNIFE) )
1515 give_item( id,"weapon_knife" )
1516
1517 if( HealsOnMap )
1518 set_user_health(id, 50175)
1519
1520 if( IsPaused[id] )
1521 {
1522 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
1523 set_pev(id, pev_origin, PauseOrigin[id])
1524 }
1525
1526 if(get_pcvar_num(kz_use_radio) == 0)
1527 {
1528 #define XO_PLAYER 5
1529 #define m_iRadiosLeft 192
1530 set_pdata_int(id, m_iRadiosLeft, 0, XO_PLAYER)
1531 }
1532}
1533
1534public GroundWeapon_Touch(iWeapon, id)
1535{
1536 if( is_user_alive(id) && timer_started[id] && get_pcvar_num(kz_pick_weapons) == 0 )
1537 return HAM_SUPERCEDE
1538
1539 return HAM_IGNORED
1540}
1541
1542
1543
1544// ==================================Save positions=================================================
1545
1546public SavePos(id)
1547{
1548
1549 new authid[33];
1550 get_user_authid(id, authid, 32)
1551 if(get_pcvar_num(kz_save_pos) == 0)
1552 {
1553 kz_chat(id, "%L", id, "KZ_SAVEPOS_DISABLED")
1554 return PLUGIN_HANDLED
1555 }
1556
1557 if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
1558 {
1559 ColorChat (id, GREEN, "%s^x01 %L", prefix, id, "KZ_NO_STEAM")
1560
1561 return PLUGIN_HANDLED
1562 }
1563
1564 if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) )
1565 {
1566 kz_chat(id, "%L", id, "KZ_NOT_ON_GROUND")
1567
1568 return PLUGIN_HANDLED
1569 }
1570
1571 if(!timer_started[id])
1572 {
1573 kz_chat(id, "%L", id, "KZ_TIMER_NOT_STARTED")
1574 return PLUGIN_HANDLED
1575 }
1576
1577 if(Verif(id,1))
1578 {
1579 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_ALREADY")
1580 savepos_menu(id)
1581 return PLUGIN_HANDLED
1582 }
1583
1584 if(get_user_noclip(id))
1585 {
1586 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_NOCLIP")
1587 return PLUGIN_HANDLED
1588 }
1589
1590 new Float:origin[3], scout
1591 pev(id, pev_origin, origin)
1592 new Float:Time,check,gocheck
1593 if(IsPaused[id])
1594 {
1595 Time = g_pausetime[id]
1596 Pause(id)
1597 }
1598 else
1599 Time=get_gametime() - timer_time[id]
1600 check=checknumbers[id]
1601 gocheck=gochecknumbers[id]
1602 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS")
1603 if (user_has_scout[id])
1604 scout=1
1605 else
1606 scout=0
1607 kz_savepos(id, Time, check, gocheck, origin, scout)
1608 reset_checkpoints(id)
1609
1610 return PLUGIN_HANDLED
1611}
1612
1613public GoPos(id)
1614{
1615 remove_hook(id)
1616 set_user_godmode(id, 0)
1617 set_user_noclip(id, 0)
1618 if(Verif(id,0))
1619 {
1620 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1621 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
1622 set_pev(id, pev_origin, SavedOrigins[id] )
1623 }
1624
1625 checknumbers[id]=SavedChecks[id]
1626 gochecknumbers[id]=SavedGoChecks[id]+((get_pcvar_num(kz_save_pos_gochecks)>0) ? 1 : 0)
1627 CheckPoint(id)
1628 CheckPoint(id)
1629 strip_user_weapons(id)
1630 give_item(id,"weapon_usp")
1631 give_item(id,"weapon_knife")
1632 if(SavedScout[id])
1633 {
1634 give_item(id, "weapon_scout")
1635 user_has_scout[id] = true
1636 }
1637 timer_time[id]=get_gametime()-SavedTime[id]
1638 timer_started[id]=true
1639 Pause(id)
1640
1641}
1642
1643public Verif(id, action)
1644{
1645 new realfile[128], tempfile[128], authid[32], map[64]
1646 new bool:exist = false
1647 get_mapname(map, 63)
1648 get_user_authid(id, authid, 31)
1649 formatex(realfile, 127, "%s/%s.ini", SavePosDir, map)
1650 formatex(tempfile, 127, "%s/temp.ini", SavePosDir)
1651
1652 if( !file_exists(realfile) )
1653 return 0
1654
1655 new file = fopen(tempfile, "wt")
1656 new vault = fopen(realfile, "rt")
1657 new data[150], sid[32], time[25], checks[5], gochecks[5], x[25], y[25], z[25], scout[5]
1658 while( !feof(vault) )
1659 {
1660 fgets(vault, data, 149)
1661 parse(data, sid, 31, time, 24, checks, 4, gochecks, 4, x, 24, y, 24, z, 24, scout, 4)
1662
1663 if( equal(sid, authid) && !exist) // ma aflu in fisier?
1664 {
1665 if(action == 1)
1666 fputs(file, data)
1667 exist= true
1668 SavedChecks[id] = str_to_num(checks)
1669 SavedGoChecks[id] = str_to_num(gochecks)
1670 SavedTime[id] = str_to_float(time)
1671 SavedOrigins[id][0]=str_to_num(x)
1672 SavedOrigins[id][1]=str_to_num(y)
1673 SavedOrigins[id][2]=str_to_num(z)
1674 SavedScout[id] = str_to_num(scout)
1675 }
1676 else
1677 {
1678 fputs(file, data)
1679 }
1680 }
1681
1682 fclose(file)
1683 fclose(vault)
1684
1685 delete_file(realfile)
1686 if(file_size(tempfile) == 0)
1687 delete_file(tempfile)
1688 else
1689 while( !rename_file(tempfile, realfile, 1) ) {}
1690
1691
1692 if(!exist)
1693 return 0
1694
1695 return 1
1696}
1697public kz_savepos (id, Float:time, checkpoints, gochecks, Float:origin[3], scout)
1698{
1699 new realfile[128], formatorigin[128], map[64], authid[32]
1700 get_mapname(map, 63)
1701 get_user_authid(id, authid, 31)
1702 formatex(realfile, 127, "%s/%s.ini", SavePosDir, map)
1703 formatex(formatorigin, 127, "%s %f %d %d %d %d %d %d", authid, time, checkpoints, gochecks, origin[0], origin[1], origin[2], scout)
1704
1705 new vault = fopen(realfile, "rt+")
1706 write_file(realfile, formatorigin) // La sfarsit adaug datele mele
1707
1708 fclose(vault)
1709
1710}
1711
1712// =================================================================================================
1713// Events / Forwards
1714// =================================================================================================
1715
1716//=================================================================================================
1717
1718public client_disconnect(id)
1719{
1720 checknumbers[id] = 0
1721 gochecknumbers[id] = 0
1722 antihookcheat[id] = 0.0
1723 chatorhud[id] = -1
1724 timer_started[id] = false
1725 ShowTime[id] = get_pcvar_num(kz_show_timer)
1726 firstspawn[id] = true
1727 NightVisionUse[id] = false
1728 IsPaused[id] = false
1729 WasPaused[id] = false
1730 user_has_scout[id] = false
1731 remove_hook(id)
1732}
1733
1734public client_putinserver(id)
1735{
1736 checknumbers[id] = 0
1737 gochecknumbers[id] = 0
1738 antihookcheat[id] = 0.0
1739 chatorhud[id] = -1
1740 timer_started[id] = false
1741 ShowTime[id] = get_pcvar_num(kz_show_timer)
1742 firstspawn[id] = true
1743 NightVisionUse[id] = false
1744 IsPaused[id] = false
1745 WasPaused[id] = false
1746 user_has_scout[id] = false
1747 remove_hook(id)
1748}
1749
1750// =================================================================================================
1751// Menu
1752// =================================================================================================
1753
1754
1755public kz_menu(id)
1756{
1757 new title[64];
1758 formatex(title, 63, "\yMenu\w")
1759 new menu = menu_create(title, "MenuHandler")
1760
1761 new msgcheck[64], msggocheck[64], msgpause[64]
1762 formatex(msgcheck, 63, "Checkpoint - \y#%i", checknumbers[id])
1763 formatex(msggocheck, 63, "Gocheck - \y#%i", gochecknumbers[id])
1764 formatex(msgpause, 63, "Pause - %s^n", IsPaused[id] ? "\yON" : "\rOFF" )
1765
1766 menu_additem( menu, msgcheck, "1" )
1767 menu_additem( menu, msggocheck, "2" )
1768 menu_additem( menu, "Top 15^n", "3")
1769 menu_additem( menu, "Start", "4")
1770 menu_additem( menu, "Timer Menu", "5" )
1771 menu_additem( menu, msgpause, "6" )
1772 menu_additem( menu, "Spectator/CT", "7" )
1773 menu_additem( menu, "Reset Time^n", "8")
1774 menu_additem( menu, "Exit", "MENU_EXIT" )
1775
1776 menu_setprop(menu, MPROP_PERPAGE, 0)
1777 menu_display(id, menu, 0)
1778 return PLUGIN_HANDLED
1779}
1780
1781public MenuHandler(id , menu, item)
1782{
1783 if( item == MENU_EXIT ) {
1784 menu_destroy(menu)
1785 return PLUGIN_HANDLED
1786 }
1787
1788
1789 switch(item) {
1790 case 0:{
1791 CheckPoint(id)
1792 kz_menu(id)
1793 }
1794 case 1:{
1795 GoCheck(id)
1796 kz_menu(id)
1797 }
1798 case 2:{
1799 top15menu(id)
1800 }
1801 case 3:{
1802 goStart(id)
1803 kz_menu(id)
1804 }
1805 case 4:{
1806 ShowTimer_Menu(id)
1807 }
1808 case 5:{
1809 Pause(id)
1810 kz_menu(id)
1811 }
1812 case 6:{
1813 ct(id)
1814 }
1815 case 7:{
1816 reset_checkpoints(id)
1817 kz_menu(id)
1818 }
1819 }
1820
1821 return PLUGIN_HANDLED
1822}
1823
1824public ShowTimer_Menu(id)
1825{
1826 if (get_pcvar_num(kz_show_timer) == 0 )
1827 {
1828 kz_chat(id, "%L", id, "KZ_TIMER_DISABLED")
1829 return PLUGIN_HANDLED
1830 }
1831 else
1832 {
1833 new menu = menu_create("\yTimer Menu\w", "TimerHandler")
1834
1835 new roundtimer[64], hudtimer[64], notimer[64];
1836
1837 formatex(roundtimer, 63, "Round Timer %s", ShowTime[id] == 2 ? "\y x" : "" )
1838 formatex(hudtimer, 63, "HUD Timer %s", ShowTime[id] == 1 ? "\y x" : "" )
1839 formatex(notimer, 63, "No Timer %s^n", ShowTime[id] == 0 ? "\y x" : "" )
1840
1841 menu_additem( menu, roundtimer, "1" )
1842 menu_additem( menu, hudtimer, "2" )
1843 menu_additem( menu, notimer, "3" )
1844 menu_additem( menu, "Main Menu", "4" )
1845
1846 menu_display(id, menu, 0)
1847 return PLUGIN_HANDLED
1848 }
1849
1850 return PLUGIN_HANDLED
1851}
1852
1853public TimerHandler (id, menu, item)
1854{
1855 if( item == MENU_EXIT )
1856 {
1857 menu_destroy(menu)
1858 return PLUGIN_HANDLED
1859 }
1860
1861 switch(item)
1862 {
1863
1864 case 0:
1865 {
1866 ShowTime[id]= 2
1867 ShowTimer_Menu(id)
1868 }
1869 case 1:
1870 {
1871 ShowTime[id]= 1
1872 ShowTimer_Menu(id)
1873 if (timer_started[id])
1874 kz_showtime_roundtime(id, 0)
1875 }
1876 case 2:
1877 {
1878 ShowTime[id]= 0
1879 ShowTimer_Menu(id)
1880 if (timer_started[id])
1881 kz_showtime_roundtime(id, 0)
1882 }
1883 case 3:
1884 {
1885 kz_menu(id)
1886 }
1887 }
1888 return PLUGIN_HANDLED
1889}
1890
1891public savepos_menu(id)
1892{
1893 new menu = menu_create("SavePos Menu", "SavePosHandler")
1894
1895 menu_additem( menu, "Reload previous run", "1" )
1896 menu_additem( menu, "Start a new run", "2" )
1897
1898 menu_display(id, menu, 0)
1899 return PLUGIN_HANDLED
1900}
1901
1902public SavePosHandler(id, menu, item)
1903{
1904
1905 switch(item)
1906 {
1907 case 0:
1908 {
1909 GoPos(id)
1910 }
1911 case 1:
1912 {
1913 Verif(id,0)
1914 }
1915 }
1916 return PLUGIN_HANDLED
1917}
1918
1919public top15menu(id)
1920{
1921 new menu = menu_create("\rProKreedz \yTop15 \w", "top15handler")
1922 menu_additem(menu, "\wPro 15", "1", 0)
1923 menu_additem(menu, "\wNoob 15^n^n", "2", 0)
1924 #if defined USE_SQL
1925 menu_additem(menu, "Pro Records","3")
1926 menu_additem(menu, "Players Rankings^n","4")
1927 menu_additem(menu, "Last 10 Pro Entries", "5")
1928 menu_additem(menu, "Maps Statistic","6")
1929 menu_additem(menu, "Main Menu", "7")
1930 #else
1931 menu_additem(menu, "\wMain Menu", "3", 0)
1932 #endif
1933
1934 menu_display(id, menu, 0);
1935
1936 return PLUGIN_HANDLED;
1937}
1938
1939public top15handler(id, menu, item)
1940{
1941 if(item == MENU_EXIT)
1942 {
1943 menu_destroy(menu)
1944 return PLUGIN_HANDLED
1945 }
1946 #if defined USE_SQL
1947 switch(item)
1948 {
1949 case 0:
1950 {
1951 ProTop_show(id)
1952 }
1953 case 1:
1954 {
1955 NoobTop_show(id)
1956 }
1957 case 2:
1958 {
1959 kz_showhtml_motd(id, PRO_RECORDS, "")
1960 }
1961 case 3:
1962 {
1963 kz_showhtml_motd(id, PLAYERS_RANKING, "")
1964 }
1965 case 4:
1966 {
1967 kz_showhtml_motd(id, LAST_PRO10, "")
1968 }
1969 case 5:
1970 {
1971 kz_showhtml_motd(id, MAPS_STATISTIC, "")
1972 }
1973 case 6:
1974 {
1975 kz_menu(id)
1976 }
1977 }
1978 #else
1979 switch(item)
1980 {
1981 case 0:
1982 {
1983 ProTop_show(id)
1984 }
1985 case 1:
1986 {
1987 NoobTop_show(id)
1988 }
1989 case 2:
1990 {
1991 kz_menu(id)
1992 }
1993 }
1994 #endif
1995
1996 return PLUGIN_HANDLED;
1997}
1998
1999// =================================================================================================
2000
2001//
2002// Timersystem
2003// =================================================================================================
2004public fwdUse(ent, id)
2005{
2006 if( !ent || id > 32 )
2007 {
2008 return HAM_IGNORED;
2009 }
2010
2011 if( !is_user_alive(id) )
2012 {
2013 return HAM_IGNORED;
2014 }
2015
2016
2017 new name[32]
2018 get_user_name(id, name, 31)
2019
2020 new szTarget[ 32 ];
2021 pev(ent, pev_target, szTarget, 31);
2022
2023 if( TrieKeyExists( g_tStarts, szTarget ) )
2024 {
2025
2026 if ( get_gametime() - antihookcheat[id] < 3.0 )
2027 {
2028 kz_hud_message( id, "%L", id, "KZ_HOOK_PROTECTION" );
2029 return PLUGIN_HANDLED
2030 }
2031
2032 if(Verif(id,1))
2033 {
2034 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_SAVED")
2035 savepos_menu(id)
2036 return HAM_IGNORED
2037 }
2038
2039 if ( reset_checkpoints(id) && !timer_started[id] )
2040 {
2041 start_climb(id)
2042 new wpn=get_user_weapon(id)
2043 for(new i = 0; i < 8; i++)
2044 if( user_has_weapon(id, other_weapons[i]) )
2045 {
2046 strip_user_weapons(id)
2047 give_item(id,"weapon_knife")
2048 give_item(id,"weapon_usp")
2049 set_pdata_int(id, 382, 24, 5)
2050 if(wpn==CSW_SCOUT)
2051 {
2052 user_has_scout[id]=true
2053 give_item(id,"weapon_scout")
2054 }
2055 else
2056 user_has_scout[id]=false
2057 }
2058
2059 if( get_user_health(id) < 100 )
2060 set_user_health(id, 100)
2061
2062 pev(id, pev_origin, SavedStart[id])
2063 if(get_pcvar_num(kz_save_autostart) == 1)
2064 AutoStart[id] = true;
2065
2066 if( !DefaultStart )
2067 {
2068 kz_set_start(MapName, SavedStart[id])
2069 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SET_START")
2070 }
2071
2072 remove_hook(id)
2073 }
2074
2075 }
2076
2077 if( TrieKeyExists( g_tStops, szTarget ) )
2078 {
2079 if( timer_started[id] )
2080 {
2081 if(get_user_noclip(id))
2082 return PLUGIN_HANDLED
2083
2084 finish_climb(id)
2085
2086 if(get_pcvar_num(kz_hook_prize) == 1 && !canusehook[id])
2087 {
2088 canusehook[id] = true
2089 ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_HOOK")
2090 }
2091 }
2092 else
2093 kz_hud_message(id, "%L", id, "KZ_TIMER_NOT_STARTED")
2094
2095 }
2096 return HAM_IGNORED
2097}
2098
2099public start_climb(id)
2100{
2101 kz_chat(id, "%L", id, "KZ_START_CLIMB")
2102
2103 if (get_pcvar_num(kz_reload_weapons) == 1)
2104 {
2105 strip_user_weapons(id)
2106 give_item(id,"weapon_knife")
2107 give_item(id,"weapon_usp")
2108 }
2109
2110 if (ShowTime[id] == 2)
2111 kz_showtime_roundtime(id, 0)
2112 set_pev(id, pev_gravity, 1.0);
2113 set_pev(id, pev_movetype, MOVETYPE_WALK)
2114 set_user_godmode(id, 0)
2115 reset_checkpoints(id)
2116 IsPaused[id] = false
2117 timer_started[id] = true
2118 timer_time[id] = get_gametime()
2119}
2120
2121public finish_climb(id)
2122{
2123 if (!is_user_alive (id))
2124 {
2125 return;
2126 }
2127
2128 if ( (get_pcvar_num(kz_top15_authid) > 1) || (get_pcvar_num(kz_top15_authid) < 0) )
2129 {
2130 ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_TOP15_DISABLED")
2131 return;
2132 }
2133
2134 #if defined USE_SQL
2135 new Float: time, wpn
2136 time = get_gametime() - timer_time[id]
2137 show_finish_message(id, time)
2138 timer_started[id] = false
2139 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
2140 kz_showtime_roundtime(id, 0)
2141 new checkpoints=checknumbers[id]
2142 new gocheck=gochecknumbers[id]
2143 if(user_has_scout[id])
2144 wpn=CSW_SCOUT
2145 else
2146 wpn=get_user_weapon( id )
2147
2148 new steam[32], name[32]
2149 get_user_name(id, name, 31)
2150 get_user_authid(id, steam, 31 )
2151 client_cmd(0, "spk buttons/bell1")
2152 new createinto[1001]
2153
2154 new cData[192]
2155 cData[0] = id
2156 formatex(cData[2], charsmax(cData)-2, "^"%f^" ^"%d^" ^"%d^" ^"%d^"", time, wpn, checkpoints ,gocheck)
2157
2158
2159 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
2160 {
2161 if (gochecknumbers[id] == 0 && !user_has_scout[id] )
2162 {
2163 cData[1] = PRO_TOP
2164 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND name='%s'", MapName, name)
2165 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2166 }
2167 if (gochecknumbers[id] > 0 || user_has_scout[id] )
2168 {
2169 cData[1] = NUB_TOP
2170 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND name='%s'", MapName, name)
2171 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2172 }
2173 } else
2174 {
2175
2176 if (gochecknumbers[id] == 0 && !user_has_scout[id] )
2177 {
2178 cData[1] = PRO_TOP
2179 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND authid='%s'", MapName, steam)
2180 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2181 }
2182 if (gochecknumbers[id] > 0 || user_has_scout[id] )
2183 {
2184 cData[1] = NUB_TOP
2185 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND authid='%s'", MapName, steam)
2186 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2187 }
2188 }
2189 #else
2190 new Float: time, authid[32]
2191 time = get_gametime() - timer_time[id]
2192 get_user_authid(id, authid, 31)
2193 show_finish_message(id, time)
2194 timer_started[id] = false
2195 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
2196 kz_showtime_roundtime(id, 0)
2197
2198 if (gochecknumbers[id] == 0 && !user_has_scout[id] )
2199 ProTop_update(id, time)
2200 if (gochecknumbers[id] > 0 || user_has_scout[id] )
2201 NoobTop_update(id, time, checknumbers[id], gochecknumbers[id])
2202 #endif
2203 user_has_scout[id] = false
2204
2205}
2206
2207public show_finish_message(id, Float:kreedztime)
2208{
2209 new name[32]
2210 new imin,isec,ims, wpn
2211 if(user_has_scout[id])
2212 wpn=CSW_SCOUT
2213 else
2214 wpn=get_user_weapon( id )
2215 get_user_name(id, name, 31)
2216 imin = floatround(kreedztime / 60.0, floatround_floor)
2217 isec = floatround(kreedztime - imin * 60.0,floatround_floor)
2218 ims = floatround( ( kreedztime - ( imin * 60.0 + isec ) ) * 100.0, floatround_floor )
2219
2220 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x04 %02i:%02i.%02i ^x03(^x01 CPs: ^x04%d^x03 | ^x01 TPs: ^x04%d^x03 | ^x01 %L: ^x04%s^x03) ^x01 !", prefix, name, LANG_PLAYER, "KZ_FINISH_MSG", imin, isec, ims, checknumbers[id], gochecknumbers[id], LANG_PLAYER, "KZ_WEAPON", g_weaponsnames[wpn])
2221}
2222
2223//==========================================================
2224#if defined USE_SQL
2225public Set_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
2226{
2227 new id = cData[0]
2228 new style = cData[1]
2229 if( iFailState != TQUERY_SUCCESS )
2230 {
2231 log_amx("[KZ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
2232 ColorChat(0, GREEN, "%s^x01 %F", prefix, LANG_PLAYER, "KZ_TOP15_SQL_ERROR")
2233 }
2234
2235 server_print("[KZ] Server Geting Info of SQL Server")
2236
2237 new createinto[1001]
2238 new x1[16], x2[4], x3[5], x4[5]
2239 parse(cData[2], x1, 15, x2, 3, x3, 4, x4, 4)
2240
2241 new dia[64], steam[32], name[32], ip[15], country[3], checkpoints[32], gochecks[32]
2242 new Float:newtime = str_to_float(x1)
2243 new iMin, iSec, iMs, server[64]
2244 get_pcvar_string(kz_sql_name, server, 63)
2245 get_time("%Y%m%d%H%M%S", dia, sizeof dia - 1)
2246 get_user_authid(id, steam, 31)
2247 get_user_name(id, name, sizeof name - 1)
2248 get_user_ip (id, ip, sizeof ip - 1, 1)
2249 geoip_code2_ex( ip, country)
2250
2251 replace_all(name, 31, "\", "")
2252 replace_all(name, 31, "`", "")
2253 replace_all(name, 31, "'", "")
2254
2255
2256 if( SQL_NumResults(hQuery) == 0 )
2257 {
2258 formatex(checkpoints, 31, ", '%d'", str_to_num(x3))
2259 formatex(gochecks, 31, ", '%d'", str_to_num(x4))
2260 formatex( createinto, sizeof createinto - 1, "INSERT INTO `%s` VALUES('%s', '%s','%s','%s','%f','%s','%s','%s'%s%s)", style == PRO_TOP ? "kz_pro15" : "kz_nub15", MapName, steam, country, name, newtime, dia, g_weaponsnames[str_to_num(x2)], server, style == PRO_TOP ? "" : checkpoints, style == PRO_TOP ? "" : gochecks)
2261 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
2262 GetNewRank(id, style)
2263 }
2264 else
2265 {
2266 new Float:oldtime, Float:thetime
2267 SQL_ReadResult(hQuery, 0, oldtime)
2268
2269 if(newtime < oldtime)
2270 {
2271 thetime = oldtime - newtime
2272 iMin = floatround(thetime / 60.0, floatround_floor)
2273 iSec = floatround(thetime - iMin * 60.0,floatround_floor)
2274 iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor )
2275 ColorChat(id, GREEN, "[KZ]^x01 %L^x03 %02i:%02i.%02i^x01 in ^x03%s", id, "KZ_IMPROVE", iMin, iSec, iMs, style == PRO_TOP ? "Pro 15" : "Noob 15")
2276 formatex(checkpoints, 31, ", checkpoints='%d'", str_to_num(x3))
2277 formatex(gochecks, 31, ", gocheck='%d'", str_to_num(x4))
2278 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
2279 formatex(createinto, sizeof createinto - 1, "UPDATE `%s` SET time='%f', weapon='%s', date='%s', server='%s'%s%s WHERE name='%s' AND mapname='%s'", style == PRO_TOP ? "kz_pro15" : "kz_nub15", newtime, g_weaponsnames[str_to_num(x2)], dia, server, style == PRO_TOP ? "" : gochecks, style == PRO_TOP ? "" : checkpoints, name, MapName)
2280 else
2281 formatex(createinto, sizeof createinto - 1, "UPDATE `%s` SET time='%f', weapon='%s', date='%s', server='%s'%s%s WHERE authid='%s' AND mapname='%s'", style == PRO_TOP ? "kz_pro15" : "kz_nub15", newtime, g_weaponsnames[str_to_num(x2)], dia, server, style == PRO_TOP ? "" : gochecks, style == PRO_TOP ? "" : checkpoints, steam, MapName)
2282
2283 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto )
2284 GetNewRank(id, style)
2285 }
2286 else
2287 {
2288 thetime = newtime - oldtime
2289 iMin = floatround(thetime / 60.0, floatround_floor)
2290 iSec = floatround(thetime - iMin * 60.0,floatround_floor)
2291 iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor )
2292 ColorChat(id, GREEN, "[KZ]^x01 %L^x03 %02i:%02i.%02i ^x01in ^x03%s", id, "KZ_SLOWER", iMin, iSec, iMs, style == PRO_TOP ? "Pro 15" : "Noob 15")
2293 }
2294 }
2295
2296 return PLUGIN_CONTINUE
2297
2298}
2299
2300public GetNewRank_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
2301{
2302 new id = cData[0]
2303 if( iFailState != TQUERY_SUCCESS )
2304 {
2305 return log_amx("TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
2306 }
2307
2308 new steam[32], authid[32], namez[32], name[32], i = 0
2309 get_user_authid(id, steam, 31)
2310 get_user_name(id, namez, 31)
2311
2312 while( SQL_MoreResults(hQuery) )
2313 {
2314 i++
2315 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
2316 {
2317 SQL_ReadResult(hQuery, 0, name, 31)
2318 if( equal(name, namez) )
2319 {
2320 ColorChat(0, GREEN, "%s^x03 %s^x01 %L ^x03%d^x01 in^x03 %s^x01",prefix, namez, LANG_PLAYER, "KZ_PLACE", i, cData[1] == PRO_TOP ? "Pro 15" : "Noob 15");
2321 break;
2322 }
2323 }
2324 else
2325 {
2326 SQL_ReadResult(hQuery, 0, authid, 31)
2327 if( equal(authid, steam) )
2328 {
2329 ColorChat(0, GREEN, "%s^x03 %s^x01 %L ^x03%d^x01 in^x03 %s^x01",prefix, namez, LANG_PLAYER, "KZ_PLACE", i, cData[1] == PRO_TOP ? "Pro 15" : "Noob 15");
2330 break;
2331 }
2332 }
2333 SQL_NextRow(hQuery)
2334 }
2335
2336 return PLUGIN_CONTINUE
2337}
2338
2339public ProTop_show(id)
2340{
2341 kz_showhtml_motd(id, PRO_TOP, MapName)
2342
2343 return PLUGIN_HANDLED
2344}
2345
2346public NoobTop_show(id)
2347{
2348
2349 kz_showhtml_motd(id, NUB_TOP, MapName)
2350
2351 return PLUGIN_HANDLED
2352}
2353
2354public ProRecs_show(id)
2355{
2356 new authid[32]
2357 get_user_authid(id, authid, 31)
2358
2359 if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
2360 {
2361 ColorChat (id, GREEN, "%s^x01 %L", prefix, id, "KZ_NO_STEAM")
2362 return PLUGIN_HANDLED
2363 }
2364
2365 kz_showhtml_motd(id, PRO_RECORDS, MapName)
2366
2367 return PLUGIN_HANDLED
2368}
2369
2370stock kz_showhtml_motd(id, type, const map[])
2371{
2372 new buffer[1001], namebuffer[64], filepath[96]
2373 get_pcvar_string(kz_sql_files, filepath, 95)
2374 new authid[32]
2375 get_user_authid(id, authid, 31)
2376
2377 switch( type )
2378 {
2379 case PRO_TOP:
2380 {
2381 formatex(namebuffer, 63, "Pro 15 of %s", equal(map, "") ? "All Maps" : map)
2382 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/pro15.php?map=%s^"></head><body><p>LOADING...</p></body></html>", filepath, map)
2383 }
2384 case NUB_TOP:
2385 {
2386 formatex(namebuffer, 63, "Noob 15 of %s", equal(map, "") ? "All Maps" : map)
2387 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/nub15.php?map=%s^"></head><body><p>LOADING...</p></body></html>", filepath, map)
2388 }
2389 case PRO_RECORDS:
2390 {
2391 formatex(namebuffer, 63, "ProRecords and Rank")
2392 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/player.php?authid=%s^"></head><body><p>LOADING...</p></body></html>", filepath, authid)
2393 }
2394 case PLAYERS_RANKING:
2395 {
2396 formatex(namebuffer, 63, "Players Ranking")
2397 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/players.php^"></head><body><p>LOADING...</p></body></html>", filepath, authid)
2398 }
2399 case LAST_PRO10:
2400 {
2401 formatex(namebuffer, 63, "Last 10 Pro Entries")
2402 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/lastpro.php^"></head><body><p>LOADING...</p></body></html>", filepath)
2403 }
2404 case MAPS_STATISTIC:
2405 {
2406 formatex(namebuffer, 63, "Maps Statistic")
2407 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/map.php^"></head><body><p>LOADING...</p></body></html>", filepath)
2408 }
2409 }
2410
2411 show_motd(id, buffer, namebuffer)
2412}
2413#else
2414public ProTop_update(id, Float:time)
2415{
2416 new authid[32], name[32], thetime[32], Float: slower, Float: faster, Float:protiempo
2417 get_user_name(id, name, 31);
2418 get_user_authid(id, authid, 31);
2419 get_time(" %d/%m/%Y ", thetime, 31);
2420 new bool:Is_in_pro15
2421 Is_in_pro15 = false
2422
2423 for(new i = 0; i < 15; i++)
2424 {
2425 if( (equali(Pro_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Pro_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2426 {
2427 Is_in_pro15 = true
2428 slower = time - Pro_Times[i]
2429 faster = Pro_Times[i] - time
2430 protiempo = Pro_Times[i]
2431 }
2432 }
2433
2434 for (new i = 0; i < 15; i++)
2435 {
2436 if( time < Pro_Times[i])
2437 {
2438 new pos = i
2439 if ( get_pcvar_num(kz_top15_authid) == 0 )
2440 while( !equal(Pro_Names[pos], name) && pos < 15 )
2441 {
2442 pos++;
2443 }
2444 else if ( get_pcvar_num(kz_top15_authid) == 1)
2445 while( !equal(Pro_AuthIDS[pos], authid) && pos < 15 )
2446 {
2447 pos++;
2448 }
2449
2450 for (new j = pos; j > i; j--)
2451 {
2452 formatex(Pro_AuthIDS[j], 31, Pro_AuthIDS[j-1]);
2453 formatex(Pro_Names[j], 31, Pro_Names[j-1]);
2454 formatex(Pro_Date[j], 31, Pro_Date[j-1])
2455 Pro_Times[j] = Pro_Times[j-1];
2456 }
2457
2458 formatex(Pro_AuthIDS[i], 31, authid);
2459 formatex(Pro_Names[i], 31, name);
2460 formatex(Pro_Date[i], 31, thetime)
2461 Pro_Times[i] = time
2462
2463 save_pro15()
2464
2465 if( Is_in_pro15 )
2466 {
2467
2468 if( time < protiempo )
2469 {
2470 new min, Float:sec;
2471 min = floatround(faster, floatround_floor)/60;
2472 sec = faster - (60*min);
2473 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_IMPROVE", min, sec < 10 ? "0" : "", sec);
2474
2475 if( (i + 1) == 1)
2476 {
2477 client_cmd(0, "spk woop");
2478 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2479 }
2480 else
2481 {
2482 client_cmd(0, "spk buttons/bell1");
2483 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2484 }
2485 }
2486 }
2487 else
2488 {
2489 if( (i + 1) == 1)
2490 {
2491 client_cmd(0, "spk woop");
2492 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2493 }
2494 else
2495 {
2496 client_cmd(0, "spk buttons/bell1");
2497 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2498 }
2499 }
2500
2501 return;
2502 }
2503
2504 if( (equali(Pro_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Pro_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2505 {
2506 if( time > protiempo )
2507 {
2508 new min, Float:sec;
2509 min = floatround(slower, floatround_floor)/60;
2510 sec = slower - (60*min);
2511 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_SLOWER", min, sec < 10 ? "0" : "", sec);
2512 return;
2513 }
2514 }
2515
2516 }
2517}
2518
2519public save_pro15()
2520{
2521 new profile[128]
2522 formatex(profile, 127, "%s/pro_%s.cfg", Topdir, MapName)
2523
2524 if( file_exists(profile) )
2525 {
2526 delete_file(profile)
2527 }
2528
2529 new Data[256];
2530 new f = fopen(profile, "at")
2531
2532 for(new i = 0; i < 15; i++)
2533 {
2534 formatex(Data, 255, "^"%.2f^" ^"%s^" ^"%s^" ^"%s^"^n", Pro_Times[i], Pro_AuthIDS[i], Pro_Names[i], Pro_Date[i])
2535 fputs(f, Data)
2536 }
2537 fclose(f);
2538}
2539
2540public read_pro15()
2541{
2542 new profile[128], prodata[256]
2543 formatex(profile, 127, "%s/pro_%s.cfg", Topdir, MapName)
2544
2545 new f = fopen(profile, "rt" )
2546 new i = 0
2547 while( !feof(f) && i < 16)
2548 {
2549 fgets(f, prodata, 255)
2550 new totime[25]
2551 parse(prodata, totime, 24, Pro_AuthIDS[i], 31, Pro_Names[i], 31, Pro_Date[i], 31)
2552 Pro_Times[i] = str_to_float(totime)
2553 i++;
2554 }
2555 fclose(f)
2556}
2557
2558//==================================================================================================
2559
2560public NoobTop_update(id, Float:time, checkpoints, gochecks)
2561{
2562 new authid[32], name[32], thetime[32], wpn, Float: slower, Float: faster, Float:noobtiempo
2563 get_user_name(id, name, 31);
2564 get_user_authid(id, authid, 31);
2565 get_time(" %d/%m/%Y ", thetime, 31);
2566 new bool:Is_in_noob15
2567 Is_in_noob15 = false
2568 if(user_has_scout[id])
2569 wpn=CSW_SCOUT
2570 else
2571 wpn=get_user_weapon(id)
2572
2573 for(new i = 0; i < 15; i++)
2574 {
2575 if( (equali(Noob_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Noob_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2576 {
2577 Is_in_noob15 = true
2578 slower = time - Noob_Tiempos[i];
2579 faster = Noob_Tiempos[i] - time;
2580 noobtiempo = Noob_Tiempos[i]
2581 }
2582 }
2583
2584 for (new i = 0; i < 15; i++)
2585 {
2586 if( time < Noob_Tiempos[i])
2587 {
2588 new pos = i
2589
2590 if ( get_pcvar_num(kz_top15_authid) == 0 )
2591 while( !equal(Noob_Names[pos], name) && pos < 15 )
2592 {
2593 pos++;
2594 }
2595 else if ( get_pcvar_num(kz_top15_authid) == 1)
2596 while( !equal(Noob_AuthIDS[pos], authid) && pos < 15 )
2597 {
2598 pos++;
2599 }
2600
2601 for (new j = pos; j > i; j--)
2602 {
2603 formatex(Noob_AuthIDS[j], 31, Noob_AuthIDS[j-1])
2604 formatex(Noob_Names[j], 31, Noob_Names[j-1])
2605 formatex(Noob_Date[j], 31, Noob_Date[j-1])
2606 formatex(Noob_Weapon[j], 31, Noob_Weapon[j-1])
2607 Noob_Tiempos[j] = Noob_Tiempos[j-1]
2608 Noob_CheckPoints[j] = Noob_CheckPoints[j-1]
2609 Noob_GoChecks[j] = Noob_GoChecks[j-1]
2610 }
2611
2612 formatex(Noob_AuthIDS[i], 31, authid);
2613 formatex(Noob_Names[i], 31, name);
2614 formatex(Noob_Date[i], 31, thetime)
2615 formatex(Noob_Weapon[i], 31, g_weaponsnames[wpn])
2616 Noob_Tiempos[i] = time
2617 Noob_CheckPoints[i] = checkpoints
2618 Noob_GoChecks[i] = gochecks
2619
2620 save_Noob15()
2621
2622 if( Is_in_noob15 )
2623 {
2624
2625 if( time < noobtiempo )
2626 {
2627 new min, Float:sec;
2628 min = floatround(faster, floatround_floor)/60;
2629 sec = faster - (60*min);
2630 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_IMPROVE", min, sec < 10 ? "0" : "", sec);
2631
2632 if( (i + 1) == 1)
2633 {
2634 client_cmd(0, "spk woop");
2635 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2636 }
2637 else
2638 {
2639 client_cmd(0, "spk buttons/bell1");
2640 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2641 }
2642 }
2643 }
2644 else
2645 {
2646 if( (i + 1) == 1)
2647 {
2648 client_cmd(0, "spk woop");
2649 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2650 }
2651 else
2652 {
2653 client_cmd(0, "spk buttons/bell1");
2654 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2655 }
2656 }
2657 return;
2658 }
2659
2660 if( (equali(Noob_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Noob_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2661 {
2662 if( time > noobtiempo )
2663 {
2664
2665 new min, Float:sec;
2666 min = floatround(slower, floatround_floor)/60;
2667 sec = slower - (60*min);
2668 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_SLOWER", min, sec < 10 ? "0" : "", sec);
2669 return;
2670 }
2671 }
2672
2673 }
2674}
2675
2676public save_Noob15()
2677{
2678 new profile[128]
2679 formatex(profile, 127, "%s/Noob_%s.cfg", Topdir, MapName)
2680
2681 if( file_exists(profile) )
2682 {
2683 delete_file(profile)
2684 }
2685
2686 new Data[256];
2687 new f = fopen(profile, "at")
2688
2689 for(new i = 0; i < 15; i++)
2690 {
2691 formatex(Data, 255, "^"%.2f^" ^"%s^" ^"%s^" ^"%i^" ^"%i^" ^"%s^" ^"%s^" ^n", Noob_Tiempos[i], Noob_AuthIDS[i], Noob_Names[i], Noob_CheckPoints[i], Noob_GoChecks[i],Noob_Date[i],Noob_Weapon[i])
2692 fputs(f, Data)
2693 }
2694 fclose(f);
2695}
2696
2697public read_Noob15()
2698{
2699 new profile[128], prodata[256]
2700 formatex(profile, 127, "%s/Noob_%s.cfg", Topdir, MapName)
2701
2702 new f = fopen(profile, "rt" )
2703 new i = 0
2704 while( !feof(f) && i < 16)
2705 {
2706 fgets(f, prodata, 255)
2707 new totime[25], checks[5], gochecks[5]
2708 parse(prodata, totime, 24, Noob_AuthIDS[i], 31, Noob_Names[i], 31, checks, 4, gochecks, 4, Noob_Date[i], 31, Noob_Weapon[i], 31)
2709 Noob_Tiempos[i] = str_to_float(totime)
2710 Noob_CheckPoints[i] = str_to_num(checks)
2711 Noob_GoChecks[i] = str_to_num(gochecks)
2712 i++;
2713 }
2714 fclose(f)
2715}
2716
2717public ProTop_show(id)
2718{
2719 new buffer[2048], len, name[32]
2720
2721 len = formatex(buffer, 2047, "<body bgcolor=#3399FF><table width=100%% cellpadding=2 cellspacing=0 border=0>")
2722 len += formatex(buffer[len], 2047-len, "<tr align=center bgcolor=#0052FF><th width=5%%> # <th width=45%% align=center> Player <th width=30%%> Time <th width=20%%> Date ")
2723
2724 for (new i = 0; i < 10; i++)
2725 {
2726 name = Pro_Names[i]
2727
2728 if( Pro_Times[i] > 9999999.0 )
2729 {
2730 len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s <td> %s <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), "", "", "")
2731 }
2732
2733 else
2734 {
2735 new minutos, Float:segundos
2736 minutos = floatround(Pro_Times[i], floatround_floor)/60
2737 segundos = Pro_Times[i] - (60*minutos)
2738
2739 len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s <td> <b>%02d:%s%.2f <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), Pro_Names[i], minutos, segundos < 10 ? "0" : "", segundos, Pro_Date[i])
2740
2741 }
2742 }
2743
2744 len += formatex(buffer[len], 2047-len, "</table></body>")
2745 len += formatex(buffer[len], 2047-len, "<tr><Center><b><BR>Plugin created by nucLeaR")
2746
2747 show_motd(id, buffer, "Pro10 Climbers")
2748
2749 return PLUGIN_HANDLED
2750}
2751
2752public NoobTop_show(id)
2753{
2754 new buffer[2048], name[32], len
2755
2756 len = formatex(buffer, 2047, "<body bgcolor=#3399FF><table width=100%% cellpadding=2 cellspacing=0 border=0>")
2757 len += formatex(buffer[len], 2047-len, "<tr align=center bgcolor=#0052FF><th width=5%%> # <th width=35%% align=center> Player <th width=20%%> Time <th width=10%%> CPs <th width=10%%> TPs <th width=10%%> Date")
2758
2759 for (new i = 0; i < 10; i++)
2760 {
2761 if( Noob_Tiempos[i] > 9999999.0 )
2762 {
2763 len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s <td> %s <td> %s <td> %s <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), "", "", "", "", "")
2764 }
2765
2766 else
2767 {
2768 name = Noob_Names[i]
2769 new minutos, Float:segundos
2770 minutos = floatround(Noob_Tiempos[i], floatround_floor)/60
2771 segundos = Noob_Tiempos[i] - (60*minutos)
2772
2773 len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s%s <td> <b>%02d:%s%.2f <td> %d <td> %d <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), Noob_Names[i], equal(Noob_Weapon[i],"scout") ? "(scout)" : "", minutos, segundos < 10 ? "0" : "", segundos, Noob_CheckPoints[i], Noob_GoChecks[i], Noob_Date[i], Noob_Weapon[i])
2774 }
2775 }
2776
2777 len += formatex(buffer[len], 2047-len, "</table></body>")
2778 len += formatex(buffer[len], 2047-len, "<tr><Center><b><BR>Plugin created by nucLeaR")
2779
2780 show_motd(id, buffer, "Noob10 Climbers")
2781
2782 return PLUGIN_HANDLED
2783}
2784#endif
2785
2786// You reached the end of file
2787// The original plugin was made by p4ddY
2788// This plugin was edited by nucLeaR
2789// Version 2.31