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