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