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