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