· 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
1159 if( !is_user_alive( id ) )
1160 {
1161 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1162 return PLUGIN_HANDLED
1163 }
1164
1165 if(get_pcvar_num(kz_checkpoints) == 0)
1166 {
1167 kz_chat(id, "%L", id, "KZ_CHECKPOINT_OFF")
1168 return PLUGIN_HANDLED
1169 }
1170
1171 if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) && !IsOnLadder(id))
1172 {
1173 kz_chat(id, "%L", id, "KZ_CHECKPOINT_AIR")
1174 return PLUGIN_HANDLED
1175 }
1176
1177 if( IsPaused[id] )
1178 {
1179 kz_chat(id, "%L", id, "KZ_CHECKPOINT_PAUSE")
1180 return PLUGIN_HANDLED
1181 }
1182
1183 pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id] ? 1 : 0])
1184 g_bCpAlternate[id] = !g_bCpAlternate[id]
1185 checknumbers[id]++
1186
1187 kz_chat(id, "%L", id, "KZ_CHECKPOINT", checknumbers[id])
1188
1189 return PLUGIN_HANDLED
1190}
1191
1192public GoCheck(id)
1193{
1194 if( !is_user_alive( id ) )
1195 {
1196 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1197 return PLUGIN_HANDLED
1198 }
1199
1200 if( checknumbers[id] == 0 )
1201 {
1202 kz_chat(id, "%L", id, "KZ_NOT_ENOUGH_CHECKPOINTS")
1203 return PLUGIN_HANDLED
1204 }
1205
1206 if( IsPaused[id] )
1207 {
1208 kz_chat(id, "%L", id, "KZ_TELEPORT_PAUSE")
1209 return PLUGIN_HANDLED
1210 }
1211
1212 set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} );
1213 set_pev( id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 } );
1214 set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING );
1215 set_pev( id, pev_fuser2, 0.0 );
1216 engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 } );
1217 set_pev(id, pev_origin, Checkpoints[ id ][ !g_bCpAlternate[id] ] )
1218 gochecknumbers[id]++
1219
1220 kz_chat(id, "%L", id, "KZ_GOCHECK", gochecknumbers[id])
1221
1222 return PLUGIN_HANDLED
1223}
1224
1225public Stuck(id)
1226{
1227 if( !is_user_alive( id ) )
1228 {
1229 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1230 return PLUGIN_HANDLED
1231 }
1232
1233 if( checknumbers[id] < 2 )
1234 {
1235 kz_chat(id, "%L", id, "KZ_NOT_ENOUGH_CHECKPOINTS")
1236 return PLUGIN_HANDLED
1237 }
1238
1239 set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} )
1240 set_pev( id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
1241 set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
1242 set_pev( id, pev_fuser2, 0.0 )
1243 engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 } )
1244 set_pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id]] )
1245 g_bCpAlternate[id] = !g_bCpAlternate[id];
1246 gochecknumbers[id]++
1247
1248 kz_chat(id, "%L", id, "KZ_GOCHECK", gochecknumbers[id])
1249
1250 return PLUGIN_HANDLED;
1251}
1252
1253// =================================================================================================
1254
1255public reset_checkpoints(id)
1256{
1257 checknumbers[id] = 0
1258 gochecknumbers[id] = 0
1259 timer_started[id] = false
1260 timer_time[id] = 0.0
1261 user_has_scout[id] = false
1262 if(IsPaused[id])
1263 {
1264 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1265 IsPaused[id] = false
1266 }
1267 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
1268 kz_showtime_roundtime(id, 0)
1269
1270 return PLUGIN_HANDLED
1271}
1272
1273//===== Invis =======
1274
1275public cmdInvisible(id)
1276{
1277
1278 gViewInvisible[id] = !gViewInvisible[id]
1279 if(gViewInvisible[id])
1280 kz_chat(id, "%L", id, "KZ_INVISIBLE_PLAYERS_ON")
1281 else
1282 kz_chat(id, "%L", id, "KZ_INVISIBLE_PLAYERS_OFF")
1283
1284 return PLUGIN_HANDLED
1285}
1286
1287public cmdWaterInvisible(id)
1288{
1289 if( !gWaterFound )
1290 {
1291 kz_chat(id, "%L", id, "KZ_INVISIBLE_NOWATER")
1292 return PLUGIN_HANDLED
1293 }
1294
1295 gWaterInvisible[id] = !gWaterInvisible[id]
1296 if(gWaterInvisible[id])
1297 kz_chat(id, "%L", id, "KZ_INVISIBLE_WATER_ON")
1298 else
1299 kz_chat(id, "%L", id, "KZ_INVISIBLE_WATER_OFF")
1300
1301 return PLUGIN_HANDLED
1302}
1303
1304//======================Semiclip / Invis==========================
1305
1306public FM_client_AddToFullPack_Post(es, e, ent, host, hostflags, player, pSet)
1307{
1308 if( player )
1309 {
1310 if (get_pcvar_num(kz_semiclip) == 1)
1311 {
1312 if ( host != ent && get_orig_retval() && is_user_alive(host) )
1313 {
1314 set_es(es, ES_Solid, SOLID_NOT)
1315 set_es(es, ES_RenderMode, kRenderTransAlpha)
1316 set_es(es, ES_RenderAmt, get_pcvar_num(kz_semiclip_transparency))
1317 }
1318 }
1319 if(gMarkedInvisible[ent] && gViewInvisible[host])
1320 {
1321 set_es(es, ES_RenderMode, kRenderTransTexture)
1322 set_es(es, ES_RenderAmt, 0)
1323 set_es(es, ES_Origin, { 999999999.0, 999999999.0, 999999999.0 } )
1324 }
1325 }
1326 else if( gWaterInvisible[host] && gWaterEntity[ent] )
1327 {
1328 set_es(es, ES_Effects, get_es( es, ES_Effects ) | EF_NODRAW )
1329 }
1330
1331 return FMRES_IGNORED
1332}
1333
1334public Ham_CBasePlayer_PreThink_Post(id)
1335{
1336 if( !is_user_alive(id) )
1337 {
1338 return
1339 }
1340
1341 RefreshPlayersList()
1342
1343 if (get_pcvar_num(kz_semiclip) == 1)
1344 {
1345 for(new i = 0; i<g_iNum; i++)
1346 {
1347 g_iPlayer = g_iPlayers[i]
1348 if( id != g_iPlayer )
1349 {
1350 set_pev(g_iPlayer, pev_solid, SOLID_NOT)
1351 }
1352 }
1353 }
1354}
1355
1356public client_PostThink(id)
1357{
1358 if( !is_user_alive(id) )
1359 return
1360
1361 RefreshPlayersList()
1362
1363 if (get_pcvar_num(kz_semiclip) == 1)
1364 for(new i = 0; i<g_iNum; i++)
1365 {
1366 g_iPlayer = g_iPlayers[i]
1367 if( g_iPlayer != id )
1368 set_pev(g_iPlayer, pev_solid, SOLID_SLIDEBOX)
1369 }
1370}
1371
1372public noclip(id)
1373{
1374 if(!is_user_alive(id))
1375 {
1376 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1377 return PLUGIN_HANDLED
1378 }
1379 new noclip = !get_user_noclip(id)
1380 set_user_noclip(id, noclip)
1381 if(IsPaused[id] && (get_pcvar_num(kz_noclip_pause) == 1))
1382 {
1383 if(noclip)
1384 {
1385 pev(id, pev_origin, NoclipPos[id])
1386 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1387 }
1388 else
1389 {
1390 set_pev(id, pev_origin, NoclipPos[id])
1391 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
1392 }
1393 }
1394 else if(noclip)
1395 detect_cheat(id,"Noclip")
1396 kz_chat(id, "%L", id, "KZ_NOCLIP" , noclip ? "ON" : "OFF")
1397
1398 return PLUGIN_HANDLED
1399}
1400
1401public GodMode(id)
1402{
1403 if(!is_user_alive(id))
1404 {
1405 kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
1406 return PLUGIN_HANDLED
1407 }
1408
1409 new godmode = !get_user_godmode(id)
1410 set_user_godmode(id, godmode)
1411 if(godmode)
1412 detect_cheat(id,"God Mode")
1413 kz_chat(id, "%L", id, "KZ_GODMODE" , godmode ? "ON" : "OFF")
1414
1415 return PLUGIN_HANDLED
1416}
1417
1418// =================================================================================================
1419
1420
1421stock kz_set_start(const map[], Float:origin[3])
1422{
1423 new realfile[128], tempfile[128], formatorigin[50]
1424 formatex(realfile, 127, "%s/%s", Kzdir, KZ_STARTFILE)
1425 formatex(tempfile, 127, "%s/%s", Kzdir, KZ_STARTFILE_TEMP)
1426 formatex(formatorigin, 49, "%f %f %f", origin[0], origin[1], origin[2])
1427
1428 DefaultStartPos = origin
1429 DefaultStart = true
1430
1431 new file = fopen(tempfile, "wt")
1432 new vault = fopen(realfile, "rt")
1433
1434 new data[128], key[64]
1435 new bool:replaced = false
1436
1437 while( !feof(vault) )
1438 {
1439 fgets(vault, data, 127)
1440 parse(data, key, 63)
1441
1442 if( equal(key, map) && !replaced )
1443 {
1444 fprintf(file, "%s %s^n", map, formatorigin)
1445
1446 replaced = true
1447 }
1448 else
1449 {
1450 fputs(file, data)
1451 }
1452 }
1453
1454 if( !replaced )
1455 {
1456 fprintf(file, "%s %s^n", map, formatorigin)
1457 }
1458
1459 fclose(file)
1460 fclose(vault)
1461
1462 delete_file(realfile)
1463 while( !rename_file(tempfile, realfile, 1) ) {}
1464}
1465
1466stock kz_showtime_roundtime(id, time)
1467{
1468 if( is_user_connected(id) )
1469 {
1470 message_begin(MSG, get_user_msgid( "RoundTime" ), _, id);
1471 write_short(time + 1);
1472 message_end();
1473 }
1474}
1475
1476stock kz_chat(id, const message[], {Float,Sql,Result,_}:...)
1477{
1478 new cvar = get_pcvar_num(kz_chatorhud)
1479 if(cvar == 0)
1480 return PLUGIN_HANDLED
1481
1482 new msg[180], final[192]
1483 if (cvar == 1 && chatorhud[id] == -1 || chatorhud[id] == 1)
1484 {
1485 vformat(msg, 179, message, 3)
1486 formatex(final, 191, "%s^x01 %s", prefix, msg)
1487 kz_remplace_colors(final, 191)
1488 ColorChat(id, GREEN, "%s", final)
1489 }
1490 else if( cvar == 2 && chatorhud[id] == -1 || chatorhud[id] == 2)
1491 {
1492 vformat(msg, 179, message, 3)
1493 replace_all(msg, 191, "^x01", "")
1494 replace_all(msg, 191, "^x03", "")
1495 replace_all(msg, 191, "^x04", "")
1496 replace_all(msg, 191, ".", "")
1497 kz_hud_message(id, "%s", msg)
1498 }
1499
1500 return 1
1501}
1502
1503stock kz_print_config(id, const msg[])
1504{
1505 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, id);
1506 write_byte(id);
1507 write_string(msg);
1508 message_end();
1509}
1510
1511stock kz_remplace_colors(message[], len)
1512{
1513 replace_all(message, len, "!g", "^x04")
1514 replace_all(message, len, "!t", "^x03")
1515 replace_all(message, len, "!y", "^x01")
1516}
1517
1518stock kz_hud_message(id, const message[], {Float,Sql,Result,_}:...)
1519{
1520 static msg[192], colors[12], r[4], g[4], b[4];
1521 vformat(msg, 191, message, 3);
1522
1523 get_pcvar_string(kz_hud_color, colors, 11)
1524 parse(colors, r, 3, g, 3, b, 4)
1525
1526 set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), -1.0, 0.90, 0, 0.0, 2.0, 0.0, 1.0, -1);
1527 ShowSyncHudMsg(id, hud_message, msg);
1528}
1529
1530stock kz_register_saycmd(const saycommand[], const function[], flags)
1531{
1532 new temp[64]
1533 formatex(temp, 63, "say /%s", saycommand)
1534 register_clcmd(temp, function, flags)
1535 formatex(temp, 63, "say .%s", saycommand)
1536 register_clcmd(temp, function, flags)
1537 formatex(temp, 63, "say_team /%s", saycommand)
1538 register_clcmd(temp, function, flags)
1539 formatex(temp, 63, "say_team .%s", saycommand)
1540 register_clcmd(temp, function, flags)
1541}
1542
1543stock get_configsdir(name[],len)
1544{
1545 return get_localinfo("amxx_configsdir",name,len);
1546}
1547
1548#if defined USE_SQL
1549stock GetNewRank(id, type)
1550{
1551 new createinto[1001]
1552
1553 new cData[2]
1554 cData[0] = id
1555 cData[1] = type
1556
1557 formatex(createinto, 1000, "SELECT authid FROM `%s` WHERE mapname='%s' ORDER BY time LIMIT 15", type == PRO_TOP ? "kz_pro15" : "kz_nub15", MapName)
1558 SQL_ThreadQuery(g_SqlTuple, "GetNewRank_QueryHandler", createinto, cData, 2)
1559}
1560
1561stock kz_update_plrname(id)
1562{
1563 new createinto[1001], authid[32], name[32]
1564 get_user_authid(id, authid, 31)
1565 get_user_name(id, name, 31)
1566
1567 replace_all(name, 31, "\", "")
1568 replace_all(name, 31, "`", "")
1569 replace_all(name, 31, "'", "")
1570
1571 if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
1572 return 0;
1573 else
1574 {
1575 formatex(createinto, 1000, "UPDATE `kz_pro15` SET name='%s' WHERE authid='%s'", name, authid)
1576 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
1577 formatex(createinto, 1000, "UPDATE `kz_nub15` SET name='%s' WHERE authid='%s'", name, authid)
1578 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
1579 }
1580 return 1
1581}
1582#endif
1583
1584public FwdSpawnWeaponbox( iEntity )
1585{
1586 if(get_pcvar_num(kz_remove_drops) == 1)
1587 {
1588 set_pev( iEntity, pev_flags, FL_KILLME )
1589 dllfunc( DLLFunc_Think, iEntity )
1590 }
1591
1592 return HAM_IGNORED
1593}
1594
1595public FwdHamDoorSpawn( iEntity )
1596{
1597 static const szNull[ ] = "common/null.wav";
1598
1599 new Float:flDamage;
1600 pev( iEntity, pev_dmg, flDamage );
1601
1602 if( flDamage < -999.0 ) {
1603 set_pev( iEntity, pev_noise1, szNull );
1604 set_pev( iEntity, pev_noise2, szNull );
1605 set_pev( iEntity, pev_noise3, szNull );
1606
1607 if( !HealsOnMap )
1608 HealsOnMap = true
1609 }
1610}
1611
1612public FwdHamPlayerSpawn( id )
1613{
1614
1615 if( !is_user_alive( id ) )
1616 return;
1617
1618 if(firstspawn[id])
1619 {
1620 ColorChat(id, GREEN, "%s^x01 IP:^x04 85.217.196.76:27030", prefix)
1621
1622 if(get_pcvar_num(kz_checkpoints) == 0)
1623 ColorChat(id, GREEN, "%s^x01 %L", id, "KZ_CHECKPOINT_OFF", prefix)
1624
1625
1626 if(Verif(id,1) && get_pcvar_num(kz_save_pos) == 1)
1627 savepos_menu(id)
1628 else if(get_pcvar_num(kz_spawn_mainmenu) == 1)
1629 kz_menu (id)
1630 }
1631 firstspawn[id] = false
1632
1633
1634 if( !user_has_weapon(id,CSW_KNIFE) )
1635 give_item( id,"weapon_knife" )
1636
1637 if( HealsOnMap )
1638 set_user_health(id, 50175)
1639
1640 if( IsPaused[id] )
1641 {
1642 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
1643 set_pev(id, pev_origin, PauseOrigin[id])
1644 }
1645
1646 if(get_pcvar_num(kz_use_radio) == 0)
1647 {
1648 #define XO_PLAYER 5
1649 #define m_iRadiosLeft 192
1650 set_pdata_int(id, m_iRadiosLeft, 0, XO_PLAYER)
1651 }
1652}
1653
1654public GroundWeapon_Touch(iWeapon, id)
1655{
1656 if( is_user_alive(id) && timer_started[id] && get_pcvar_num(kz_pick_weapons) == 0 )
1657 return HAM_SUPERCEDE
1658
1659 return HAM_IGNORED
1660}
1661
1662
1663
1664// ==================================Save positions=================================================
1665
1666public SavePos(id)
1667{
1668
1669 new authid[33];
1670 get_user_authid(id, authid, 32)
1671 if(get_pcvar_num(kz_save_pos) == 0)
1672 {
1673 kz_chat(id, "%L", id, "KZ_SAVEPOS_DISABLED")
1674 return PLUGIN_HANDLED
1675 }
1676
1677 if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
1678 {
1679 ColorChat (id, GREEN, "%s^x01 %L", prefix, id, "KZ_NO_STEAM")
1680
1681 return PLUGIN_HANDLED
1682 }
1683
1684 if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) )
1685 {
1686 kz_chat(id, "%L", id, "KZ_NOT_ON_GROUND")
1687
1688 return PLUGIN_HANDLED
1689 }
1690
1691 if(!timer_started[id])
1692 {
1693 kz_chat(id, "%L", id, "KZ_TIMER_NOT_STARTED")
1694 return PLUGIN_HANDLED
1695 }
1696
1697 if(Verif(id,1))
1698 {
1699 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_ALREADY")
1700 savepos_menu(id)
1701 return PLUGIN_HANDLED
1702 }
1703
1704 if(get_user_noclip(id))
1705 {
1706 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_NOCLIP")
1707 return PLUGIN_HANDLED
1708 }
1709
1710 new Float:origin[3], scout
1711 pev(id, pev_origin, origin)
1712 new Float:Time,check,gocheck
1713 if(IsPaused[id])
1714 {
1715 Time = g_pausetime[id]
1716 Pause(id)
1717 }
1718 else
1719 Time=get_gametime() - timer_time[id]
1720 check=checknumbers[id]
1721 gocheck=gochecknumbers[id]
1722 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS")
1723 if (user_has_scout[id])
1724 scout=1
1725 else
1726 scout=0
1727 kz_savepos(id, Time, check, gocheck, origin, scout)
1728 reset_checkpoints(id)
1729
1730 return PLUGIN_HANDLED
1731}
1732
1733public GoPos(id)
1734{
1735 remove_hook(id)
1736 set_user_godmode(id, 0)
1737 set_user_noclip(id, 0)
1738 if(Verif(id,0))
1739 {
1740 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1741 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
1742 set_pev(id, pev_origin, SavedOrigins[id] )
1743 }
1744
1745 checknumbers[id]=SavedChecks[id]
1746 gochecknumbers[id]=SavedGoChecks[id]+((get_pcvar_num(kz_save_pos_gochecks)>0) ? 1 : 0)
1747 CheckPoint(id)
1748 CheckPoint(id)
1749 strip_user_weapons(id)
1750 give_item(id,"weapon_usp")
1751 give_item(id,"weapon_knife")
1752 if(SavedScout[id])
1753 {
1754 give_item(id, "weapon_scout")
1755 user_has_scout[id] = true
1756 }
1757 timer_time[id]=get_gametime()-SavedTime[id]
1758 timer_started[id]=true
1759 Pause(id)
1760
1761}
1762
1763public Verif(id, action)
1764{
1765 new realfile[128], tempfile[128], authid[32], map[64]
1766 new bool:exist = false
1767 get_mapname(map, 63)
1768 get_user_authid(id, authid, 31)
1769 formatex(realfile, 127, "%s/%s.ini", SavePosDir, map)
1770 formatex(tempfile, 127, "%s/temp.ini", SavePosDir)
1771
1772 if( !file_exists(realfile) )
1773 return 0
1774
1775 new file = fopen(tempfile, "wt")
1776 new vault = fopen(realfile, "rt")
1777 new data[150], sid[32], time[25], checks[5], gochecks[5], x[25], y[25], z[25], scout[5]
1778 while( !feof(vault) )
1779 {
1780 fgets(vault, data, 149)
1781 parse(data, sid, 31, time, 24, checks, 4, gochecks, 4, x, 24, y, 24, z, 24, scout, 4)
1782
1783 if( equal(sid, authid) && !exist) // ma aflu in fisier?
1784 {
1785 if(action == 1)
1786 fputs(file, data)
1787 exist= true
1788 SavedChecks[id] = str_to_num(checks)
1789 SavedGoChecks[id] = str_to_num(gochecks)
1790 SavedTime[id] = str_to_float(time)
1791 SavedOrigins[id][0]=str_to_num(x)
1792 SavedOrigins[id][1]=str_to_num(y)
1793 SavedOrigins[id][2]=str_to_num(z)
1794 SavedScout[id] = str_to_num(scout)
1795 }
1796 else
1797 {
1798 fputs(file, data)
1799 }
1800 }
1801
1802 fclose(file)
1803 fclose(vault)
1804
1805 delete_file(realfile)
1806 if(file_size(tempfile) == 0)
1807 delete_file(tempfile)
1808 else
1809 while( !rename_file(tempfile, realfile, 1) ) {}
1810
1811
1812 if(!exist)
1813 return 0
1814
1815 return 1
1816}
1817public kz_savepos (id, Float:time, checkpoints, gochecks, Float:origin[3], scout)
1818{
1819 new realfile[128], formatorigin[128], map[64], authid[32]
1820 get_mapname(map, 63)
1821 get_user_authid(id, authid, 31)
1822 formatex(realfile, 127, "%s/%s.ini", SavePosDir, map)
1823 formatex(formatorigin, 127, "%s %f %d %d %d %d %d %d", authid, time, checkpoints, gochecks, origin[0], origin[1], origin[2], scout)
1824
1825 new vault = fopen(realfile, "rt+")
1826 write_file(realfile, formatorigin) // La sfarsit adaug datele mele
1827
1828 fclose(vault)
1829
1830}
1831
1832// =================================================================================================
1833// Events / Forwards
1834// =================================================================================================
1835
1836//=================================================================================================
1837
1838public client_disconnect(id)
1839{
1840 checknumbers[id] = 0
1841 gochecknumbers[id] = 0
1842 antihookcheat[id] = 0.0
1843 chatorhud[id] = -1
1844 timer_started[id] = false
1845 ShowTime[id] = get_pcvar_num(kz_show_timer)
1846 firstspawn[id] = true
1847 NightVisionUse[id] = false
1848 IsPaused[id] = false
1849 WasPaused[id] = false
1850 user_has_scout[id] = false
1851 remove_hook(id)
1852}
1853
1854public client_putinserver(id)
1855{
1856 checknumbers[id] = 0
1857 gochecknumbers[id] = 0
1858 antihookcheat[id] = 0.0
1859 chatorhud[id] = -1
1860 timer_started[id] = false
1861 ShowTime[id] = get_pcvar_num(kz_show_timer)
1862 firstspawn[id] = true
1863 NightVisionUse[id] = false
1864 IsPaused[id] = false
1865 WasPaused[id] = false
1866 user_has_scout[id] = false
1867 remove_hook(id)
1868}
1869
1870// =================================================================================================
1871// Menu
1872// =================================================================================================
1873
1874
1875public kz_menu(id)
1876{
1877 new title[64];
1878 formatex(title, 63, "\yMenu\w")
1879 new menu = menu_create(title, "MenuHandler")
1880
1881 new msgcheck[64], msggocheck[64], msgpause[64]
1882 formatex(msgcheck, 63, "Checkpoint - \y#%i", checknumbers[id])
1883 formatex(msggocheck, 63, "Gocheck - \y#%i", gochecknumbers[id])
1884 formatex(msgpause, 63, "Pause - %s^n", IsPaused[id] ? "\yON" : "\rOFF" )
1885
1886 menu_additem( menu, msgcheck, "1" )
1887 menu_additem( menu, msggocheck, "2" )
1888 menu_additem( menu, "Top 15^n", "3")
1889 menu_additem( menu, "Start", "4")
1890 menu_additem( menu, "Timer Menu", "5" )
1891 menu_additem( menu, msgpause, "6" )
1892 menu_additem( menu, "Invisible Menu", "7" )
1893 menu_additem( menu, "Spectator/CT", "8" )
1894 menu_additem( menu, "Reset Time^n", "9")
1895 menu_additem( menu, "Exit", "MENU_EXIT" )
1896
1897 menu_setprop(menu, MPROP_PERPAGE, 0)
1898 menu_display(id, menu, 0)
1899 return PLUGIN_HANDLED
1900}
1901
1902public MenuHandler(id , menu, item)
1903{
1904 if( item == MENU_EXIT ) {
1905 menu_destroy(menu)
1906 return PLUGIN_HANDLED
1907 }
1908
1909
1910 switch(item) {
1911 case 0:{
1912 CheckPoint(id)
1913 kz_menu(id)
1914 }
1915 case 1:{
1916 GoCheck(id)
1917 kz_menu(id)
1918 }
1919 case 2:{
1920 top15menu(id)
1921 }
1922 case 3:{
1923 goStart(id)
1924 kz_menu(id)
1925 }
1926 case 4:{
1927 ShowTimer_Menu(id)
1928 }
1929 case 5:{
1930 Pause(id)
1931 kz_menu(id)
1932 }
1933 case 6:{
1934 InvisMenu(id)
1935 }
1936 case 7:{
1937 ct(id)
1938 }
1939 case 8:{
1940 reset_checkpoints(id)
1941 kz_menu(id)
1942 }
1943 }
1944
1945 return PLUGIN_HANDLED
1946}
1947
1948public InvisMenu(id)
1949{
1950 new menu = menu_create("\yInvis Menu\w", "InvisMenuHandler")
1951 new msginvis[64], msgwaterinvis[64]
1952
1953 formatex(msginvis, 63, "Players - %s", gViewInvisible[id] ? "\yON" : "\rOFF" )
1954 formatex(msgwaterinvis, 63, "Water - %s^n^n", gWaterInvisible[id] ? "\yON" : "\rOFF" )
1955
1956 menu_additem( menu, msginvis, "1" )
1957 menu_additem( menu, msgwaterinvis, "2" )
1958 menu_additem( menu, "Main Menu", "3" )
1959
1960 menu_display(id, menu, 0)
1961 return PLUGIN_HANDLED
1962}
1963
1964public InvisMenuHandler (id, menu, item)
1965{
1966 if( item == MENU_EXIT )
1967 {
1968 menu_destroy(menu)
1969 return PLUGIN_HANDLED
1970 }
1971
1972 switch(item)
1973 {
1974 case 0:
1975 {
1976 cmdInvisible(id)
1977 InvisMenu(id)
1978 }
1979 case 1:
1980 {
1981 cmdWaterInvisible(id)
1982 InvisMenu(id)
1983 }
1984 case 2:
1985 {
1986 kz_menu(id)
1987 }
1988 }
1989 return PLUGIN_HANDLED
1990}
1991
1992public ShowTimer_Menu(id)
1993{
1994 if (get_pcvar_num(kz_show_timer) == 0 )
1995 {
1996 kz_chat(id, "%L", id, "KZ_TIMER_DISABLED")
1997 return PLUGIN_HANDLED
1998 }
1999 else
2000 {
2001 new menu = menu_create("\yTimer Menu\w", "TimerHandler")
2002
2003 new roundtimer[64], hudtimer[64], notimer[64];
2004
2005 formatex(roundtimer, 63, "Round Timer %s", ShowTime[id] == 2 ? "\y x" : "" )
2006 formatex(hudtimer, 63, "HUD Timer %s", ShowTime[id] == 1 ? "\y x" : "" )
2007 formatex(notimer, 63, "No Timer %s^n", ShowTime[id] == 0 ? "\y x" : "" )
2008
2009 menu_additem( menu, roundtimer, "1" )
2010 menu_additem( menu, hudtimer, "2" )
2011 menu_additem( menu, notimer, "3" )
2012 menu_additem( menu, "Main Menu", "4" )
2013
2014 menu_display(id, menu, 0)
2015 return PLUGIN_HANDLED
2016 }
2017
2018 return PLUGIN_HANDLED
2019}
2020
2021public TimerHandler (id, menu, item)
2022{
2023 if( item == MENU_EXIT )
2024 {
2025 menu_destroy(menu)
2026 return PLUGIN_HANDLED
2027 }
2028
2029 switch(item)
2030 {
2031
2032 case 0:
2033 {
2034 ShowTime[id]= 2
2035 ShowTimer_Menu(id)
2036 }
2037 case 1:
2038 {
2039 ShowTime[id]= 1
2040 ShowTimer_Menu(id)
2041 if (timer_started[id])
2042 kz_showtime_roundtime(id, 0)
2043 }
2044 case 2:
2045 {
2046 ShowTime[id]= 0
2047 ShowTimer_Menu(id)
2048 if (timer_started[id])
2049 kz_showtime_roundtime(id, 0)
2050 }
2051 case 3:
2052 {
2053 kz_menu(id)
2054 }
2055 }
2056 return PLUGIN_HANDLED
2057}
2058
2059public savepos_menu(id)
2060{
2061 new menu = menu_create("SavePos Menu", "SavePosHandler")
2062
2063 menu_additem( menu, "Reload previous run", "1" )
2064 menu_additem( menu, "Start a new run", "2" )
2065
2066 menu_display(id, menu, 0)
2067 return PLUGIN_HANDLED
2068}
2069
2070public SavePosHandler(id, menu, item)
2071{
2072
2073 switch(item)
2074 {
2075 case 0:
2076 {
2077 GoPos(id)
2078 }
2079 case 1:
2080 {
2081 Verif(id,0)
2082 }
2083 }
2084 return PLUGIN_HANDLED
2085}
2086
2087public top15menu(id)
2088{
2089 new menu = menu_create("\rProKreedz \yTop15 \w", "top15handler")
2090 menu_additem(menu, "\wPro 15", "1", 0)
2091 menu_additem(menu, "\wNoob 15^n^n", "2", 0)
2092 #if defined USE_SQL
2093 menu_additem(menu, "Pro Records","3")
2094 menu_additem(menu, "Players Rankings^n","4")
2095 menu_additem(menu, "Last 10 Pro Entries", "5")
2096 menu_additem(menu, "Maps Statistic","6")
2097 menu_additem(menu, "Main Menu", "7")
2098 #else
2099 menu_additem(menu, "\wMain Menu", "3", 0)
2100 #endif
2101
2102 menu_display(id, menu, 0);
2103
2104 return PLUGIN_HANDLED;
2105}
2106
2107public top15handler(id, menu, item)
2108{
2109 if(item == MENU_EXIT)
2110 {
2111 menu_destroy(menu)
2112 return PLUGIN_HANDLED
2113 }
2114 #if defined USE_SQL
2115 switch(item)
2116 {
2117 case 0:
2118 {
2119 ProTop_show(id)
2120 }
2121 case 1:
2122 {
2123 NoobTop_show(id)
2124 }
2125 case 2:
2126 {
2127 kz_showhtml_motd(id, PRO_RECORDS, "")
2128 }
2129 case 3:
2130 {
2131 kz_showhtml_motd(id, PLAYERS_RANKING, "")
2132 }
2133 case 4:
2134 {
2135 kz_showhtml_motd(id, LAST_PRO10, "")
2136 }
2137 case 5:
2138 {
2139 kz_showhtml_motd(id, MAPS_STATISTIC, "")
2140 }
2141 case 6:
2142 {
2143 kz_menu(id)
2144 }
2145 }
2146 #else
2147 switch(item)
2148 {
2149 case 0:
2150 {
2151 ProTop_show(id)
2152 }
2153 case 1:
2154 {
2155 NoobTop_show(id)
2156 }
2157 case 2:
2158 {
2159 kz_menu(id)
2160 }
2161 }
2162 #endif
2163
2164 return PLUGIN_HANDLED;
2165}
2166
2167// =================================================================================================
2168
2169//
2170// Timersystem
2171// =================================================================================================
2172public fwdUse(ent, id)
2173{
2174 if( !ent || id > 32 )
2175 {
2176 return HAM_IGNORED;
2177 }
2178
2179 if( !is_user_alive(id) )
2180 {
2181 return HAM_IGNORED;
2182 }
2183
2184
2185 new name[32]
2186 get_user_name(id, name, 31)
2187
2188 new szTarget[ 32 ];
2189 pev(ent, pev_target, szTarget, 31);
2190
2191 if( TrieKeyExists( g_tStarts, szTarget ) )
2192 {
2193
2194 if ( get_gametime() - antihookcheat[id] < 3.0 )
2195 {
2196 kz_hud_message( id, "%L", id, "KZ_HOOK_PROTECTION" );
2197 return PLUGIN_HANDLED
2198 }
2199
2200 if(Verif(id,1))
2201 {
2202 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_SAVED")
2203 savepos_menu(id)
2204 return HAM_IGNORED
2205 }
2206
2207 if ( reset_checkpoints(id) && !timer_started[id] )
2208 {
2209 start_climb(id)
2210 new wpn=get_user_weapon(id)
2211 for(new i = 0; i < 8; i++)
2212 if( user_has_weapon(id, other_weapons[i]) )
2213 {
2214 strip_user_weapons(id)
2215 give_item(id,"weapon_knife")
2216 give_item(id,"weapon_usp")
2217 set_pdata_int(id, 382, 24, 5)
2218 if(wpn==CSW_SCOUT)
2219 {
2220 user_has_scout[id]=true
2221 give_item(id,"weapon_scout")
2222 }
2223 else
2224 user_has_scout[id]=false
2225 }
2226
2227 if( get_user_health(id) < 100 )
2228 set_user_health(id, 100)
2229
2230 pev(id, pev_origin, SavedStart[id])
2231 if(get_pcvar_num(kz_save_autostart) == 1)
2232 AutoStart[id] = true;
2233
2234 if( !DefaultStart )
2235 {
2236 kz_set_start(MapName, SavedStart[id])
2237 ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SET_START")
2238 }
2239
2240 remove_hook(id)
2241 }
2242
2243 }
2244
2245 if( TrieKeyExists( g_tStops, szTarget ) )
2246 {
2247 if( timer_started[id] )
2248 {
2249 if(get_user_noclip(id))
2250 return PLUGIN_HANDLED
2251
2252 finish_climb(id)
2253
2254 if(get_pcvar_num(kz_hook_prize) == 1 && !canusehook[id])
2255 {
2256 canusehook[id] = true
2257 ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_HOOK")
2258 }
2259 }
2260 else
2261 kz_hud_message(id, "%L", id, "KZ_TIMER_NOT_STARTED")
2262
2263 }
2264 return HAM_IGNORED
2265}
2266
2267public start_climb(id)
2268{
2269 kz_chat(id, "%L", id, "KZ_START_CLIMB")
2270
2271 if (get_pcvar_num(kz_reload_weapons) == 1)
2272 {
2273 strip_user_weapons(id)
2274 give_item(id,"weapon_knife")
2275 give_item(id,"weapon_usp")
2276 }
2277
2278 if (ShowTime[id] == 2)
2279 kz_showtime_roundtime(id, 0)
2280 set_pev(id, pev_gravity, 1.0);
2281 set_pev(id, pev_movetype, MOVETYPE_WALK)
2282 set_user_godmode(id, 0)
2283 reset_checkpoints(id)
2284 IsPaused[id] = false
2285 timer_started[id] = true
2286 timer_time[id] = get_gametime()
2287}
2288
2289public finish_climb(id)
2290{
2291 if (!is_user_alive (id))
2292 {
2293 return;
2294 }
2295
2296 if ( (get_pcvar_num(kz_top15_authid) > 1) || (get_pcvar_num(kz_top15_authid) < 0) )
2297 {
2298 ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_TOP15_DISABLED")
2299 return;
2300 }
2301
2302 #if defined USE_SQL
2303 new Float: time, wpn
2304 time = get_gametime() - timer_time[id]
2305 show_finish_message(id, time)
2306 timer_started[id] = false
2307 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
2308 kz_showtime_roundtime(id, 0)
2309 new checkpoints=checknumbers[id]
2310 new gocheck=gochecknumbers[id]
2311 if(user_has_scout[id])
2312 wpn=CSW_SCOUT
2313 else
2314 wpn=get_user_weapon( id )
2315
2316 new steam[32], name[32]
2317 get_user_name(id, name, 31)
2318 get_user_authid(id, steam, 31 )
2319 client_cmd(0, "spk buttons/bell1")
2320 new createinto[1001]
2321
2322 new cData[192]
2323 cData[0] = id
2324 formatex(cData[2], charsmax(cData)-2, "^"%f^" ^"%d^" ^"%d^" ^"%d^"", time, wpn, checkpoints ,gocheck)
2325
2326
2327 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
2328 {
2329 if (gochecknumbers[id] == 0 && !user_has_scout[id] )
2330 {
2331 cData[1] = PRO_TOP
2332 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND name='%s'", MapName, name)
2333 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2334 }
2335 if (gochecknumbers[id] > 0 || user_has_scout[id] )
2336 {
2337 cData[1] = NUB_TOP
2338 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND name='%s'", MapName, name)
2339 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2340 }
2341 } else
2342 {
2343
2344 if (gochecknumbers[id] == 0 && !user_has_scout[id] )
2345 {
2346 cData[1] = PRO_TOP
2347 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND authid='%s'", MapName, steam)
2348 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2349 }
2350 if (gochecknumbers[id] > 0 || user_has_scout[id] )
2351 {
2352 cData[1] = NUB_TOP
2353 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND authid='%s'", MapName, steam)
2354 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2355 }
2356 }
2357 #else
2358 new Float: time, authid[32]
2359 time = get_gametime() - timer_time[id]
2360 get_user_authid(id, authid, 31)
2361 show_finish_message(id, time)
2362 timer_started[id] = false
2363 if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
2364 kz_showtime_roundtime(id, 0)
2365
2366 if (gochecknumbers[id] == 0 && !user_has_scout[id] )
2367 ProTop_update(id, time)
2368 if (gochecknumbers[id] > 0 || user_has_scout[id] )
2369 NoobTop_update(id, time, checknumbers[id], gochecknumbers[id])
2370 #endif
2371 user_has_scout[id] = false
2372
2373}
2374
2375public show_finish_message(id, Float:kreedztime)
2376{
2377 new name[32]
2378 new imin,isec,ims, wpn
2379 if(user_has_scout[id])
2380 wpn=CSW_SCOUT
2381 else
2382 wpn=get_user_weapon( id )
2383 get_user_name(id, name, 31)
2384 imin = floatround(kreedztime / 60.0, floatround_floor)
2385 isec = floatround(kreedztime - imin * 60.0,floatround_floor)
2386 ims = floatround( ( kreedztime - ( imin * 60.0 + isec ) ) * 100.0, floatround_floor )
2387
2388 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x04 %02i:%02i.%02i ^x03(^x01 CPs: ^x04%d^x03 | ^x01 TPs: ^x04%d^x03 | ^x01 %L: ^x04%s^x03) ^x01 !", prefix, name, LANG_PLAYER, "KZ_FINISH_MSG", imin, isec, ims, checknumbers[id], gochecknumbers[id], LANG_PLAYER, "KZ_WEAPON", g_weaponsnames[wpn])
2389}
2390
2391//==========================================================
2392#if defined USE_SQL
2393public Set_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
2394{
2395 new id = cData[0]
2396 new style = cData[1]
2397 if( iFailState != TQUERY_SUCCESS )
2398 {
2399 log_amx("[KZ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
2400 ColorChat(0, GREEN, "%s^x01 %F", prefix, LANG_PLAYER, "KZ_TOP15_SQL_ERROR")
2401 }
2402
2403 server_print("[KZ] Server Geting Info of SQL Server")
2404
2405 new createinto[1001]
2406 new x1[16], x2[4], x3[5], x4[5]
2407 parse(cData[2], x1, 15, x2, 3, x3, 4, x4, 4)
2408
2409 new dia[64], steam[32], name[32], ip[15], country[3], checkpoints[32], gochecks[32]
2410 new Float:newtime = str_to_float(x1)
2411 new iMin, iSec, iMs, server[64]
2412 get_pcvar_string(kz_sql_name, server, 63)
2413 get_time("%Y%m%d%H%M%S", dia, sizeof dia - 1)
2414 get_user_authid(id, steam, 31)
2415 get_user_name(id, name, sizeof name - 1)
2416 get_user_ip (id, ip, sizeof ip - 1, 1)
2417 geoip_code2_ex( ip, country)
2418
2419 replace_all(name, 31, "\", "")
2420 replace_all(name, 31, "`", "")
2421 replace_all(name, 31, "'", "")
2422
2423
2424 if( SQL_NumResults(hQuery) == 0 )
2425 {
2426 formatex(checkpoints, 31, ", '%d'", str_to_num(x3))
2427 formatex(gochecks, 31, ", '%d'", str_to_num(x4))
2428 formatex( createinto, sizeof createinto - 1, "INSERT INTO `%s` VALUES('%s', '%s','%s','%s','%f','%s','%s','%s'%s%s)", style == PRO_TOP ? "kz_pro15" : "kz_nub15", MapName, steam, country, name, newtime, dia, g_weaponsnames[str_to_num(x2)], server, style == PRO_TOP ? "" : checkpoints, style == PRO_TOP ? "" : gochecks)
2429 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
2430 GetNewRank(id, style)
2431 }
2432 else
2433 {
2434 new Float:oldtime, Float:thetime
2435 SQL_ReadResult(hQuery, 0, oldtime)
2436
2437 if(newtime < oldtime)
2438 {
2439 thetime = oldtime - newtime
2440 iMin = floatround(thetime / 60.0, floatround_floor)
2441 iSec = floatround(thetime - iMin * 60.0,floatround_floor)
2442 iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor )
2443 ColorChat(id, GREEN, "[KZ]^x01 %L^x03 %02i:%02i.%02i^x01 in ^x03%s", id, "KZ_IMPROVE", iMin, iSec, iMs, style == PRO_TOP ? "Pro 15" : "Noob 15")
2444 formatex(checkpoints, 31, ", checkpoints='%d'", str_to_num(x3))
2445 formatex(gochecks, 31, ", gocheck='%d'", str_to_num(x4))
2446 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
2447 formatex(createinto, sizeof createinto - 1, "UPDATE `%s` SET time='%f', weapon='%s', date='%s', server='%s'%s%s WHERE name='%s' AND mapname='%s'", style == PRO_TOP ? "kz_pro15" : "kz_nub15", newtime, g_weaponsnames[str_to_num(x2)], dia, server, style == PRO_TOP ? "" : gochecks, style == PRO_TOP ? "" : checkpoints, name, MapName)
2448 else
2449 formatex(createinto, sizeof createinto - 1, "UPDATE `%s` SET time='%f', weapon='%s', date='%s', server='%s'%s%s WHERE authid='%s' AND mapname='%s'", style == PRO_TOP ? "kz_pro15" : "kz_nub15", newtime, g_weaponsnames[str_to_num(x2)], dia, server, style == PRO_TOP ? "" : gochecks, style == PRO_TOP ? "" : checkpoints, steam, MapName)
2450
2451 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto )
2452 GetNewRank(id, style)
2453 }
2454 else
2455 {
2456 thetime = newtime - oldtime
2457 iMin = floatround(thetime / 60.0, floatround_floor)
2458 iSec = floatround(thetime - iMin * 60.0,floatround_floor)
2459 iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor )
2460 ColorChat(id, GREEN, "[KZ]^x01 %L^x03 %02i:%02i.%02i ^x01in ^x03%s", id, "KZ_SLOWER", iMin, iSec, iMs, style == PRO_TOP ? "Pro 15" : "Noob 15")
2461 }
2462 }
2463
2464 return PLUGIN_CONTINUE
2465
2466}
2467
2468public GetNewRank_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
2469{
2470 new id = cData[0]
2471 if( iFailState != TQUERY_SUCCESS )
2472 {
2473 return log_amx("TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
2474 }
2475
2476 new steam[32], authid[32], namez[32], name[32], i = 0
2477 get_user_authid(id, steam, 31)
2478 get_user_name(id, namez, 31)
2479
2480 while( SQL_MoreResults(hQuery) )
2481 {
2482 i++
2483 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
2484 {
2485 SQL_ReadResult(hQuery, 0, name, 31)
2486 if( equal(name, namez) )
2487 {
2488 ColorChat(0, GREEN, "%s^x03 %s^x01 %L ^x03%d^x01 in^x03 %s^x01",prefix, namez, LANG_PLAYER, "KZ_PLACE", i, cData[1] == PRO_TOP ? "Pro 15" : "Noob 15");
2489 break;
2490 }
2491 }
2492 else
2493 {
2494 SQL_ReadResult(hQuery, 0, authid, 31)
2495 if( equal(authid, steam) )
2496 {
2497 ColorChat(0, GREEN, "%s^x03 %s^x01 %L ^x03%d^x01 in^x03 %s^x01",prefix, namez, LANG_PLAYER, "KZ_PLACE", i, cData[1] == PRO_TOP ? "Pro 15" : "Noob 15");
2498 break;
2499 }
2500 }
2501 SQL_NextRow(hQuery)
2502 }
2503
2504 return PLUGIN_CONTINUE
2505}
2506
2507public ProTop_show(id)
2508{
2509 kz_showhtml_motd(id, PRO_TOP, MapName)
2510
2511 return PLUGIN_HANDLED
2512}
2513
2514public NoobTop_show(id)
2515{
2516
2517 kz_showhtml_motd(id, NUB_TOP, MapName)
2518
2519 return PLUGIN_HANDLED
2520}
2521
2522public ProRecs_show(id)
2523{
2524 new authid[32]
2525 get_user_authid(id, authid, 31)
2526
2527 if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
2528 {
2529 ColorChat (id, GREEN, "%s^x01 %L", prefix, id, "KZ_NO_STEAM")
2530 return PLUGIN_HANDLED
2531 }
2532
2533 kz_showhtml_motd(id, PRO_RECORDS, MapName)
2534
2535 return PLUGIN_HANDLED
2536}
2537
2538stock kz_showhtml_motd(id, type, const map[])
2539{
2540 new buffer[1001], namebuffer[64], filepath[96]
2541 get_pcvar_string(kz_sql_files, filepath, 95)
2542 new authid[32]
2543 get_user_authid(id, authid, 31)
2544
2545 switch( type )
2546 {
2547 case PRO_TOP:
2548 {
2549 formatex(namebuffer, 63, "Pro 15 of %s", equal(map, "") ? "All Maps" : map)
2550 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/pro15.php?map=%s^"></head><body><p>LOADING...</p></body></html>", filepath, map)
2551 }
2552 case NUB_TOP:
2553 {
2554 formatex(namebuffer, 63, "Noob 15 of %s", equal(map, "") ? "All Maps" : map)
2555 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/nub15.php?map=%s^"></head><body><p>LOADING...</p></body></html>", filepath, map)
2556 }
2557 case PRO_RECORDS:
2558 {
2559 formatex(namebuffer, 63, "ProRecords and Rank")
2560 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/player.php?authid=%s^"></head><body><p>LOADING...</p></body></html>", filepath, authid)
2561 }
2562 case PLAYERS_RANKING:
2563 {
2564 formatex(namebuffer, 63, "Players Ranking")
2565 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/players.php^"></head><body><p>LOADING...</p></body></html>", filepath, authid)
2566 }
2567 case LAST_PRO10:
2568 {
2569 formatex(namebuffer, 63, "Last 10 Pro Entries")
2570 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/lastpro.php^"></head><body><p>LOADING...</p></body></html>", filepath)
2571 }
2572 case MAPS_STATISTIC:
2573 {
2574 formatex(namebuffer, 63, "Maps Statistic")
2575 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/map.php^"></head><body><p>LOADING...</p></body></html>", filepath)
2576 }
2577 }
2578
2579 show_motd(id, buffer, namebuffer)
2580}
2581#else
2582public ProTop_update(id, Float:time)
2583{
2584 new authid[32], name[32], thetime[32], Float: slower, Float: faster, Float:protiempo
2585 get_user_name(id, name, 31);
2586 get_user_authid(id, authid, 31);
2587 get_time(" %d/%m/%Y ", thetime, 31);
2588 new bool:Is_in_pro15
2589 Is_in_pro15 = false
2590
2591 for(new i = 0; i < 15; i++)
2592 {
2593 if( (equali(Pro_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Pro_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2594 {
2595 Is_in_pro15 = true
2596 slower = time - Pro_Times[i]
2597 faster = Pro_Times[i] - time
2598 protiempo = Pro_Times[i]
2599 }
2600 }
2601
2602 for (new i = 0; i < 15; i++)
2603 {
2604 if( time < Pro_Times[i])
2605 {
2606 new pos = i
2607 if ( get_pcvar_num(kz_top15_authid) == 0 )
2608 while( !equal(Pro_Names[pos], name) && pos < 15 )
2609 {
2610 pos++;
2611 }
2612 else if ( get_pcvar_num(kz_top15_authid) == 1)
2613 while( !equal(Pro_AuthIDS[pos], authid) && pos < 15 )
2614 {
2615 pos++;
2616 }
2617
2618 for (new j = pos; j > i; j--)
2619 {
2620 formatex(Pro_AuthIDS[j], 31, Pro_AuthIDS[j-1]);
2621 formatex(Pro_Names[j], 31, Pro_Names[j-1]);
2622 formatex(Pro_Date[j], 31, Pro_Date[j-1])
2623 Pro_Times[j] = Pro_Times[j-1];
2624 }
2625
2626 formatex(Pro_AuthIDS[i], 31, authid);
2627 formatex(Pro_Names[i], 31, name);
2628 formatex(Pro_Date[i], 31, thetime)
2629 Pro_Times[i] = time
2630
2631 save_pro15()
2632
2633 if( Is_in_pro15 )
2634 {
2635
2636 if( time < protiempo )
2637 {
2638 new min, Float:sec;
2639 min = floatround(faster, floatround_floor)/60;
2640 sec = faster - (60*min);
2641 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_IMPROVE", min, sec < 10 ? "0" : "", sec);
2642
2643 if( (i + 1) == 1)
2644 {
2645 client_cmd(0, "spk woop");
2646 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2647 }
2648 else
2649 {
2650 client_cmd(0, "spk buttons/bell1");
2651 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2652 }
2653 }
2654 }
2655 else
2656 {
2657 if( (i + 1) == 1)
2658 {
2659 client_cmd(0, "spk woop");
2660 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2661 }
2662 else
2663 {
2664 client_cmd(0, "spk buttons/bell1");
2665 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2666 }
2667 }
2668
2669 return;
2670 }
2671
2672 if( (equali(Pro_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Pro_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2673 {
2674 if( time > protiempo )
2675 {
2676 new min, Float:sec;
2677 min = floatround(slower, floatround_floor)/60;
2678 sec = slower - (60*min);
2679 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_SLOWER", min, sec < 10 ? "0" : "", sec);
2680 return;
2681 }
2682 }
2683
2684 }
2685}
2686
2687public save_pro15()
2688{
2689 new profile[128]
2690 formatex(profile, 127, "%s/pro_%s.cfg", Topdir, MapName)
2691
2692 if( file_exists(profile) )
2693 {
2694 delete_file(profile)
2695 }
2696
2697 new Data[256];
2698 new f = fopen(profile, "at")
2699
2700 for(new i = 0; i < 15; i++)
2701 {
2702 formatex(Data, 255, "^"%.2f^" ^"%s^" ^"%s^" ^"%s^"^n", Pro_Times[i], Pro_AuthIDS[i], Pro_Names[i], Pro_Date[i])
2703 fputs(f, Data)
2704 }
2705 fclose(f);
2706}
2707
2708public read_pro15()
2709{
2710 new profile[128], prodata[256]
2711 formatex(profile, 127, "%s/pro_%s.cfg", Topdir, MapName)
2712
2713 new f = fopen(profile, "rt" )
2714 new i = 0
2715 while( !feof(f) && i < 16)
2716 {
2717 fgets(f, prodata, 255)
2718 new totime[25]
2719 parse(prodata, totime, 24, Pro_AuthIDS[i], 31, Pro_Names[i], 31, Pro_Date[i], 31)
2720 Pro_Times[i] = str_to_float(totime)
2721 i++;
2722 }
2723 fclose(f)
2724}
2725
2726//==================================================================================================
2727
2728public NoobTop_update(id, Float:time, checkpoints, gochecks)
2729{
2730 new authid[32], name[32], thetime[32], wpn, Float: slower, Float: faster, Float:noobtiempo
2731 get_user_name(id, name, 31);
2732 get_user_authid(id, authid, 31);
2733 get_time(" %d/%m/%Y ", thetime, 31);
2734 new bool:Is_in_noob15
2735 Is_in_noob15 = false
2736 if(user_has_scout[id])
2737 wpn=CSW_SCOUT
2738 else
2739 wpn=get_user_weapon(id)
2740
2741 for(new i = 0; i < 15; i++)
2742 {
2743 if( (equali(Noob_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Noob_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2744 {
2745 Is_in_noob15 = true
2746 slower = time - Noob_Tiempos[i];
2747 faster = Noob_Tiempos[i] - time;
2748 noobtiempo = Noob_Tiempos[i]
2749 }
2750 }
2751
2752 for (new i = 0; i < 15; i++)
2753 {
2754 if( time < Noob_Tiempos[i])
2755 {
2756 new pos = i
2757
2758 if ( get_pcvar_num(kz_top15_authid) == 0 )
2759 while( !equal(Noob_Names[pos], name) && pos < 15 )
2760 {
2761 pos++;
2762 }
2763 else if ( get_pcvar_num(kz_top15_authid) == 1)
2764 while( !equal(Noob_AuthIDS[pos], authid) && pos < 15 )
2765 {
2766 pos++;
2767 }
2768
2769 for (new j = pos; j > i; j--)
2770 {
2771 formatex(Noob_AuthIDS[j], 31, Noob_AuthIDS[j-1])
2772 formatex(Noob_Names[j], 31, Noob_Names[j-1])
2773 formatex(Noob_Date[j], 31, Noob_Date[j-1])
2774 formatex(Noob_Weapon[j], 31, Noob_Weapon[j-1])
2775 Noob_Tiempos[j] = Noob_Tiempos[j-1]
2776 Noob_CheckPoints[j] = Noob_CheckPoints[j-1]
2777 Noob_GoChecks[j] = Noob_GoChecks[j-1]
2778 }
2779
2780 formatex(Noob_AuthIDS[i], 31, authid);
2781 formatex(Noob_Names[i], 31, name);
2782 formatex(Noob_Date[i], 31, thetime)
2783 formatex(Noob_Weapon[i], 31, g_weaponsnames[wpn])
2784 Noob_Tiempos[i] = time
2785 Noob_CheckPoints[i] = checkpoints
2786 Noob_GoChecks[i] = gochecks
2787
2788 save_Noob15()
2789
2790 if( Is_in_noob15 )
2791 {
2792
2793 if( time < noobtiempo )
2794 {
2795 new min, Float:sec;
2796 min = floatround(faster, floatround_floor)/60;
2797 sec = faster - (60*min);
2798 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_IMPROVE", min, sec < 10 ? "0" : "", sec);
2799
2800 if( (i + 1) == 1)
2801 {
2802 client_cmd(0, "spk woop");
2803 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2804 }
2805 else
2806 {
2807 client_cmd(0, "spk buttons/bell1");
2808 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2809 }
2810 }
2811 }
2812 else
2813 {
2814 if( (i + 1) == 1)
2815 {
2816 client_cmd(0, "spk woop");
2817 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
2818 }
2819 else
2820 {
2821 client_cmd(0, "spk buttons/bell1");
2822 ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
2823 }
2824 }
2825 return;
2826 }
2827
2828 if( (equali(Noob_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Noob_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
2829 {
2830 if( time > noobtiempo )
2831 {
2832
2833 new min, Float:sec;
2834 min = floatround(slower, floatround_floor)/60;
2835 sec = slower - (60*min);
2836 ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_SLOWER", min, sec < 10 ? "0" : "", sec);
2837 return;
2838 }
2839 }
2840
2841 }
2842}
2843
2844public save_Noob15()
2845{
2846 new profile[128]
2847 formatex(profile, 127, "%s/Noob_%s.cfg", Topdir, MapName)
2848
2849 if( file_exists(profile) )
2850 {
2851 delete_file(profile)
2852 }
2853
2854 new Data[256];
2855 new f = fopen(profile, "at")
2856
2857 for(new i = 0; i < 15; i++)
2858 {
2859 formatex(Data, 255, "^"%.2f^" ^"%s^" ^"%s^" ^"%i^" ^"%i^" ^"%s^" ^"%s^" ^n", Noob_Tiempos[i], Noob_AuthIDS[i], Noob_Names[i], Noob_CheckPoints[i], Noob_GoChecks[i],Noob_Date[i],Noob_Weapon[i])
2860 fputs(f, Data)
2861 }
2862 fclose(f);
2863}
2864
2865public read_Noob15()
2866{
2867 new profile[128], prodata[256]
2868 formatex(profile, 127, "%s/Noob_%s.cfg", Topdir, MapName)
2869
2870 new f = fopen(profile, "rt" )
2871 new i = 0
2872 while( !feof(f) && i < 16)
2873 {
2874 fgets(f, prodata, 255)
2875 new totime[25], checks[5], gochecks[5]
2876 parse(prodata, totime, 24, Noob_AuthIDS[i], 31, Noob_Names[i], 31, checks, 4, gochecks, 4, Noob_Date[i], 31, Noob_Weapon[i], 31)
2877 Noob_Tiempos[i] = str_to_float(totime)
2878 Noob_CheckPoints[i] = str_to_num(checks)
2879 Noob_GoChecks[i] = str_to_num(gochecks)
2880 i++;
2881 }
2882 fclose(f)
2883}
2884
2885public ProTop_show(id)
2886{
2887 new buffer[2048], len, name[32]
2888
2889 len = formatex(buffer, 2047, "<body bgcolor=#3399FF><table width=100%% cellpadding=2 cellspacing=0 border=0>")
2890 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 ")
2891
2892 for (new i = 0; i < 10; i++)
2893 {
2894 name = Pro_Names[i]
2895
2896 if( Pro_Times[i] > 9999999.0 )
2897 {
2898 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), "", "", "")
2899 }
2900
2901 else
2902 {
2903 new minutos, Float:segundos
2904 minutos = floatround(Pro_Times[i], floatround_floor)/60
2905 segundos = Pro_Times[i] - (60*minutos)
2906
2907 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])
2908
2909 }
2910 }
2911
2912 len += formatex(buffer[len], 2047-len, "</table></body>")
2913 len += formatex(buffer[len], 2047-len, "<tr><Center><b><BR>Plugin created by nucLeaR")
2914
2915 show_motd(id, buffer, "Pro10 Climbers")
2916
2917 return PLUGIN_HANDLED
2918}
2919
2920public NoobTop_show(id)
2921{
2922 new buffer[2048], name[32], len
2923
2924 len = formatex(buffer, 2047, "<body bgcolor=#3399FF><table width=100%% cellpadding=2 cellspacing=0 border=0>")
2925 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")
2926
2927 for (new i = 0; i < 10; i++)
2928 {
2929 if( Noob_Tiempos[i] > 9999999.0 )
2930 {
2931 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), "", "", "", "", "")
2932 }
2933
2934 else
2935 {
2936 name = Noob_Names[i]
2937 new minutos, Float:segundos
2938 minutos = floatround(Noob_Tiempos[i], floatround_floor)/60
2939 segundos = Noob_Tiempos[i] - (60*minutos)
2940
2941 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])
2942 }
2943 }
2944
2945 len += formatex(buffer[len], 2047-len, "</table></body>")
2946 len += formatex(buffer[len], 2047-len, "<tr><Center><b><BR>Plugin created by nucLeaR")
2947
2948 show_motd(id, buffer, "Noob10 Climbers")
2949
2950 return PLUGIN_HANDLED
2951}
2952#endif
2953
2954// You reached the end of file
2955// The original plugin was made by p4ddY
2956// This plugin was edited by nucLeaR
2957// Version 2.31