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