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