· 9 years ago · Jun 30, 2017, 09:54 AM
1#include <amxmodx>
2#include <engine>
3#include <amxmisc>
4#include <cstrike>
5#include <colorchat>
6#include <engine>
7#include <fakemeta>
8#include <fun>
9#include <hamsandwich>
10#include <orpheu_stocks>
11#include <orpheu_memory>
12
13#define USE_SQL
14
15#pragma tabsize 0
16
17#if defined USE_SQL
18#include <sqlx>
19#include <geoip>
20#endif
21
22#define KZ_VIP ADMIN_LEVEL_C
23#define MSG MSG_ONE_UNRELIABLE
24#define MAX_ENTITYS 900+15*32
25#define IsOnLadder(%1) (pev(%1, pev_movetype) == MOVETYPE_FLY)
26#define VERSION ""
27#define SCOREATTRIB_NONE 0
28#define SCOREATTRIB_DEAD (1 << 0)
29#define SCOREATTRIB_BOMB (1 << 1)
30#define SCOREATTRIB_VIP (1 << 2)
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
36new iconstatus
37new g_roundtime
38new g_msgDeathMsg
39new g_soundlist[] =
40{
41 "doors/doorstop1.wav", "doors/doorstop2.wav", "doors/doorstop3.wav",
42 "player/pl_pain2.wav", "player/pl_pain3.wav","player/pl_pain4.wav",
43 "player/pl_pain5.wav", "player/pl_pain6.wav", "player/pl_pain7.wav",
44 "player/bhit_kevlar-1.wav", "player/bhit_flesh-1.wav", "player/bhit_flesh-2.wav",
45 "player/bhit_flesh-3.wav","player/pl_swim1.wav", "player/pl_swim2.wav",
46 "player/pl_swim3.wav", "player/pl_swim4.wav", "player/waterrun.wav",
47 "weapons/knife_hit1.wav", "weapons/knife_hit2.wav", "weapons/knife_hit3.wav",
48 "weapons/knife_hit4.wav", "weapons/knife_stab.wav", "weapons/knife_deploy1.wav",
49 "weapons/dryfire_pistol.wav", "weapons/dryfire_rifle.wav",
50 "items/gunpickup2.wav", "items/9mmclip1.wav", "common/bodysplat.wav", "common/player/sprayer.wav"
51}
52
53new g_bot_soundlist[] =
54{
55 "common/wpn_select.wav", "common/wpn_denyselect.wav", "weapons/dryfire_pistol.wav",
56 "weapons/dryfire_rifle.wav", "common/player/sprayer.wav"
57}
58
59new const g_RemoveEntities[][] =
60{
61 "func_bomb_target", "info_bomb_target", "hostage_entity", "func_breakable",
62 "monster_scientist", "func_hostage_rescue", "info_hostage_rescue",
63 "info_vip_start", "func_vip_safetyzone", "func_escapezone",
64 "armoury_entity", "game_player_equip", "player_weaponstrip",
65 "info_deathmatch_start"
66}
67
68
69new bool:menu_user[33]
70new bool:hook[33]
71new bool:usedhook[33]
72new hook_to[33][3]
73new hook_speed_cvar
74new bool:has_hook[33]
75
76#if defined USE_SQL
77new Handle:g_SqlTuple
78new Handle:SqlConnection
79new g_Error[512]
80new kz_sql_host
81new kz_sql_user
82new kz_sql_pass
83new kz_sql_db
84new kz_sql_name
85new kz_sql_files
86#else
87new Float:Pro_Times[24]
88new Pro_AuthIDS[24][32]
89new Pro_Names[24][32]
90new Pro_Date[24][32]
91new Float:Noob_Tiempos[24]
92new Noob_AuthIDS[24][32]
93new Noob_Names[24][32]
94new Noob_Date[24][32]
95new Noob_CheckPoints[24]
96new Noob_GoChecks[24]
97new Noob_Weapon[24][32]
98#endif
99
100new Float:angles[3]
101new Float:CPangles[33][2][3]
102new Float:Checkpoints[33][2][3]
103new Float:timer_time[33]
104new Float:g_pausetime[33]
105new Float:anticheat[33]
106new Float:groundtime[33]
107new Float:SpecLoc[33][2][3]
108new Float:NoclipPos[33][3]
109new Float:PauseOrigin[33][3]
110new Float:SavedStart[33][3]
111new Float:DefaultStartPos[3]
112new Float:DefaultStartPosAng[3]
113new Float:CustomStartPos[33][2][3]
114new is_user_spec[33]
115
116new Float:SavedTime[33]
117new SavedChecks[33]
118new SavedGoChecks[33]
119new SavedScout[33]
120new Float:PosLoc[33][2][3]
121
122new bool:g_bCpAlternate[33]
123new bool:show_timer[33]
124new bool:timer_started[33]
125new bool:in_run[33]
126new bool:IsPaused[33]
127new bool:WasPaused[33]
128new bool:AutoPaused[33]
129new bool:firstspawn[33]
130new bool:user_has_scout[33]
131new bool:HealsOnMap
132new bool:KeysOn[33]
133new bool:gWaterEntity[MAX_ENTITYS]
134new bool:gWaterFound
135new bool:CustomStart[33]
136new bool:DefaultStart
137new bool:AutoStart[33]
138
139new Trie:g_aSounds
140new Trie:g_tStarts
141new Trie:g_tStops
142new checknumbers[33]
143new gochecknumbers[33]
144new ShowTime[33]
145new MapName[64]
146new Kzdir[128]
147new SavePosDir[128]
148
149#if !defined USE_SQL
150new Topdir[128]
151#endif
152
153new tempid
154new kz_motd_enabled
155new kz_airace
156new kz_cheats
157new kz_godmode
158new kz_teleport_notification
159new kz_teleport_height
160new kz_cp_angles
161new kz_block_pickup
162new kz_block_ct
163new kz_block_money
164new kz_block_kill
165new kz_checkpoints
166new kz_cheatdetect
167new kz_show_timer
168new kz_hud_color
169new hud_message
170new kz_bot_usp
171new kz_other_weapons
172new kz_drop_weapons
173new kz_remove_drops
174new kz_pick_weapons
175new kz_reload_weapons
176new kz_use_radio
177new kz_pause
178new kz_noclip_pause
179new kz_vip
180new kz_save_pos_gochecks
181new kz_respawn_ct
182new kz_save_autostart
183new kz_top15_authid
184
185new g_iMsgMoney
186
187new const other_weapons[7] =
188{
189 CSW_SCOUT, CSW_P90, CSW_FAMAS, CSW_SG552,
190 CSW_M4A1, CSW_AK47, CSW_AWP
191}
192
193new const other_weapons_name[7][] =
194{
195 "weapon_scout", "weapon_p90", "weapon_famas", "weapon_sg552",
196 "weapon_m4a1", "weapon_ak47", "weapon_awp"
197}
198
199new const g_weaponsnames[][] =
200{
201 "",
202 "p228", "shield", "scout", "hegrenade", "xm1014", "c4",
203 "mac10", "aug", "smokegrenade", "elite", "fiveseven",
204 "ump45", "sg550", "galil", "famas", "usp", "glock18",
205 "awp", "mp5navy", "m249", "m3", "m4a1", "tmp", "g3sg1",
206 "flashbang", "deagle", "sg552", "ak47", "knife", "p90",
207 "glock", "elites", "fn57", "mp5", "vest", "vesthelm",
208 "flash", "hegren", "sgren", "defuser", "nvgs", "primammo",
209 "secammo", "km45", "9x19mm", "nighthawk", "228compact",
210 "12gauge", "autoshotgun", "mp", "c90", "cv47", "defender",
211 "clarion", "krieg552", "bullpup", "magnum", "d3au1",
212 "krieg550"
213}
214
215new const g_block_commands[][]=
216{
217 "buy", "buyammo1", "buyammo2", "buyequip",
218 "cl_autobuy", "cl_rebuy", "cl_setautobuy", "cl_setrebuy"
219}
220
221enum
222{
223 TASK_ID_CHECKENT
224}
225
226#if defined USE_SQL
227enum
228{
229 TOP_NULL,
230 PRO_TOP,
231 NUB_TOP,
232 SEARCH_PLAYER,
233 LAST_PRO10,
234 PRO_RECORDS,
235 MY_RECORDS,
236 PLAYERS_RANKING,
237 MAPS_STATISTIC
238}
239#endif
240
241new g_szMapName[32]
242
243public plugin_init()
244{
245 register_plugin("ProKreedz", VERSION, "")
246
247 kz_airace = get_cvar_pointer( "sv_airaccelerate" )
248 kz_motd_enabled = register_cvar("motd_enabled","1")
249 kz_cp_angles = register_cvar("kz_cp_angles","0")
250 kz_block_pickup = register_cvar("kz_block_pickup","1")
251 kz_block_ct = register_cvar("kz_block_ct","0")
252 kz_block_money = register_cvar("kz_block_money","1")
253 kz_block_kill = register_cvar( "kz_block_kill", "1" )
254 kz_checkpoints = register_cvar("kz_checkpoints","1")
255 kz_cheats = register_cvar("kz_cheats","1")
256 kz_godmode = register_cvar("kz_godmode","1")
257 kz_cheatdetect = register_cvar("kz_cheatdetect","1")
258 kz_show_timer = register_cvar("kz_show_timer", "1")
259 kz_hud_color = register_cvar("kz_hud_color", "255 255 255")
260 kz_bot_usp = register_cvar("kz_bot_usp","0")
261 kz_other_weapons = register_cvar("kz_other_weapons","1")
262 kz_drop_weapons = register_cvar("kz_drop_weapons", "1")
263 kz_remove_drops = register_cvar("kz_remove_drops", "0")
264 kz_pick_weapons = register_cvar("kz_pick_weapons", "1")
265 kz_reload_weapons = register_cvar("kz_reload_weapons", "0")
266 kz_use_radio = register_cvar("kz_use_radio", "0")
267 kz_pause = register_cvar("kz_pause", "1")
268 kz_noclip_pause = register_cvar("kz_noclip_pause", "1")
269 kz_vip = register_cvar("kz_vip","1")
270 kz_respawn_ct = register_cvar("kz_respawn_ct", "1")
271 kz_save_autostart = register_cvar("kz_save_autostart", "1")
272 kz_teleport_notification = register_cvar("kz_teleport_notification", "1")
273 kz_teleport_height = register_cvar("kz_teleport_height", "20")
274 kz_top15_authid = register_cvar("kz_top15_authid", "1")
275 kz_save_pos_gochecks = register_cvar("kz_save_pos_gochecks", "1")
276
277 g_iMsgMoney = get_user_msgid( "Money" )
278
279 #if defined USE_SQL
280 kz_sql_host = register_cvar("kz_sql_host", "")
281 kz_sql_user = register_cvar("kz_sql_user", "")
282 kz_sql_pass = register_cvar("kz_sql_pass", "", FCVAR_PROTECTED)
283 kz_sql_db = register_cvar("kz_sql_db", "")
284 kz_sql_name = register_cvar("kz_sql_server", "")
285 kz_sql_files = register_cvar("kz_sql_files", "")
286 #endif
287
288 register_touch("weaponbox", "player", "BlockPickup")
289 register_touch("armoury_entity", "player", "BlockPickup")
290 register_touch("weapon_shield", "player", "BlockPickup")
291
292 hook_speed_cvar = register_cvar("hook_speed","5")
293 register_concmd("+hook","hook_on")
294 register_concmd("-hook","hook_off")
295 register_concmd("hook_toggle","hook_toggle",ADMIN_KICK,"Toggles your hook on and off")
296 register_concmd("amx_give_hook","cmd_givetake",ADMIN_KICK,"Give a player the ability to hook <nick>")
297 register_concmd("amx_take_hook","cmd_givetake",ADMIN_KICK,"Take a player's ability to hook <nick>")
298 register_clcmd("say /timer", "timer_toggle")
299 register_clcmd("say /time", "timer_toggle")
300 register_clcmd("say /showtime", "timer_toggle")
301 register_clcmd("say /showtimer", "timer_toggle")
302 register_clcmd("say /tele", "kz_tele_menu")
303 register_clcmd("say /savepos", "SavePos")
304 register_clcmd("say /save", "SavePos")
305 register_clcmd("/cp","CheckPoint")
306 register_clcmd("/gc", "GoCheck")
307 register_clcmd("/tp","GoCheck")
308 register_clcmd("start", "goStart")
309 register_clcmd("drop", "BlockDrop")
310 register_clcmd("chooseteam", "ct")
311 register_clcmd("radio1", "BlockRadio")
312 register_clcmd("radio2", "BlockRadio")
313 register_clcmd("radio3", "BlockRadio")
314 register_clcmd("say /xj", "xj")
315 register_clcmd("say /cc", "cc")
316 register_clcmd("say /aa", "CheckAir")
317 register_clcmd("say /cp","CheckPoint")
318 register_clcmd("say /gc", "GoCheck")
319 register_clcmd("say /tp", "GoCheck")
320 register_clcmd("say /teleport", "GoCheck")
321 register_clcmd("say /gocheck", "GoCheck")
322 register_clcmd("say /stuck", "Stuck")
323 register_clcmd("say /unstuck", "Stuck")
324 register_clcmd("say /reset", "reset_checkpoints")
325 register_clcmd("say /customstart", "customStart")
326 register_clcmd("say /cs", "customStart")
327 register_clcmd("say .cs", "customStart")
328 register_clcmd("say /setstart", "setStart")
329 register_clcmd("say /ss", "setStart")
330 register_clcmd("say .ss", "setStart")
331 register_clcmd("say /start", "goStart")
332 register_clcmd("say /respawn", "goStart")
333 register_clcmd("say /pause", "Pause")
334 register_clcmd("say /p", "Pause")
335 register_clcmd("say /blockct", "BlockCT")
336 register_clcmd("say /menu","kz_menu")
337 register_clcmd("say /kz", "climb_menu")
338 register_clcmd("say /training","climb_menu")
339 register_clcmd("say /climb","climb_menu")
340 register_clcmd("say /model", "model_menu")
341 register_clcmd("say /models", "model_menu")
342 register_clcmd("say /nc", "noclip")
343 register_clcmd("say /noclip", "noclip")
344
345 #if defined USE_SQL
346 register_clcmd("say /rec", "My_Records")
347 register_clcmd("say /recs", "My_Records")
348 register_clcmd("say /records", "My_Records")
349 register_clcmd("say /rank", "Players_Ranking")
350 register_clcmd("say /search", "NoobTop_show")
351 register_clcmd("say /s", "NoobTop_show")
352 register_clcmd("say /maps", "Map_Statistic")
353 register_clcmd("say /best", "ProTop_show")
354 register_clcmd("say /top", "ProTop_show")
355 register_clcmd("say /top10", "ProTop_show")
356 register_clcmd("say /top15", "ProTop_show")
357 register_clcmd("say /pro10", "ProTop_show")
358 register_clcmd("say /pro15", "ProTop_show")
359 register_clcmd("say /nub10", "ProTop_show")
360 register_clcmd("say /nub15", "ProTop_show")
361 register_clcmd("say /wr", "ProTop_show")
362 #endif
363 register_clcmd("say /topmenu", "top15menu")
364 register_clcmd("say /uptime", "CmdUpTime")
365 register_clcmd("say /up", "CmdUpTime")
366 register_clcmd("say /ct","ct")
367 register_clcmd("say /spec", "ct")
368 register_clcmd("say /maxspeed", "maxspeedmsg")
369 register_clcmd("say /ms", "maxspeedmsg")
370 register_clcmd("say /weapons", "weapons")
371 register_clcmd("say /guns", "weapons")
372 register_clcmd("say /scout", "scout")
373
374 new iEnt
375 iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString , "info_target"))
376 set_pev(iEnt, pev_classname, "kz_time_think")
377 set_pev(iEnt, pev_nextthink, get_gametime() + 1.0)
378
379 register_forward(FM_Think,"fw_ThinkEntity")
380 register_forward(FM_EmitSound, "block_sound")
381 register_forward( FM_ClientKill, "fwdClientKill" )
382
383 OrpheuRegisterHook(OrpheuGetFunction("PM_Move"), "OR_PMMove");
384
385 RegisterHam(Ham_Use, "func_button", "fwdUse", 0)
386 RegisterHam(Ham_Killed, "player", "Ham_CBasePlayer_Killed_Post", 1)
387 RegisterHam(Ham_Touch, "weaponbox", "FwdSpawnWeaponbox")
388 RegisterHam(Ham_Spawn, "player", "FwdHamPlayerSpawn", 1)
389 RegisterHam(Ham_Killed, "player", "Ham_PlayerKilled_P", true)
390 RegisterHam(Ham_Touch, "weaponbox", "GroundWeapon_Touch")
391 RegisterHam( Ham_TakeDamage, "player", "hamTakeDamage" )
392 register_message(get_user_msgid("StatusIcon"), "MessageStatusIcon")
393 register_message(get_user_msgid("ScoreAttrib"), "MessageScoreAttrib")
394
395 register_message(get_user_msgid("SendAudio"), "msg_block_startsounds")
396 register_message(get_user_msgid("SendAudio"),"msg_block_statussounds")
397 register_message(get_user_msgid("TextMsg") ,"message_textmsg")
398
399 new aSounds[][] = {"%!MRAD_LOCKNLOAD","%!MRAD_MOVEOUT","%!MRAD_LETSGO","%!MRAD_GO","%!MRAD_ELIM","%!MRAD_GETOUT"}
400
401 g_aSounds = TrieCreate()
402
403 for(new i = 0; i < sizeof(aSounds); i++)
404 TrieSetCell(g_aSounds, aSounds[i], 1)
405
406 register_dictionary("prokreedz.txt")
407 get_mapname(MapName, 63)
408 iconstatus = get_user_msgid("StatusIcon")
409 g_roundtime = get_user_msgid("RoundTime")
410 g_msgDeathMsg = get_user_msgid("DeathMsg")
411 set_msg_block(g_msgDeathMsg,BLOCK_ONCE)
412 set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
413 register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
414 register_event( "Money", "EventMoney", "b" )
415 #if defined USE_SQL
416 set_task(0.2, "plugin_sql")
417 #endif
418 get_mapname(g_szMapName, sizeof(g_szMapName) - 1)
419 strtolower(g_szMapName)
420
421 new kreedz_cfg[128], ConfigDir[64]
422 get_configsdir(ConfigDir, 64)
423 formatex(Kzdir,128, "%s/kz", ConfigDir)
424 if(!dir_exists(Kzdir))
425 mkdir(Kzdir)
426
427 #if !defined USE_SQL
428 formatex(Topdir,128, "%s/top15", Kzdir)
429 if(!dir_exists(Topdir))
430 mkdir(Topdir)
431 #endif
432
433 formatex(SavePosDir, 128, "%s/savepos", Kzdir)
434 if( !dir_exists(SavePosDir) )
435 mkdir(SavePosDir)
436
437 formatex(kreedz_cfg,128,"%s/kreedz.cfg", Kzdir)
438
439 if(file_exists(kreedz_cfg))
440 {
441 server_exec()
442 server_cmd("exec %s",kreedz_cfg)
443 }
444
445 for(new i = 0; i < sizeof(g_block_commands) ; i++)
446 register_clcmd(g_block_commands[i], "BlockBuy")
447
448 g_tStarts = TrieCreate()
449 g_tStops = TrieCreate()
450
451 new const szStarts[ ][ ] =
452 {
453 "counter_start", "clockstartbutton", "firsttimerelay", "but_start", "counter_start_button",
454 "multi_start", "timer_startbutton", "start_timer_emi", "gogogo"
455 }
456
457 new const szStops[ ][ ] =
458 {
459 "counter_off", "clockstopbutton", "clockstop", "but_stop", "counter_stop_button",
460 "multi_stop", "stop_counter", "m_counter_end_emi"
461 }
462
463 for(new i = 0; i < sizeof szStarts; i++)
464 TrieSetCell(g_tStarts, szStarts[ i ], 1)
465
466 for(new i = 0; i < sizeof szStops; i++)
467 TrieSetCell(g_tStops, szStops[ i ], 1)
468}
469#if defined USE_SQL
470
471public plugin_sql()
472{
473 new host[64], user[64], pass[64], db[64]
474
475 get_pcvar_string(kz_sql_host, host, 63)
476 get_pcvar_string(kz_sql_user, user, 63)
477 get_pcvar_string(kz_sql_pass, pass, 63)
478 get_pcvar_string(kz_sql_db, db, 63)
479
480 g_SqlTuple = SQL_MakeDbTuple(host, user, pass, db)
481
482 new ErrorCode
483 SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
484
485 if(!SqlConnection)
486 {
487 server_print("[KZ] TOP15 SQL: Could not connect to SQL database.!")
488 log_amx("[KZ] TOP15 SQL: Could not connect to SQL database.")
489 }
490
491 new createinto[1001]
492 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)")
493 SQL_ThreadQuery(g_SqlTuple,"QueryHandle", createinto)
494 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)")
495 SQL_ThreadQuery(g_SqlTuple,"QueryHandle", createinto)
496
497 return PLUGIN_CONTINUE
498}
499
500public QueryHandle(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
501{
502 if(iFailState != TQUERY_SUCCESS)
503 {
504 log_amx("[KZ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
505 ColorChat(0, GREEN, "^x01[KZ]: Warning the SQL Tops can not be saved.")
506 }
507 server_print("[KZ] Server Sending Info to SQL Server")
508
509 return PLUGIN_CONTINUE
510}
511#endif
512
513public plugin_natives()
514{
515 register_native("kz_menu_user", "native_menu_user", 1)
516}
517
518public native_menu_user(id)
519{
520 if(menu_user[id])
521 return true
522 else
523 return false
524
525 return false
526}
527
528public plugin_precache()
529{
530 hud_message = CreateHudSyncObj()
531 RegisterHam(Ham_Spawn, "func_door", "FwdHamDoorSpawn", 1)
532 precache_sound("weapons/xbow_hit2.wav")
533 precache_sound("vox/woop.wav")
534 precache_sound("buttons/bell1.wav")
535 register_forward(FM_Spawn, "FwdSpawn", 0)
536}
537
538public plugin_cfg()
539{
540 #if !defined USE_SQL
541 for (new i = 0 ; i < 15; ++i)
542 {
543 Pro_Times[i] = 999999999.00000
544 Noob_Tiempos[i] = 999999999.00000
545 }
546 read_pro15()
547 read_Noob15()
548 #endif
549
550 new startcheck[100], data[256], map[64], x[13], y[13], z[13], a[13], b[13], c[13]
551 formatex(startcheck, 99, "%s/%s", Kzdir, KZ_STARTFILE)
552 new f = fopen(startcheck, "rt")
553 while(!feof(f))
554 {
555 fgets(f, data, sizeof data - 1)
556 parse(data, map, 63, x, 12, y, 12, z, 12, a, 12, b, 12, c, 12)
557
558 if(equali(map, MapName))
559 {
560 DefaultStartPos[0] = str_to_float(x)
561 DefaultStartPos[1] = str_to_float(y)
562 DefaultStartPos[2] = str_to_float(z)
563
564 DefaultStartPosAng[0] = str_to_float(a)
565 DefaultStartPosAng[1] = str_to_float(b)
566 DefaultStartPosAng[2] = str_to_float(c)
567
568 DefaultStart = true
569 break
570 }
571 }
572 fclose(f)
573 new ent = -1
574 while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_water")) != 0)
575 {
576 if(!gWaterFound)
577 {
578 gWaterFound = true
579 }
580 gWaterEntity[ent] = true
581 }
582
583 ent = -1
584 while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_illusionary")) != 0)
585 {
586 if(pev(ent, pev_skin) == CONTENTS_WATER)
587 {
588 if(!gWaterFound)
589 {
590 gWaterFound = true
591 }
592
593 gWaterEntity[ent] = true
594 }
595 }
596
597 ent = -1
598 while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_conveyor")) != 0)
599 {
600 if(pev(ent, pev_spawnflags) == 3)
601 {
602 if(!gWaterFound)
603 {
604 gWaterFound = true
605 }
606
607 gWaterEntity[ent] = true
608 }
609 }
610}
611
612public msg_block_startsounds()
613{
614 new sArg2[18]
615 get_msg_arg_string(2, sArg2, charsmax(sArg2))
616 if(TrieKeyExists(g_aSounds, sArg2))
617 {
618 if(get_msg_block(SVC_TEMPENTITY) == BLOCK_NOT)
619 {
620 set_msg_block(SVC_TEMPENTITY, BLOCK_ONCE)
621 }
622
623 return PLUGIN_HANDLED
624 }
625 return PLUGIN_CONTINUE
626}
627
628public msg_block_statussounds(msg_id, msg_dest, msg_entity)
629{
630 static message[10]
631 get_msg_arg_string(2, message, sizeof message - 1)
632
633 switch(message[7])
634 {
635 // -- %!MRAD_terwin ; %!MRAD_ctwin ; %!MRAD_rounddraw
636 case 'c', 't', 'r' : return PLUGIN_HANDLED
637 }
638
639 return PLUGIN_CONTINUE
640}
641
642public message_textmsg(msg_id, msg_dest, msg_entity)
643{
644 static message[3]
645 get_msg_arg_string(2, message, sizeof message - 1)
646
647 switch(message[1])
648 {
649 // -- #CTs_Win ; #Terrorists_Win ; #Round_Draw
650 case 'C', 'T', 'R' : return PLUGIN_HANDLED
651 }
652
653 return PLUGIN_CONTINUE
654}
655
656public client_infochanged(id)
657{
658 if( !is_user_connected(id) )
659 {
660 return PLUGIN_CONTINUE
661 }
662
663 new newname[32], oldname[32]
664
665 get_user_name(id, oldname, 31)
666 get_user_info(id, "name", newname, 31)
667
668 if(!equal(newname, oldname))
669 {
670 kz_update_plrname(id, newname)
671 }
672
673 return PLUGIN_CONTINUE
674}
675
676public FwdSpawn(ent)
677{
678 if( pev_valid(ent) )
679 {
680 set_task(0.1, "TaskDelayedCheck", ent + TASK_ID_CHECKENT, "", 0, "", 0)
681
682 return FMRES_HANDLED
683 }
684
685 return FMRES_IGNORED
686}
687
688public TaskDelayedCheck(ent)
689{
690 ent -= TASK_ID_CHECKENT
691
692 if( !pev_valid(ent) )
693 {
694 return PLUGIN_CONTINUE
695 }
696
697 new class[32]
698 pev(ent, pev_classname, class, 32)
699
700 for( new i; i < sizeof(g_RemoveEntities); i++ )
701 {
702 if( equal(class, g_RemoveEntities[i], 0) )
703 {
704 engfunc(EngFunc_RemoveEntity, ent)
705 break
706 }
707 }
708
709 return PLUGIN_CONTINUE
710}
711
712public Pause(id)
713{
714 new entclassname[33], Float:dmg
715 pev(pev(id, pev_groundentity), pev_classname, entclassname, 32)
716 pev(pev(id, pev_groundentity), pev_dmg, dmg)
717 if(!is_user_alive(id) || equal(entclassname, "func_door") && dmg >= 0 || !(pev(id, pev_flags) & FL_ONGROUND2) && !IsOnLadder(id))
718 {
719 if(!AutoPaused[id])
720 {
721 client_print(id, print_center, "This command is not available to you at this point")
722 return PLUGIN_HANDLED
723 }
724 }
725 if(!get_pcvar_num(kz_pause))
726 {
727 client_print(id, print_center, "This command is not available to you at this point")
728 return PLUGIN_HANDLED
729 }
730 if(!IsPaused[id])
731 {
732 if(!timer_started[id])
733 {
734 hidetime(id)
735 client_print(id, print_center, "Timer is not started")
736 return PLUGIN_HANDLED
737 }
738 g_pausetime[id] = get_gametime() - timer_time[id]
739 timer_time[id] = 0.0
740 IsPaused[id] = true
741 client_print(id, print_center, "Your timer has been paused")
742 if(!AutoPaused[id])
743 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
744 pev(id, pev_origin, PauseOrigin[id])
745 showtime2(id)
746 }
747 else
748 {
749 if(timer_started[id])
750 {
751 if(AutoPaused[id])
752 {
753 set_pev(id, pev_origin, PauseOrigin[id])
754 AutoPaused[id] = false
755 }
756
757 client_print(id, print_center, "Your timer has been unpaused")
758 if(get_user_noclip(id))
759 noclip(id)
760 timer_time[id] = get_gametime() - g_pausetime[id]
761 }
762 IsPaused[id] = false
763 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
764 if(user_has_scout[id] || gochecknumbers[id]>=1)
765 showtime2(id)
766 else
767 showtime(id)
768 }
769 return PLUGIN_HANDLED
770}
771
772public timer_toggle(id)
773{
774 if(show_timer[id]==false)
775 {
776 ColorChat(id,BLUE,"^1[KZ] Timer: ^3enabled")
777 show_timer[id] = true
778 }
779 else if(show_timer[id]==true)
780 {
781 ColorChat(id,RED,"^1[KZ] Timer: ^3disabled")
782 show_timer[id] = false
783 }
784}
785
786public fw_ThinkEntity(iEnt)
787{
788 if(pev_valid(iEnt))
789 {
790 static ClassName[32]
791 pev(iEnt, pev_classname, ClassName, 31)
792
793 if(get_pcvar_num(kz_show_timer) > 0 && equal(ClassName, "kz_time_think"))
794 {
795 fw_TimeThink()
796 set_pev(iEnt, pev_nextthink, get_gametime() + 0.08 )
797 }
798 }
799}
800
801public fw_TimeThink()
802{
803 new Alive[32], Dead[32], alivePlayers, deadPlayers
804 new Float:kreedztime, Float:isec, imin
805 get_players(Alive, alivePlayers, "ach")
806 get_players(Dead, deadPlayers, "bch")
807 for(new i=0;i<alivePlayers;i++)
808 {
809 if(in_run[Alive[i]] && show_timer[Alive[i]])
810 {
811 if(ShowTime[Alive[i]] == 1)
812 {
813 kreedztime = get_gametime() - (IsPaused[Alive[i]] ? get_gametime() - g_pausetime[Alive[i]] : timer_time[Alive[i]])
814 imin = floatround(kreedztime , floatround_floor)/60
815 isec = kreedztime - (60*imin)
816 set_hudmessage(100, 100, 100, 0.0265, 0.4764, 0, 0.0, 0.2, 0.0, 0.0, 2)
817 if(checknumbers[Alive[i]] > 0)
818 show_hudmessage(Alive[i], "%02d:%s%.2f (%d|%d) %s",imin,isec < 10 ? "0" : "",isec,checknumbers[Alive[i]],gochecknumbers[Alive[i]], IsPaused[Alive[i]] ? "| *Paused*" : "")
819 else
820 show_hudmessage(Alive[i], "%02d:%s%.2f %s",imin,isec < 10 ? "0" : "",isec, IsPaused[Alive[i]] ? "| *Paused*" : "")
821 }
822 else if(ShowTime[Alive[i]] == 2)
823 kz_showtime_roundtime(Alive[i], floatround(kreedztime))
824 }
825 }
826 for(new i=0;i<deadPlayers;i++)
827 {
828 new specmode = pev(Dead[i], pev_iuser1)
829 if(specmode == 2 || specmode == 4)
830 {
831 new target = pev(Dead[i], pev_iuser2)
832 if(target != Dead[i])
833 if(is_user_alive(target) && in_run[target])
834 {
835 kreedztime = get_gametime() - (IsPaused[target] ? get_gametime() - g_pausetime[target] : timer_time[target])
836 imin = floatround(kreedztime , floatround_floor)/60
837 isec = kreedztime - (60*imin)
838 if(checknumbers[target] > 0)
839 client_print(Dead[i], print_center,"[ %02d:%s%.2f ] (%d|%d) %s",imin,isec < 10 ? "0" : "",isec,checknumbers[target], gochecknumbers[target], IsPaused[target] ? "| *Paused*" : "")
840 else if(!is_user_bot(target))
841 client_print(Dead[i], print_center, "[ %02d:%s%.2f ] %s",imin,isec < 10 ? "0" : "",isec,IsPaused[target] ? "| *Paused*" : "")
842 }
843 }
844 }
845}
846
847public block_sound(entity, channel, const sound[]) {
848 for(new i; i<sizeof g_soundlist; i++)
849 {
850 if( equali(sound, g_soundlist[i]) )
851 return FMRES_SUPERCEDE
852 }
853 for(new i; i<sizeof g_bot_soundlist; i++)
854 {
855 if(is_user_bot(entity) && equali(sound, g_bot_soundlist[i]))
856 return FMRES_SUPERCEDE
857 }
858 return FMRES_IGNORED
859}
860
861public BlockRadio(id)
862{
863 if(get_pcvar_num(kz_use_radio) == 1)
864 return PLUGIN_CONTINUE
865 else
866 {
867 client_print(id, print_center, "This command is not available to you at this point")
868 return PLUGIN_HANDLED
869 }
870 return PLUGIN_HANDLED
871}
872
873public BlockDrop(id)
874{
875 if(get_pcvar_num(kz_drop_weapons) == 1 && !timer_started[id])
876 return PLUGIN_CONTINUE
877 else
878 {
879 client_print(id, print_center, "This command is not available to you at this point")
880 return PLUGIN_HANDLED
881 }
882 return PLUGIN_HANDLED
883}
884
885public BlockBuy(id)
886{
887 return PLUGIN_HANDLED
888}
889
890public Ham_PlayerKilled_P(id) {
891 if(!is_user_bot(id))
892 set_task(1.0, "CmdRespawn", id)
893 if(timer_started[id])
894 hidetime(id)
895 return HAM_IGNORED
896}
897
898public CmdRespawn(id)
899{
900 if(get_user_team(id) == 3)
901 return PLUGIN_HANDLED
902 else
903 ExecuteHamB(Ham_CS_RoundRespawn, id)
904 return PLUGIN_HANDLED
905}
906
907public ct(id) {
908 if(get_pcvar_num(kz_block_ct) || get_user_noclip(id)) {
909 client_print(id, print_center, "This command is not available to you at this point")
910 return PLUGIN_HANDLED
911 }
912 new CsTeams:team = cs_get_user_team(id)
913 if(team == CS_TEAM_CT)
914 {
915 if(!(pev(id, pev_flags) & FL_ONGROUND2) && timer_started[id])
916 return PLUGIN_HANDLED
917
918 if(timer_started[id] && in_run[id])
919 {
920 SavePos_Spec(id)
921 if(IsPaused[id])
922 {
923 Pause(id)
924 WasPaused[id]=true
925 hidetime(id)
926 }
927
928 g_pausetime[id] = get_gametime() - timer_time[id]
929 timer_time[id] = 0.0
930 client_print(id, print_center, "Your timer has been paused");
931 }
932 SaveSpecLoc(id)
933 hidetime(id)
934 cs_set_user_team(id,CS_TEAM_SPECTATOR)
935 set_pev(id, pev_solid, SOLID_NOT)
936 set_pev(id, pev_movetype, MOVETYPE_FLY)
937 set_pev(id, pev_effects, EF_NODRAW)
938 set_pev(id, pev_deadflag, DEAD_DEAD)
939 //client_cmd(id, "cup_remove")
940 }
941 else
942 {
943 cs_set_user_team(id,CS_TEAM_CT)
944 set_pev(id, pev_effects, 0)
945 set_pev(id, pev_movetype, MOVETYPE_WALK)
946 set_pev(id, pev_deadflag, DEAD_NO)
947 set_pev(id, pev_takedamage, DAMAGE_AIM)
948 CmdRespawn(id)
949 LoadSpecLoc(id)
950
951 if(in_run[id])
952 {
953 Verif(id,0)
954 timer_time[id] = get_gametime() - g_pausetime[id] + timer_time[id]
955 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
956 IsPaused[id] = true
957 if(user_has_scout[id] || IsPaused[id])
958 set_task(0.1, "showtime2", id)
959 else
960 set_task(0.1, "showtime", id)
961 }
962 if(WasPaused[id])
963 {
964 Pause(id)
965 WasPaused[id]=false
966 showtime2(id)
967 }
968 }
969 return PLUGIN_HANDLED
970}
971
972public SaveSpecLoc(id)
973{
974 if(is_user_alive(id))
975 {
976 if(entity_get_int(id, EV_INT_flags) & FL_ONGROUND)
977 {
978 entity_get_vector(id, EV_VEC_origin, SpecLoc[id][0])
979 entity_get_vector(id, EV_VEC_v_angle, SpecLoc[id][1])
980
981 return PLUGIN_HANDLED
982 }
983 }
984
985 return PLUGIN_CONTINUE
986}
987
988public LoadSpecLoc(id)
989{
990 if(is_user_alive(id))
991 {
992 entity_set_vector(id, EV_VEC_origin, SpecLoc[id][0])
993 entity_set_vector(id, EV_VEC_angles, SpecLoc[id][1])
994 set_pev(id, pev_fixangle, 1)
995
996 return PLUGIN_HANDLED
997 }
998
999 return PLUGIN_CONTINUE
1000}
1001
1002public SavePosLoc(id)
1003{
1004 if(is_user_alive(id))
1005 {
1006 if(entity_get_int(id, EV_INT_flags) & FL_ONGROUND)
1007 {
1008 entity_get_vector(id, EV_VEC_origin, PosLoc[id][0])
1009 entity_get_vector(id, EV_VEC_v_angle, PosLoc[id][1])
1010
1011 return PLUGIN_HANDLED
1012 }
1013 }
1014
1015 return PLUGIN_CONTINUE
1016}
1017
1018public LoadPosLoc(id)
1019{
1020 if(is_user_alive(id))
1021 {
1022 entity_set_vector(id, EV_VEC_origin, PosLoc[id][0])
1023 entity_set_vector(id, EV_VEC_angles, PosLoc[id][1])
1024 set_pev(id, pev_fixangle, 1)
1025
1026 return PLUGIN_HANDLED
1027 }
1028
1029 return PLUGIN_CONTINUE
1030}
1031
1032public fwdClientKill(id)
1033{
1034 if(get_pcvar_num(kz_block_kill))
1035 {
1036 return FMRES_SUPERCEDE
1037 }
1038
1039 return FMRES_IGNORED
1040}
1041
1042public kz_tele_menu(id)
1043{
1044 if(!(get_user_flags(id) & KZ_VIP))
1045 {
1046 client_print(id, print_center, "This command is not available to you at this point")
1047 return PLUGIN_HANDLED
1048 }
1049
1050 new menu = menu_create("\r[INS] \dTeleport Menu", "tele_menuhandler")
1051
1052 new players[32], pnum
1053 new szName[32], szTempid[10]
1054
1055 get_players(players, pnum)
1056 for(new i; i<pnum;i++)
1057 {
1058 tempid = players[i]
1059
1060 if(is_user_alive(tempid) && id != tempid)
1061 {
1062 get_user_name(tempid, szName, 31)
1063 num_to_str(tempid, szTempid, 9)
1064 menu_additem(menu, szName, szTempid, 0)
1065 }
1066 else if(pnum < 2)
1067 {
1068 client_print(id, print_center, "This command is not available to you at this point");
1069 return PLUGIN_HANDLED
1070 }
1071
1072 if(!is_user_alive(id))
1073 ct(id)
1074
1075 }
1076 menu_display(id, menu, 0)
1077 return PLUGIN_HANDLED
1078}
1079
1080public tele_menuhandler(id, menu, item)
1081{
1082 if(item == MENU_EXIT)
1083 {
1084 kz_menu(id)
1085 return PLUGIN_HANDLED
1086 }
1087
1088 new data[6], iName[64]
1089 new access, callback
1090 menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
1091
1092 tempid = str_to_num(data)
1093
1094 if(!get_pcvar_num(kz_cheats))
1095 {
1096 ColorChat(id, RED, "^1[KZ] ^3Cheats are currently disabled!")
1097 return PLUGIN_HANDLED
1098 }
1099
1100 if(timer_started[id] == true)
1101 {
1102 ColorChat(id, RED, "^x01[KZ]^x03 You cannot teleport during a run!")
1103 kz_tele_menu(id)
1104 return PLUGIN_HANDLED
1105 }
1106
1107 if(is_user_alive(id) && is_user_alive(tempid))
1108 {
1109 new name[32]
1110 get_user_name(id, name, 31)
1111
1112 new name1[32]
1113 get_user_name(tempid, name1, 31)
1114
1115 new origin[3]
1116 get_user_origin(tempid, origin)
1117
1118 origin[2] = origin[2] + get_pcvar_num(kz_teleport_height)
1119
1120 set_user_origin(id, origin)
1121
1122 if(get_pcvar_num(kz_teleport_notification))
1123 {
1124 ColorChat(id, BLUE, "^x01[KZ]^x03 You have been teleported to^x04 %s.", name1)
1125 ColorChat(tempid, BLUE, "^x01[KZ]^x03 ^x04%s^x03 has been teleported to you.", name)
1126 }
1127 }
1128 menu_destroy(menu)
1129 kz_tele_menu(id)
1130 return PLUGIN_HANDLED
1131}
1132
1133public BlockPickup(ent, id)
1134{
1135 if(get_pcvar_num(kz_block_pickup))
1136 {
1137 if(cs_get_user_team (id) == CS_TEAM_CT)
1138 return PLUGIN_HANDLED
1139 }
1140
1141 return PLUGIN_CONTINUE
1142}
1143
1144public maxspeedmsg(id)
1145{
1146 if(!is_user_alive(id))
1147 {
1148 client_print(id, print_center, "This command is not available to you at this point")
1149 return PLUGIN_HANDLED
1150 }
1151
1152 ColorChat(id, BLUE, "^1[KZ] ^3Maxspeed of this weapon is ^4%d ^3units^1.",floatround(get_user_maxspeed(id), floatround_floor))
1153 return PLUGIN_HANDLED
1154}
1155
1156public weapons(id)
1157{
1158 if(!get_pcvar_num(kz_other_weapons) || !is_user_alive(id) || timer_started[id])
1159 {
1160 client_print(id, print_center, "This command is not available to you at this point")
1161 return PLUGIN_HANDLED
1162 }
1163
1164 for(new i = 0; i < 7; i++)
1165 if(!user_has_weapon(id, other_weapons[i]))
1166 {
1167 new item
1168 item = give_item(id, other_weapons_name[i])
1169 cs_set_weapon_ammo(item, 0)
1170 }
1171
1172
1173 return PLUGIN_HANDLED
1174}
1175
1176public scout(id)
1177{
1178 if(!get_pcvar_num(kz_other_weapons) || !is_user_alive(id) || timer_started[id] || !get_user_flags(id) && ADMIN_BAN)
1179 {
1180 client_print(id, print_center, "This command is not available to you at this point")
1181 return PLUGIN_HANDLED
1182 }
1183
1184 give_item(id,"weapon_scout")
1185 cs_set_weapon_ammo(find_ent_by_owner(-1,"weapon_scout",id),0)
1186
1187 return PLUGIN_HANDLED
1188}
1189
1190public cc(id)
1191{
1192 if(get_pcvar_num(kz_motd_enabled))
1193 {
1194 show_motd(id, "cosy.txt")
1195 }
1196}
1197
1198public xj(id)
1199{
1200 if(get_pcvar_num(kz_motd_enabled))
1201 {
1202 show_motd(id, "xj.txt")
1203 }
1204}
1205
1206public CheckAir(id) {
1207 if(get_pcvar_num(kz_airace) == 10)
1208 {
1209 set_hudmessage(0, 255, 0, 0.04, 0.7, _, _, 3.5, _, _, 3)
1210 show_hudmessage(id, "Server runs: aa10")
1211 }
1212 else if(get_pcvar_num(kz_airace) == 100)
1213 {
1214 set_hudmessage(255, 0, 0, 0.04, 0.7, _, _, 3.5, _, _, 3)
1215 show_hudmessage(id, "Server runs: aa100")
1216 }
1217
1218 return PLUGIN_HANDLED
1219}
1220
1221public customStart(id)
1222{
1223 if(!(pev(id, pev_flags) & FL_ONGROUND2) && !IsOnLadder(id))
1224 {
1225 client_print(id, print_center, "This command is not available to you at this point")
1226 return PLUGIN_HANDLED
1227 }
1228 entity_get_vector(id, EV_VEC_origin, CustomStartPos[id][0])
1229 entity_get_vector(id, EV_VEC_v_angle, CustomStartPos[id][1])
1230
1231 client_print(id, print_center, "Custom Start position set")
1232
1233 CustomStart[id] = true
1234
1235 return PLUGIN_HANDLED
1236}
1237
1238public m_goStart(id)
1239{
1240 if(!is_user_alive(id) || get_user_noclip(id) || IsPaused[id])
1241 {
1242 client_print(id, print_center, "This command is not available to you at this point")
1243 return PLUGIN_HANDLED
1244 }
1245
1246 if(timer_started[id] && in_run[id])
1247 {
1248 AutoPaused[id] = true
1249 if(checknumbers[id]==0)
1250 CheckPoint(id)
1251 Pause(id)
1252 }
1253
1254 if(!menu_user[id])
1255 menu_user[id] = true
1256
1257 if(get_pcvar_num(kz_save_autostart) == 1 && AutoStart [id])
1258 {
1259 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1260 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING)
1261 set_pev(id, pev_origin, SavedStart [id])
1262 }
1263 else if(CustomStart[id])
1264 {
1265 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1266 set_pev(id, pev_origin, DefaultStartPos)
1267 set_pev(id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
1268 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING)
1269 set_pev(id, pev_fuser2, 0.0)
1270 entity_set_vector(id, EV_VEC_origin, CustomStartPos[id][0])
1271 entity_set_vector(id, EV_VEC_angles, CustomStartPos[id][1])
1272 set_pev(id, pev_fixangle, 1)
1273 }
1274 else if(DefaultStart)
1275 {
1276 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1277 set_pev(id, pev_origin, DefaultStartPos)
1278 set_pev(id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
1279 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING)
1280 set_pev(id, pev_fuser2, 0.0)
1281 engfunc(EngFunc_SetSize, id,{-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 })
1282 entity_set_vector(id, EV_VEC_angles, DefaultStartPosAng)
1283 set_pev(id, pev_fixangle , 1)
1284 }
1285 else
1286 {
1287 client_print(id, print_center, "No start position is set for this map")
1288
1289 CmdRespawn(id)
1290 }
1291
1292
1293 if(pev(id, pev_flags) & FL_FROZEN)
1294 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1295 usedhook[id] = false
1296 reset_spectimer(id)
1297
1298 return PLUGIN_HANDLED
1299}
1300
1301public goStart(id)
1302{
1303 if(!is_user_alive(id) || get_user_noclip(id))
1304 {
1305 client_print(id, print_center, "This command is not available to you at this point")
1306 return PLUGIN_HANDLED
1307 }
1308
1309 if(!IsPaused[id] && timer_started[id] && in_run[id])
1310 {
1311 AutoPaused[id] = true
1312 if(checknumbers[id]==0)
1313 CheckPoint(id)
1314 Pause(id)
1315 }
1316
1317 if(menu_user[id])
1318 menu_user[id] = false
1319
1320 if(get_pcvar_num(kz_save_autostart) == 1 && AutoStart [id])
1321 {
1322 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1323 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING)
1324 set_pev(id, pev_origin, SavedStart [id])
1325 }
1326 else if(CustomStart[id])
1327 {
1328 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1329 set_pev(id, pev_origin, DefaultStartPos)
1330 set_pev(id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
1331 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING)
1332 set_pev(id, pev_fuser2, 0.0)
1333 entity_set_vector(id, EV_VEC_origin, CustomStartPos[id][0])
1334 entity_set_vector(id, EV_VEC_angles, CustomStartPos[id][1])
1335 set_pev(id, pev_fixangle, 1)
1336 }
1337 else if(DefaultStart)
1338 {
1339 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1340 set_pev(id, pev_origin, DefaultStartPos)
1341 set_pev(id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
1342 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING)
1343 set_pev(id, pev_fuser2, 0.0)
1344 engfunc(EngFunc_SetSize, id,{-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 })
1345 entity_set_vector(id, EV_VEC_angles, DefaultStartPosAng)
1346 set_pev(id, pev_fixangle , 1)
1347 }
1348 else
1349 {
1350 client_print(id, print_center, "No start position is set for this map")
1351
1352 CmdRespawn(id)
1353 }
1354
1355 if(pev(id, pev_flags) & FL_FROZEN)
1356 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1357 usedhook[id] = false
1358 reset_spectimer(id)
1359
1360 return PLUGIN_HANDLED
1361}
1362
1363public setStart(id)
1364{
1365 if(!(pev(id, pev_flags) & FL_ONGROUND2) && !IsOnLadder(id))
1366 {
1367 client_print(id, print_center, "This command is not available to you at this point")
1368 return PLUGIN_HANDLED
1369 }
1370
1371 if(!(get_user_flags(id) & ADMIN_BAN))
1372 {
1373 client_print(id, print_center, "This command is not available to you at this point")
1374 ColorChat(id, GREEN, "^x01[KZ] ^x01Try /customstart or /cs to set your personal start position.")
1375
1376 return PLUGIN_HANDLED
1377 }
1378
1379 new Float:origin[3]
1380
1381 entity_get_vector(id, EV_VEC_origin , origin)
1382 entity_get_vector(id, EV_VEC_v_angle, angles)
1383
1384 kz_set_start(MapName, origin, angles)
1385
1386 AutoStart[id] = false
1387 client_print(id, print_center, "Start position set")
1388 return PLUGIN_HANDLED
1389}
1390
1391public Ham_CBasePlayer_Killed_Post(id)
1392{
1393 if(get_pcvar_num(kz_respawn_ct) == 1)
1394 {
1395 if(cs_get_user_team(id) == CS_TEAM_CT)
1396 {
1397 set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)
1398 cs_set_user_deaths(id, 0)
1399 set_user_frags(id, 0)
1400 }
1401 }
1402}
1403
1404public cmd_givetake(id,level,cid)
1405{
1406 if(!cmd_access(id,level,cid,2))
1407 {
1408 return PLUGIN_HANDLED
1409 }
1410 new arg1[32]
1411 read_argv(1,arg1,31)
1412 new target = cmd_target(id,arg1,9)
1413 if(!target)
1414 {
1415 return PLUGIN_HANDLED
1416 }
1417 new name[32]
1418 get_user_name(target,name,31)
1419 if(get_user_flags(target) & ADMIN_IMMUNITY)
1420 {
1421 console_print(id,"[AMXX] Cannot give/take hook from admin %s.",name)
1422 return PLUGIN_HANDLED
1423 }
1424 new arg0[32]
1425 read_argv(0,arg0,31)
1426 if(containi(arg0,"give")!=-1)
1427 {
1428 if(containi(arg0,"hook")!=-1)
1429 {
1430 if(has_hook[target])
1431 {
1432 console_print(id,"[AMXX] %s already has hook",name)
1433 }
1434 else
1435 {
1436 has_hook[target]=true
1437 console_print(id,"[AMXX] %s has been given hook",name)
1438 client_print(target,print_chat,"[AMXX] An admin has given you hook. Use: bind key +hook")
1439 }
1440 }
1441 }
1442 if(containi(arg0,"take")!=-1)
1443 {
1444 if(containi(arg0,"hook")!=-1)
1445 {
1446 if(!has_hook[target])
1447 {
1448 console_print(id,"[AMXX] %s doesn't have hook",name)
1449 }
1450 else
1451 {
1452 has_hook[target]=false
1453 console_print(id,"[AMXX] %s's hook has been taken away.",name)
1454 client_print(target,print_chat,"[AMXX] An admin has taken your hook away.")
1455 }
1456 }
1457 }
1458 return PLUGIN_HANDLED
1459}
1460
1461public hook_toggle(id)
1462{
1463 if(!(get_user_flags(id)&KZ_VIP))
1464 {
1465 client_print(id, print_center, "This command is not available to you at this point")
1466 return PLUGIN_HANDLED
1467 }
1468
1469 if(has_hook[id])
1470 {
1471 if(hook[id]) hook_off(id)
1472 else hook_on(id)
1473 }
1474
1475 return PLUGIN_HANDLED
1476}
1477
1478public hook_on(id)
1479{
1480 if(!get_pcvar_num(kz_cheats))
1481 {
1482 client_print(id, print_center, "This command is not available to you at this point")
1483 return PLUGIN_HANDLED
1484 }
1485
1486 AutoPaused[id] = false
1487
1488 if(get_user_flags(id) & KZ_VIP || has_hook[id])
1489 {
1490 if(hook[id])
1491 {
1492 return PLUGIN_HANDLED
1493 }
1494 set_user_gravity(id,0.0)
1495 set_task(0.1,"hook_prethink",id+10000,"",0,"b")
1496 hook[id]=true
1497 usedhook[id]=true
1498 hook_to[id][0]=999999
1499 hook_prethink(id+10000)
1500
1501 detect_cheat(id,"Hook")
1502 anticheat[id] = get_gametime()
1503 }
1504 else
1505 client_print(id, print_center, "This command is not available to you at this point")
1506 return PLUGIN_HANDLED
1507}
1508
1509public hook_off(id)
1510{
1511 AutoPaused[id] = false
1512
1513 groundtime[id] = get_gametime()
1514
1515 if(is_user_alive(id)) set_user_gravity(id)
1516 if(hook[id] == true)
1517 timer_started[id] = false
1518
1519 hook[id]=false
1520 return PLUGIN_HANDLED
1521}
1522
1523public hook_prethink(id)
1524{
1525 id -= 10000
1526 if(!is_user_alive(id))
1527 {
1528 hook[id]=false
1529 }
1530 if(!hook[id])
1531 {
1532 remove_task(id+10000)
1533 return PLUGIN_HANDLED
1534 }
1535
1536 static origin1[3]
1537 get_user_origin(id,origin1)
1538 if(hook_to[id][0]==999999)
1539 {
1540 static origin2[3]
1541 get_user_origin(id,origin2,3)
1542 hook_to[id][0]=origin2[0]
1543 hook_to[id][1]=origin2[1]
1544 hook_to[id][2]=origin2[2]
1545 }
1546
1547 static Float:velocity[3]
1548 velocity[0] = (float(hook_to[id][0]) - float(origin1[0])) * 3.0
1549 velocity[1] = (float(hook_to[id][1]) - float(origin1[1])) * 3.0
1550 velocity[2] = (float(hook_to[id][2]) - float(origin1[2])) * 3.0
1551 static Float:y
1552 y = velocity[0]*velocity[0] + velocity[1]*velocity[1] + velocity[2]*velocity[2]
1553 static Float:x
1554 x = (get_pcvar_float(hook_speed_cvar) * 120.0) / floatsqroot(y)
1555 velocity[0] *= x
1556 velocity[1] *= x
1557 velocity[2] *= x
1558 set_velo(id,velocity)
1559 return PLUGIN_CONTINUE
1560}
1561
1562public get_origin(ent,Float:origin[3])
1563{
1564#if defined engine
1565 return entity_get_vector(id,EV_VEC_origin,origin)
1566#else
1567 return pev(ent,pev_origin,origin)
1568#endif
1569}
1570
1571public set_velo(id,Float:velocity[3])
1572{
1573#if defined engine
1574 return set_user_velocity(id,velocity)
1575#else
1576 return set_pev(id,pev_velocity,velocity)
1577#endif
1578}
1579
1580public get_velo(id,Float:velocity[3])
1581{
1582#if defined engine
1583 return get_user_velocity(id,velocity)
1584#else
1585 return pev(id,pev_velocity,velocity)
1586#endif
1587}
1588
1589public is_valid_ent2(ent)
1590{
1591#if defined engine
1592 return is_valid_ent(ent)
1593#else
1594 return pev_valid(ent)
1595#endif
1596}
1597
1598public get_solidity(ent)
1599{
1600#if defined engine
1601 return entity_get_int(ent,EV_INT_solid)
1602#else
1603 return pev(ent,pev_solid)
1604#endif
1605}
1606
1607stock set_rendering2(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16)
1608{
1609#if defined engine
1610 return set_rendering(index,fx,r,g,b,render,amount)
1611#else
1612 set_pev(index, pev_renderfx, fx)
1613 new Float:RenderColor[3]
1614 RenderColor[0] = float(r)
1615 RenderColor[1] = float(g)
1616 RenderColor[2] = float(b)
1617 set_pev(index, pev_rendercolor, RenderColor)
1618 set_pev(index, pev_rendermode, render)
1619 set_pev(index, pev_renderamt, float(amount))
1620 return 1
1621#endif
1622}
1623
1624public MessageScoreAttrib(iMsgID, iDest, iReceiver)
1625{
1626 if(get_pcvar_num(kz_vip))
1627 {
1628 new iPlayer = get_msg_arg_int(1)
1629 if(is_user_alive(iPlayer) && (get_user_flags(iPlayer) & KZ_VIP))
1630 {
1631 set_msg_arg_int(2, ARG_BYTE, SCOREATTRIB_VIP)
1632 }
1633 }
1634}
1635
1636public detect_cheat(id,reason[])
1637{
1638 if(timer_started[id] && get_pcvar_num(kz_cheatdetect) == 1)
1639 {
1640 hidetime(id)
1641 timer_started[id] = false
1642 in_run[id] = false
1643 client_cmd(id, "spk fvox/blip")
1644 if(IsPaused[id])
1645 {
1646 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1647 IsPaused[id] = false
1648 }
1649 if(get_pcvar_num(kz_show_timer) > 0)
1650 kz_showtime_roundtime(id, 0)
1651 client_print(id, print_center, "%s detected", reason)
1652 }
1653}
1654
1655public CheckPoint(id)
1656{
1657 if(!get_pcvar_num(kz_cheats) || !get_pcvar_num(kz_checkpoints) || !is_user_alive(id) || IsPaused[id] || !(pev(id, pev_flags) & FL_ONGROUND2) && !IsOnLadder(id))
1658 {
1659 client_print(id, print_center, "This command is not available to you at this point")
1660 return PLUGIN_HANDLED
1661 }
1662
1663 entity_get_vector(id, EV_VEC_origin, CPangles[id][0])
1664 entity_get_vector(id, EV_VEC_v_angle, CPangles[id][1])
1665
1666 pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id] ? 1 : 0])
1667 g_bCpAlternate[id] = !g_bCpAlternate[id]
1668 checknumbers[id]++
1669 return PLUGIN_HANDLED
1670}
1671
1672public m_GoCheck(id)
1673{
1674 if(!is_user_alive(id) || checknumbers[id] == 0)
1675 {
1676 client_print(id, print_center, "This command is not available to you at this point")
1677 return PLUGIN_HANDLED
1678 }
1679
1680 if(!menu_user[id])
1681 menu_user[id] = true
1682
1683 if(timer_started[id] && gochecknumbers[id] == 0)
1684 {
1685 showtime2(id)
1686 client_cmd(id, "spk fvox/blip")
1687 }
1688
1689 if(get_pcvar_num(kz_cp_angles) == 1)
1690 {
1691 entity_set_vector(id, EV_VEC_angles, CPangles[id][1])
1692 set_pev(id, pev_fixangle, 1)
1693 }
1694
1695 if(IsPaused[id])
1696 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
1697
1698 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1699 set_pev(id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
1700 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING)
1701 set_pev(id, pev_fuser2, 0.0)
1702 set_pev(id, pev_origin, Checkpoints[ id ][ !g_bCpAlternate[id] ])
1703
1704 gochecknumbers[id]++
1705
1706 return PLUGIN_HANDLED
1707}
1708
1709public GoCheck(id)
1710{
1711 if(!is_user_alive(id) || checknumbers[id] == 0)
1712 {
1713 client_print(id, print_center, "This command is not available to you at this point")
1714 return PLUGIN_HANDLED
1715 }
1716
1717 if(menu_user[id])
1718 menu_user[id] = false
1719
1720 if(timer_started[id] && gochecknumbers[id] == 0)
1721 {
1722 showtime2(id)
1723 client_cmd(id, "spk fvox/blip")
1724 }
1725
1726 if(get_pcvar_num(kz_cp_angles) == 1)
1727 {
1728 entity_set_vector(id, EV_VEC_angles, CPangles[id][1])
1729 set_pev(id, pev_fixangle, 1)
1730 }
1731
1732 if(IsPaused[id])
1733 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
1734
1735 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1736 set_pev(id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
1737 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING)
1738 set_pev(id, pev_fuser2, 0.0)
1739 set_pev(id, pev_origin, Checkpoints[ id ][ !g_bCpAlternate[id] ])
1740
1741 gochecknumbers[id]++
1742
1743 return PLUGIN_HANDLED
1744}
1745
1746public Stuck(id)
1747{
1748 if(checknumbers[id] < 2 || !is_user_alive(id))
1749 {
1750 client_print(id, print_center, "This command is not available to you at this point")
1751 return PLUGIN_HANDLED
1752 }
1753
1754 set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
1755 set_pev(id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
1756 set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING)
1757 set_pev(id, pev_fuser2, 0.0)
1758 engfunc(EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 })
1759 set_pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id]])
1760 g_bCpAlternate[id] = !g_bCpAlternate[id]
1761 gochecknumbers[id]++
1762
1763 return PLUGIN_HANDLED
1764}
1765
1766public reset_checkpoints(id)
1767{
1768 checknumbers[id] = 0
1769 gochecknumbers[id] = 0
1770 timer_started[id] = false
1771 in_run[id] = false
1772 timer_time[id] = 0.0
1773 AutoPaused[id] = false
1774 if(IsPaused[id])
1775 {
1776 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1777 IsPaused[id] = false
1778 }
1779 if(get_pcvar_num(kz_show_timer) > 0)
1780 kz_showtime_roundtime(id, 0)
1781 hidetime(id)
1782 return PLUGIN_HANDLED
1783}
1784
1785public noclip(id)
1786{
1787 if(!get_pcvar_num(kz_cheats) || !is_user_connected(id) || !is_user_alive(id))
1788 {
1789 client_print(id, print_center, "This command is not available to you at this point")
1790 return PLUGIN_HANDLED
1791 }
1792
1793 new noclip = !get_user_noclip(id)
1794 set_user_noclip(id, noclip)
1795 if(IsPaused[id] && (get_pcvar_num(kz_noclip_pause) == 1))
1796 {
1797 if(noclip)
1798 {
1799 pev(id, pev_origin, NoclipPos[id])
1800 set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
1801 }
1802 else
1803 {
1804 set_pev(id, pev_origin, NoclipPos[id])
1805 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
1806 }
1807 }
1808 else if(noclip)
1809 detect_cheat(id,"Noclip")
1810
1811 return PLUGIN_HANDLED
1812}
1813
1814stock kz_set_start(const map[], Float:origin[3], Float:ViewAngles[3])
1815{
1816 new realfile[128], tempfile[128], formatorigin[50]
1817 formatex(realfile, 127, "%s/%s", Kzdir, KZ_STARTFILE)
1818 formatex(tempfile, 127, "%s/%s", Kzdir, KZ_STARTFILE_TEMP)
1819 formatex(formatorigin, 99, "%f %f %f %f %f %f", origin[0], origin[1], origin[2], ViewAngles[0], ViewAngles[1], ViewAngles[2])
1820 DefaultStartPosAng = ViewAngles
1821 DefaultStartPos = origin
1822 DefaultStart = true
1823
1824 new file = fopen(tempfile, "wt")
1825 new vault = fopen(realfile, "rt")
1826
1827 new data[128], key[64]
1828 new bool:replaced = false
1829
1830 while(!feof(vault))
1831 {
1832 fgets(vault, data, 127)
1833 parse(data, key, 63)
1834
1835 if(equal(key, map) && !replaced)
1836 {
1837 fprintf(file, "%s %s^n", map, formatorigin)
1838
1839 replaced = true
1840 }
1841 else
1842 {
1843 fputs(file, data)
1844 }
1845 }
1846
1847 if(!replaced)
1848 {
1849 fprintf(file, "%s %s^n", map, formatorigin)
1850 }
1851
1852 fclose(file)
1853 fclose(vault)
1854
1855 delete_file(realfile)
1856 while(!rename_file(tempfile, realfile, 1)) {}
1857}
1858
1859stock kz_showtime_roundtime(id, time)
1860{
1861 if(is_user_connected(id))
1862 {
1863 message_begin(MSG, get_user_msgid("RoundTime"), _, id)
1864 write_short(time + 1)
1865 message_end()
1866 }
1867}
1868
1869stock kz_print_config(id, const msg[])
1870{
1871 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, id)
1872 write_byte(id)
1873 write_string(msg)
1874 message_end()
1875}
1876
1877stock kz_remplace_colors(message[], len)
1878{
1879 replace_all(message, len, "!g", "^x04")
1880 replace_all(message, len, "!t", "^x03")
1881 replace_all(message, len, "!y", "^x01")
1882}
1883
1884stock kz_hud_message(id, const message[], {Float,Sql,Result,_}:...)
1885{
1886 static msg[192], colors[12], r[4], g[4], b[4]
1887 vformat(msg, 191, message, 3)
1888
1889 get_pcvar_string(kz_hud_color, colors, 11)
1890 parse(colors, r, 3, g, 3, b, 4)
1891
1892 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)
1893 ShowSyncHudMsg(id, hud_message, msg)
1894}
1895
1896#if defined USE_SQL
1897stock GetNewRank(id, type)
1898{
1899 new createinto[1001]
1900
1901 new cData[2]
1902 cData[0] = id
1903 cData[1] = type
1904
1905 formatex(createinto, 1000, "SELECT authid FROM `%s` WHERE mapname='%s' ORDER BY time LIMIT 9999", type == PRO_TOP ? "kz_pro15" : "kz_nub15", MapName)
1906 SQL_ThreadQuery(g_SqlTuple, "GetNewRank_QueryHandler", createinto, cData, 2)
1907}
1908
1909stock kz_update_plrname(id, const newname[32] = "")
1910{
1911 new createinto[1001], steam[32], name[32]
1912 get_user_authid(id, steam, 31)
1913
1914 if( equal(newname, "") )
1915 get_user_name(id, name, 31)
1916 else
1917 name = newname
1918
1919 replace_all(name, 31, "\", "")
1920 replace_all(name, 31, "`", "\`")
1921 replace_all(name, 31, "'", "\'")
1922
1923 formatex(createinto, 1000, "UPDATE `kz_pro15` SET name='%s' WHERE authid='%s'", name, steam)
1924 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
1925 formatex(createinto, 1000, "UPDATE `kz_nub15` SET name='%s' WHERE authid='%s'", name, steam)
1926 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
1927
1928 //ColorChat(id, BLUE, "^x04[nobkz] ^x03Your new name for Top15 is: ^x04%s", name)
1929
1930 return 1
1931}
1932#endif
1933
1934public FwdSpawnWeaponbox(iEntity)
1935{
1936 if(get_pcvar_num(kz_remove_drops) == 1)
1937 {
1938 set_pev(iEntity, pev_flags, FL_KILLME)
1939 dllfunc(DLLFunc_Think, iEntity)
1940 }
1941
1942 return HAM_IGNORED
1943}
1944
1945public FwdHamDoorSpawn(iEntity)
1946{
1947 static const szNull[ ] = "common/null.wav"
1948
1949 new Float:flDamage
1950 pev(iEntity, pev_dmg, flDamage)
1951
1952 if(flDamage < -999.0) {
1953 set_pev(iEntity, pev_noise1, szNull)
1954 set_pev(iEntity, pev_noise2, szNull)
1955 set_pev(iEntity, pev_noise3, szNull)
1956
1957 if(!HealsOnMap)
1958 HealsOnMap = true
1959 }
1960}
1961
1962public TaskSpectator(id)
1963{
1964 cs_set_user_team(id, CS_TEAM_SPECTATOR)
1965}
1966
1967public model_menu(id) {
1968 new title[64]
1969 formatex(title, 63, "\r[INS] \dModel Menu")
1970 new menu = menu_create(title, "model_menuhandler")
1971
1972 menu_additem(menu, "Terrorists", "1")
1973 menu_additem(menu, "Counter-Terrorists", "2")
1974 menu_additem(menu, "Custom \y[VIP]", "3")
1975
1976 menu_display(id, menu, 0)
1977
1978 return PLUGIN_HANDLED
1979}
1980
1981public model_menuhandler(id, menu, item)
1982{
1983 if(item == MENU_EXIT)
1984 {
1985 kz_menu(id)
1986 return PLUGIN_HANDLED
1987 }
1988
1989 switch(item)
1990 {
1991 case 0: terror_menu(id)
1992 case 1: ct_menu(id)
1993 case 2: custom_menu(id)
1994 }
1995
1996 return PLUGIN_CONTINUE
1997}
1998cmdURBAN(id)
1999{
2000 new name[32]
2001 get_user_name(id, name, 31)
2002
2003 if(cs_get_user_team(id) == CS_TEAM_T)
2004 {
2005 ColorChat(id, RED, "^x01[KZ] ^x03This model is only available for Counter-Terrorists.")
2006 }
2007 else if(cs_get_user_team(id) == CS_TEAM_CT)
2008 {
2009 cs_set_user_model(id, "urban")
2010 }
2011 kz_menu(id)
2012}
2013cmdGSG9(id)
2014{
2015 new name[32]
2016 get_user_name(id, name, 31)
2017 if(cs_get_user_team(id) == CS_TEAM_T)
2018 {
2019 ColorChat(id, RED, "^x01[KZ] ^x03This model is only available for Counter-Terrorists.")
2020 }
2021 else if(cs_get_user_team(id) == CS_TEAM_CT)
2022 {
2023 cs_set_user_model(id, "gsg9")
2024 }
2025 kz_menu(id)
2026}
2027cmdSAS(id)
2028{
2029 new name[32]
2030 get_user_name(id, name, 31)
2031
2032 if(cs_get_user_team(id) == CS_TEAM_T)
2033 {
2034 ColorChat(id, RED, "^x01[KZ] ^x03This model is only available for Counter-Terrorists.")
2035 }
2036 else if(cs_get_user_team(id) == CS_TEAM_CT)
2037 {
2038 cs_set_user_model(id, "sas")
2039 }
2040 kz_menu(id)
2041}
2042cmdGIGN(id)
2043{
2044 new name[32]
2045 get_user_name(id, name, 31)
2046
2047 if(cs_get_user_team(id) == CS_TEAM_T)
2048 {
2049 ColorChat(id, RED, "^x01[KZ] ^x03This model is only available for Counter-Terrorists.")
2050 }
2051 else if(cs_get_user_team(id) == CS_TEAM_CT)
2052 {
2053 cs_set_user_model(id, "gign")
2054 }
2055 kz_menu(id)
2056}
2057cmdTERROR(id)
2058{
2059 new name[32]
2060 get_user_name(id, name, 31)
2061
2062 if(cs_get_user_team(id) == CS_TEAM_T)
2063 {
2064 ColorChat(id, RED, "^x01[KZ] ^x03This model is only available for Counter-Terrorists.")
2065 }
2066 else if(cs_get_user_team(id) == CS_TEAM_CT)
2067 {
2068 cs_set_user_model(id, "terror")
2069 }
2070 kz_menu(id)
2071}
2072cmdLEET(id)
2073{
2074 new name[32]
2075 get_user_name(id, name, 31)
2076
2077 if(cs_get_user_team(id) == CS_TEAM_T)
2078 {
2079 ColorChat(id, RED, "^x01[KZ] ^x03This model is only available for Counter-Terrorists.")
2080 }
2081 else if(cs_get_user_team(id) == CS_TEAM_CT)
2082 {
2083 cs_set_user_model(id, "leet")
2084 }
2085 kz_menu(id)
2086}
2087cmdARCTIC(id)
2088{
2089 new name[32]
2090 get_user_name(id, name, 31)
2091
2092 if(cs_get_user_team(id) == CS_TEAM_T)
2093 {
2094 ColorChat(id, RED, "^x01[KZ] ^x03This model is only available for Counter-Terrorists.")
2095 }
2096 else if(cs_get_user_team(id) == CS_TEAM_CT)
2097 {
2098 cs_set_user_model(id, "arctic")
2099 }
2100 kz_menu(id)
2101}
2102cmdGUERILLA(id)
2103{
2104 new name[32]
2105 get_user_name(id, name, 31)
2106
2107 if(cs_get_user_team(id) == CS_TEAM_T)
2108 {
2109 ColorChat(id, RED, "^x01[KZ] ^x03This model is only available for Counter-Terrorists.")
2110 }
2111 else if(cs_get_user_team(id) == CS_TEAM_CT)
2112 {
2113 cs_set_user_model(id, "guerilla")
2114 }
2115 kz_menu(id)
2116}
2117cmdVIP(id)
2118{
2119 new name[32]
2120 get_user_name(id, name, 31)
2121
2122 if(cs_get_user_team(id) == CS_TEAM_T)
2123 {
2124 ColorChat(id, RED, "^x01[KZ] ^x03This model is only available for Counter-Terrorists.")
2125 }
2126 else if(cs_get_user_team(id) == CS_TEAM_CT)
2127 {
2128 cs_set_user_model(id, "vip")
2129 }
2130 kz_menu(id)
2131}
2132
2133public BlockCT(id) {
2134 if(!(get_user_flags(id) & ADMIN_BAN))
2135 {
2136 client_print(id, print_center, "This command is not available to you at this point")
2137 return PLUGIN_HANDLED
2138 }
2139
2140 if(get_pcvar_num(kz_block_ct) == 1)
2141 {
2142 set_pcvar_num(kz_block_ct, 0)
2143 ColorChat(0, RED, "^x01[KZ]^x03 Block CT has been disabled!")
2144 }
2145 else
2146 {
2147 cmdForceSpec()
2148 set_pcvar_num(kz_block_ct, 1)
2149 ColorChat(0, BLUE, "^x01[KZ]^x03 Block CT has been enabled!")
2150 }
2151 return PLUGIN_HANDLED
2152}
2153
2154public cmdForceSpec()
2155{
2156 new aPlayers[32], iPlayersNum
2157 get_players(aPlayers, iPlayersNum, "ae", "CT")
2158
2159 for(new i = 0; i < iPlayersNum; i++)
2160 {
2161 if(!is_user_admin(aPlayers[i]))
2162 {
2163 ct(aPlayers[i])
2164 }
2165 }
2166}
2167
2168public kz_reset_data(id)
2169{
2170 kz_roundtime(id, 0)
2171
2172 return 1
2173}
2174
2175public FwdHamPlayerSpawn(id)
2176{
2177 if(!is_user_alive(id))
2178 return
2179
2180 if(firstspawn[id])
2181 {
2182 if(get_pcvar_num(kz_block_ct))
2183 {
2184 set_pev(id, pev_solid, SOLID_NOT)
2185 set_pev(id, pev_movetype, MOVETYPE_FLY)
2186 set_pev(id, pev_effects, EF_NODRAW)
2187 set_pev(id, pev_deadflag, DEAD_DEAD)
2188 cs_set_user_team(id, CS_TEAM_SPECTATOR)
2189 }
2190
2191 model_menu(id)
2192 }
2193
2194 firstspawn[id] = false
2195 kz_reset_data(id)
2196 client_print(id, print_center, "")
2197
2198 if(!is_user_bot(id))
2199 {
2200 if(user_has_scout[id])
2201 {
2202 give_item(id,"weapon_scout")
2203 cs_set_weapon_ammo(find_ent_by_owner(-1,"weapon_scout",id),0)
2204 }
2205
2206 give_item(id,"weapon_knife")
2207 give_item(id,"weapon_usp")
2208 cs_set_weapon_ammo(find_ent_by_owner(-1,"weapon_usp",id),12)
2209 cs_set_user_bpammo(id, CSW_USP, 24)
2210 }
2211 else if(is_user_bot(id))
2212 {
2213 if(get_pcvar_num(kz_bot_usp))
2214 {
2215 give_item(id,"weapon_usp")
2216 give_item(id,"weapon_knife")
2217 }
2218 else if(!get_pcvar_num(kz_bot_usp))
2219 {
2220 strip_user_weapons(id)
2221 give_item(id,"weapon_knife")
2222 }
2223 }
2224
2225 if(HealsOnMap)
2226 set_user_health(id, 50175)
2227
2228 if(IsPaused[id])
2229 {
2230 set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
2231 set_pev(id, pev_origin, PauseOrigin[id])
2232 }
2233
2234 if(get_pcvar_num(kz_use_radio) == 0)
2235 {
2236 #define XO_PLAYER 5
2237 #define m_iRadiosLeft 192
2238 set_pdata_int(id, m_iRadiosLeft, 0, XO_PLAYER)
2239 }
2240}
2241
2242public GroundWeapon_Touch(iWeapon, id)
2243{
2244 if(is_user_alive(id) && timer_started[id] && get_pcvar_num(kz_pick_weapons) == 0)
2245 return HAM_SUPERCEDE
2246 return HAM_IGNORED
2247}
2248
2249public hamTakeDamage( )
2250{
2251 if(get_pcvar_num(kz_godmode))
2252 return HAM_SUPERCEDE
2253
2254 return HAM_IGNORED
2255}
2256
2257public SavePos(id)
2258{
2259 if(is_user_bot(id) || is_user_hltv(id) || !is_user_alive(id) || AutoPaused[id] ||
2260 !timer_started[id] || get_user_noclip(id) ||
2261 Verif(id,1) || !(pev(id, pev_flags) & FL_ONGROUND2) && !IsOnLadder(id))
2262 {
2263 client_print(id, print_center, "This command is not available to you at this point")
2264 return PLUGIN_HANDLED
2265 }
2266
2267 new scout;
2268 SavePosLoc(id);
2269 new Float:Time,check,gocheck
2270 if(IsPaused[id])
2271 {
2272 Time = g_pausetime[id]
2273 Pause(id)
2274 }
2275 else
2276 Time=get_gametime() - timer_time[id]
2277 check=checknumbers[id]
2278 gocheck=gochecknumbers[id]
2279 ColorChat(id, BLUE, "^1[KZ] ^3Position saved")
2280 if(user_has_scout[id])
2281 scout=1
2282 else
2283 scout=0
2284 kz_savepos(id, Time, check, gocheck, PosLoc[id], scout)
2285 reset_checkpoints(id)
2286
2287 return PLUGIN_HANDLED
2288}
2289
2290public SavePos_Spec(id)
2291{
2292 if(is_user_bot(id) || is_user_hltv(id) || !is_user_alive(id) || AutoPaused[id] ||
2293 !timer_started[id] || get_user_noclip(id) ||
2294 Verif(id,1) || !(pev(id, pev_flags) & FL_ONGROUND2) && !IsOnLadder(id))
2295 {
2296 client_print(id, print_center, "This command is not available to you at this point")
2297 return PLUGIN_HANDLED
2298 }
2299
2300 new scout;
2301 SavePosLoc(id);
2302 new Float:Time,check,gocheck
2303 if(IsPaused[id])
2304 {
2305 Time = g_pausetime[id]
2306 Pause(id)
2307 }
2308 else
2309 Time=get_gametime() - timer_time[id]
2310 check=checknumbers[id]
2311 gocheck=gochecknumbers[id]
2312 //ColorChat(id, BLUE, "^1[KZ] ^3Position saved")
2313 if(user_has_scout[id])
2314 scout=1
2315 else
2316 scout=0
2317 kz_savepos(id, Time, check, gocheck, PosLoc[id], scout)
2318 //reset_checkpoints(id)
2319
2320 return PLUGIN_HANDLED
2321}
2322
2323public GoPos(id)
2324{
2325 if(!is_user_alive(id) || get_user_noclip(id))
2326 {
2327 client_print(id, print_center, "This command is not available to you at this point")
2328 return PLUGIN_HANDLED
2329 }
2330
2331 if(Verif(id,0))
2332 LoadPosLoc(id)
2333
2334 checknumbers[id] = SavedChecks[id]
2335 gochecknumbers[id] = SavedGoChecks[id]+((get_pcvar_num(kz_save_pos_gochecks)>0) ? 1 : 0)
2336 CheckPoint(id)
2337 if(SavedScout[id])
2338 {
2339 give_item(id, "weapon_scout")
2340 user_has_scout[id] = true
2341 }
2342 timer_time[id] = get_gametime()-SavedTime[id]
2343 timer_started[id] = true
2344 in_run[id] = true
2345 Pause(id)
2346
2347 return PLUGIN_HANDLED
2348}
2349
2350public Verif(id, action)
2351{
2352 new realfile[128], tempfile[128], authid[32], map[64]
2353 new bool:exist = false
2354 get_mapname(map, 63)
2355 get_user_authid(id, authid, 31)
2356 formatex(realfile, 127, "%s/%s.ini", SavePosDir, map)
2357 formatex(tempfile, 127, "%s/temp.ini", SavePosDir)
2358
2359 if( !file_exists(realfile) )
2360 return 0
2361
2362 new file = fopen(tempfile, "wt")
2363 new vault = fopen(realfile, "rt")
2364 new data[150], sid[32], time[25], checks[5], gochecks[5], x[25], y[25], z[25], a[25], b[25], c[25], scout[5]
2365 while( !feof(vault) )
2366 {
2367 fgets(vault, data, 149)
2368 parse(data, sid, 31, time, 24, checks, 4, gochecks, 4, x, 24, y, 24, z, 24, a, 24, b, 24, c, 24, scout, 4)
2369
2370 if( equal(sid, authid) && !exist)
2371 {
2372 if(action == 1)
2373 fputs(file, data)
2374 exist= true
2375 SavedChecks[id] = str_to_num(checks)
2376 SavedGoChecks[id] = str_to_num(gochecks)
2377 SavedTime[id] = str_to_float(time)
2378
2379 PosLoc[id][0][0]=str_to_float(x)
2380 PosLoc[id][0][1]=str_to_float(y)
2381 PosLoc[id][0][2]=str_to_float(z)
2382
2383 PosLoc[id][1][0]=str_to_float(a)
2384 PosLoc[id][1][1]=str_to_float(b)
2385 PosLoc[id][1][2]=str_to_float(c)
2386
2387 SavedScout[id] = str_to_num(scout)
2388 }
2389 else
2390 {
2391 fputs(file, data)
2392 }
2393 }
2394
2395 fclose(file)
2396 fclose(vault)
2397
2398 delete_file(realfile)
2399 if(file_size(tempfile) == 0)
2400 delete_file(tempfile)
2401 else
2402 while( !rename_file(tempfile, realfile, 1) ) {}
2403
2404
2405 if(!exist)
2406 return 0
2407
2408 return 1
2409}
2410
2411public kz_savepos (id, Float:time, checkpoints, gochecks, Float:pos[2][3], scout)
2412{
2413 new realfile[128], formatorigin[128], map[64], authid[32]
2414 get_mapname(map, 63)
2415 get_user_authid(id, authid, 31)
2416 formatex(realfile, 127, "%s/%s.ini", SavePosDir, map)
2417 formatex(formatorigin, 127, "%s %f %d %d %f %f %f %f %f %f %d", authid, time, checkpoints, gochecks, pos[0][0], pos[0][1], pos[0][2], pos[1][0], pos[1][1], pos[1][2], scout)
2418
2419 new vault = fopen(realfile, "rt+")
2420
2421 write_file(realfile, formatorigin) // La sfarsit adaug datele mele
2422
2423 fclose(vault)
2424}
2425
2426public client_disconnect(id)
2427{
2428 if(is_user_alive(id) && timer_started[id] && in_run[id])
2429 SavePos(id)
2430
2431 checknumbers[id] = 0
2432 gochecknumbers[id] = 0
2433 anticheat[id] = 0.0
2434 groundtime[id] = 0.0
2435 show_timer[id] = true
2436 timer_started[id] = false
2437 in_run[id] = false
2438 ShowTime[id] = get_pcvar_num(kz_show_timer)
2439 firstspawn[id] = true
2440 IsPaused[id] = false
2441 WasPaused[id] = false
2442 AutoPaused[id] = false
2443 user_has_scout[id] = false
2444 CustomStart[id] = false
2445 menu_user[id] = false
2446}
2447
2448public client_putinserver(id)
2449{
2450 menu_user[id] = false
2451 checknumbers[id] = 0
2452 gochecknumbers[id] = 0
2453 anticheat[id] = 0.0
2454 groundtime[id] = 0.0
2455 show_timer[id] = true
2456 timer_started[id] = false
2457 in_run[id] = false
2458 has_hook[id]= false
2459 ShowTime[id] = get_pcvar_num(kz_show_timer)
2460 firstspawn[id] = true
2461 IsPaused[id] = false
2462 WasPaused[id] = false
2463 AutoPaused[id] = false
2464 user_has_scout[id] = false
2465 CustomStart[id] = false
2466}
2467
2468public savepos_menu(id)
2469{
2470 new menu = menu_create("\r[INS] \dSavePos Menu", "SavePosHandler")
2471
2472 menu_additem( menu, "Reload previous run", "1" )
2473 menu_additem( menu, "Start a new run", "2" )
2474
2475 menu_display(id, menu, 0)
2476 return PLUGIN_HANDLED
2477}
2478
2479public SavePosHandler(id, menu, item)
2480{
2481
2482 switch(item)
2483 {
2484 case 0:
2485 {
2486 GoPos(id)
2487 }
2488 case 1:
2489 {
2490 Verif(id,0)
2491 }
2492 }
2493 return PLUGIN_HANDLED
2494}
2495
2496public climb_menu(id)
2497{
2498 new mapname[32]
2499 get_mapname(mapname,31)
2500 new title[64]
2501 formatex(title, 63, "^n^n^n\r[INS] \dClimb Menu^n\dCurrent Map: \y%s\d", mapname)
2502 new menu = menu_create(title, "climb_menuhandler")
2503
2504 new msgcheck[64], msggocheck[64], msgpause[64]
2505 formatex(msgcheck, 63, "Checkpoint")
2506 formatex(msggocheck, 63, "Gocheck")
2507 formatex(msgpause, 63, "Pause - %s^n", IsPaused[id] ? "\yON" : "\rOFF")
2508
2509 menu_additem(menu, msgcheck, "1")
2510 menu_additem(menu, msggocheck, "2")
2511 menu_additem(menu, "Start", "3")
2512 menu_additem(menu, msgpause, "4")
2513 menu_additem(menu, "Stuck", "5")
2514 menu_additem(menu, "Save Position^n", "6")
2515 menu_additem(menu, "Show keys", "7")
2516
2517 menu_setprop( menu, MPROP_PERPAGE, 7 )
2518
2519 menu_display( id, menu, 0 )
2520
2521 return PLUGIN_HANDLED
2522}
2523
2524public climb_menuhandler(id, menu, item)
2525{
2526 if(item == MENU_EXIT) {
2527 kz_menu(id)
2528 return PLUGIN_HANDLED
2529 }
2530 switch(item) {
2531 case 0:
2532 {
2533 CheckPoint(id)
2534 climb_menu(id)
2535 }
2536 case 1:
2537 {
2538 m_GoCheck(id)
2539 climb_menu(id)
2540 }
2541 case 2:
2542 {
2543 m_goStart(id)
2544 climb_menu(id)
2545 }
2546 case 3:
2547 {
2548 Pause(id)
2549 climb_menu(id)
2550 }
2551 case 4:
2552 {
2553 Stuck(id)
2554 climb_menu(id)
2555 }
2556 case 5:
2557 {
2558 SavePos(id)
2559 climb_menu(id)
2560 }
2561 case 6:
2562 {
2563 cmdGetKeys(id)
2564 climb_menu(id)
2565 }
2566 }
2567 return PLUGIN_HANDLED
2568}
2569
2570
2571public kz_menu(id)
2572{
2573 new mapname[32]
2574 get_mapname(mapname,31)
2575 new title[64]
2576 formatex(title, 63, "\r[INS] \dMain Menu^n\dCurrent Map: \y%s\d", mapname)
2577 new menu = menu_create(title, "kz_menuhandler")
2578
2579 menu_additem(menu, "Climb Menu", "1")
2580 menu_additem(menu, "Teleport Menu", "2")
2581 menu_additem(menu, "Invisibility Menu", "3")
2582 menu_additem(menu, "Model Menu", "4")
2583 menu_additem(menu, "Kreedz Tops", "5")
2584 menu_additem(menu, "LongJump Tops", "6")
2585 menu_additem(menu, "FPS Viewer", "7")
2586 menu_additem(menu, "Measure Menu", "8")
2587 menu_additem(menu, "Timing Menu", "9")
2588
2589 menu_setprop( menu, MPROP_PERPAGE, 7 )
2590
2591 menu_display( id, menu, 0 )
2592
2593 return PLUGIN_HANDLED
2594}
2595
2596public kz_menuhandler(id, menu, item)
2597{
2598 if(item == MENU_EXIT) {
2599 menu_destroy(menu)
2600 return PLUGIN_HANDLED
2601 }
2602 switch(item) {
2603 case 0: climb_menu(id)
2604 case 1: kz_tele_menu(id)
2605 case 2: invis(id)
2606 case 3: model_menu(id)
2607 case 4: top15menu(id)
2608 case 5: ljtop(id)
2609 case 6: fpsview(id)
2610 case 7: measure(id)
2611 case 8: timing(id)
2612 }
2613 return PLUGIN_HANDLED
2614}
2615
2616public measure(id)
2617{
2618 client_cmd(id, "say /measure")
2619}
2620
2621public invis(id)
2622{
2623 client_cmd(id, "say /invis")
2624}
2625
2626public duelmenu(id)
2627{
2628 client_cmd(id, "say /duel")
2629}
2630
2631public fpsview(id)
2632{
2633 client_cmd(id, "say /fps")
2634}
2635
2636public ljtop(id)
2637{
2638 client_cmd(id, "say /ljtop")
2639}
2640
2641public timing(id)
2642{
2643 client_cmd(id, "say /timing")
2644}
2645
2646public cmdGetKeys(id)
2647{
2648 if(KeysOn[id])
2649 {
2650 client_cmd(id, "show_keys 0")
2651 KeysOn[id] = false
2652 return PLUGIN_HANDLED
2653 }
2654 else
2655 {
2656 client_cmd(id, "show_keys 1")
2657 KeysOn[id] = true
2658 return PLUGIN_HANDLED
2659 }
2660 return PLUGIN_HANDLED
2661}
2662
2663public ct_menu(id)
2664{
2665 new title[64]
2666 formatex(title, 63, "\r[INS] \dModel Menu")
2667 new menu = menu_create(title, "ct_menuhandler")
2668
2669 menu_additem(menu, "Urban", "1")
2670 menu_additem(menu, "Gsg9", "2")
2671 menu_additem(menu, "Sas", "3")
2672 menu_additem(menu, "Gign^n", "4")
2673
2674 menu_setprop(menu, MPROP_PERPAGE, 7)
2675 menu_display(id, menu, 0)
2676
2677 return PLUGIN_HANDLED
2678}
2679
2680public ct_menuhandler(id, menu, item)
2681{
2682 if(item == MENU_EXIT)
2683 {
2684 model_menu(id)
2685 return PLUGIN_HANDLED
2686 }
2687
2688 switch(item)
2689 {
2690 case 0: cmdURBAN(id)
2691 case 1: cmdGSG9(id)
2692 case 2: cmdSAS(id)
2693 case 3: cmdGIGN(id)
2694 }
2695 return PLUGIN_HANDLED
2696}
2697
2698public terror_menu(id)
2699{
2700 new title[64]
2701 formatex(title, 63, "\r[INS] \dModel Menu")
2702 new menu = menu_create(title, "terror_menuhandler")
2703
2704 menu_additem(menu, "Terror", "1")
2705 menu_additem(menu, "Leet", "2")
2706 menu_additem(menu, "Arctic", "3")
2707 menu_additem(menu, "Guerilla", "4")
2708
2709 menu_setprop(menu, MPROP_PERPAGE, 7)
2710 menu_display(id, menu, 0)
2711
2712 return PLUGIN_HANDLED
2713}
2714
2715public terror_menuhandler(id, menu, item)
2716{
2717 if(item == MENU_EXIT)
2718 {
2719 model_menu(id)
2720 return PLUGIN_HANDLED
2721 }
2722
2723 switch(item)
2724 {
2725 case 0: cmdTERROR(id)
2726 case 1: cmdLEET(id)
2727 case 2: cmdARCTIC(id)
2728 case 3: cmdGUERILLA(id)
2729 }
2730 return PLUGIN_HANDLED
2731}
2732
2733public custom_menu(id)
2734{
2735 if(!(get_user_flags(id) & KZ_VIP))
2736 {
2737 client_print(id, print_center, "This command is not available to you at this point")
2738 model_menu(id)
2739 return PLUGIN_HANDLED
2740 }
2741 new title[64]
2742 formatex(title, 63, "\r[INS] \dModel Menu")
2743 new menu = menu_create(title, "custom_menuhandler")
2744
2745 menu_additem(menu, "VIP", "1")
2746
2747 menu_setprop(menu, MPROP_PERPAGE, 7)
2748 menu_display(id, menu, 0)
2749
2750 return PLUGIN_HANDLED
2751}
2752
2753public custom_menuhandler(id, menu, item)
2754{
2755 if(item == MENU_EXIT)
2756 {
2757 model_menu(id)
2758 return PLUGIN_HANDLED
2759 }
2760
2761 switch(item)
2762 {
2763 case 0: cmdVIP(id)
2764 }
2765 return PLUGIN_HANDLED
2766}
2767
2768public top15menu(id)
2769{
2770 new menu = menu_create("\r[INS] \dTop15 \w", "top15handler")
2771 menu_additem(menu, "Map Top", "1", 0)
2772 menu_additem(menu, "My Records", "2", 0)
2773 menu_additem(menu, "Players Ranking", "3", 0)
2774 menu_additem(menu, "Last Pro Entries", "4")
2775 menu_additem(menu, "Search Player", "5", 0)
2776 menu_additem(menu, "Map Statistics","6")
2777
2778 menu_display(id, menu, 0)
2779
2780 return PLUGIN_HANDLED
2781}
2782
2783public top15handler(id, menu, item)
2784{
2785 if(item == MENU_EXIT)
2786 {
2787 kz_menu(id)
2788 return PLUGIN_HANDLED
2789 }
2790 switch(item)
2791 {
2792 case 0:
2793 {
2794 ProTop_show(id)
2795 top15menu(id)
2796 }
2797 case 1:
2798 {
2799 kz_showhtml_motd(id, MY_RECORDS, "")
2800 top15menu(id)
2801 }
2802 case 2:
2803 {
2804 Players_Ranking(id)
2805 top15menu(id)
2806 }
2807 case 3:
2808 {
2809 kz_showhtml_motd(id, LAST_PRO10, "")
2810 top15menu(id)
2811 }
2812 case 4:
2813 {
2814 NoobTop_show(id)
2815 top15menu(id)
2816 }
2817 case 5:
2818 {
2819 kz_showhtml_motd(id, MAPS_STATISTIC, "")
2820 top15menu(id)
2821 }
2822 }
2823
2824 return PLUGIN_HANDLED
2825}
2826
2827public reset_spectimer(id)
2828{
2829 for( new i = 1; i < 33; i++ )
2830 {
2831 is_user_spec[i]=is_user_spectating_player(i, id)
2832 if(i == id || is_user_spec[i])
2833 {
2834 client_print(i, print_center, "")
2835 }
2836 }
2837}
2838
2839public fwdUse(ent, id)
2840{
2841 if(!ent || id > 32)
2842 {
2843 return HAM_IGNORED
2844 }
2845
2846 if(!is_user_alive(id))
2847 {
2848 return HAM_IGNORED
2849 }
2850
2851 new name[32]
2852 get_user_name(id, name, 31)
2853
2854 new szTarget[ 32 ]
2855 pev(ent, pev_target, szTarget, 31)
2856
2857 if(TrieKeyExists(g_tStarts, szTarget))
2858 {
2859 new entclassname[33], Float:dmg
2860 pev(pev(id, pev_groundentity), pev_classname, entclassname, 32)
2861 pev(pev(id, pev_groundentity), pev_dmg, dmg)
2862 if(equal(entclassname, "func_door") && dmg >= 0)
2863 {
2864 return PLUGIN_HANDLED
2865 }
2866
2867 if(Verif(id,1))
2868 {
2869 client_print(id, print_center, "This command is not available to you at this point")
2870 //savepos_menu(id)
2871 GoPos(id)
2872 return HAM_IGNORED
2873 }
2874
2875 if(reset_checkpoints(id) && !timer_started[id] )
2876 {
2877 start_climb(id)
2878 for(new i = 0; i < 8; i++)
2879 if(get_user_health(id) < 100)
2880 set_user_health(id, 100)
2881 pev(id, pev_origin, SavedStart[id])
2882 if(get_pcvar_num(kz_save_autostart) == 1)
2883 AutoStart[id] = true
2884 if(!DefaultStart)
2885 {
2886 entity_get_vector(id, EV_VEC_v_angle, angles)
2887 kz_set_start(MapName, SavedStart[id], angles)
2888 client_print(id, print_center, "Start position set")
2889 }
2890 }
2891 }
2892
2893 if(TrieKeyExists(g_tStops, szTarget))
2894 {
2895 if(timer_started[id] || !IsPaused[id])
2896 {
2897 reset_spectimer(id)
2898 if(get_gametime() - anticheat[id] < 1.0)
2899 {
2900 return PLUGIN_HANDLED
2901 }
2902 if(get_user_noclip(id))
2903 return PLUGIN_HANDLED
2904
2905 if(hook[id] == false)
2906 finish_climb(id)
2907 has_hook[id] = true
2908 }
2909 }
2910 return HAM_IGNORED
2911}
2912
2913public start_climb(id)
2914{
2915 if(hook[id] == true)
2916 return PLUGIN_HANDLED
2917
2918 new flags = pev(id, pev_flags)
2919 if(usedhook[id] && flags & FL_ONGROUND && get_gametime() - groundtime[id] < 0.7 || usedhook[id] && !(flags & FL_ONGROUND))
2920 {
2921 usedhook[id] = false
2922 set_task(0.1, "goStart", id)
2923 client_print(id, print_center, "Hook detected")
2924
2925 return PLUGIN_HANDLED
2926 }
2927
2928 if(get_pcvar_num(kz_reload_weapons) == 1)
2929 {
2930 strip_user_weapons(id)
2931 give_item(id,"weapon_knife")
2932 }
2933
2934 if(ShowTime[id] == 2)
2935 kz_showtime_roundtime(id, 0)
2936 set_pev(id, pev_gravity, 1.0)
2937 set_pev(id, pev_movetype, MOVETYPE_WALK)
2938 set_user_godmode(id, 0)
2939 reset_checkpoints(id)
2940 IsPaused[id] = false
2941 timer_started[id] = true
2942 in_run[id] = true
2943 timer_time[id] = get_gametime()
2944 showtime(id)
2945
2946 if(get_user_weapon(id) == CSW_SCOUT)
2947 showtime2(id)
2948 else if(user_has_weapon(id,CSW_SCOUT))
2949 ham_strip_user_weapon(id, "weapon_scout")
2950
2951 return PLUGIN_CONTINUE
2952}
2953
2954public finish_climb(id)
2955{
2956 if(!is_user_alive(id) || is_user_bot(id) || !in_run[id] || IsPaused[id])
2957 {
2958 timer_started[id] = false
2959 in_run[id] = false
2960 return
2961 }
2962
2963 if((get_pcvar_num(kz_top15_authid) > 1) || (get_pcvar_num(kz_top15_authid) < 0))
2964 {
2965 return
2966 }
2967
2968 #if defined USE_SQL
2969 new Float: time, wpn
2970 time = get_gametime() - timer_time[id]
2971 show_finish_message(id, time)
2972 in_run[id] = false
2973 anticheat[id] = get_gametime()
2974 if(get_pcvar_num(kz_show_timer) > 0)
2975 kz_showtime_roundtime(id, 0)
2976 new checkpoints=checknumbers[id]
2977 new gocheck=gochecknumbers[id]
2978 if(user_has_weapon(id, CSW_SCOUT))
2979 wpn=CSW_SCOUT
2980 else
2981 wpn=get_user_weapon(id)
2982 new steam[32], name[32]
2983 get_user_name(id, name, 31)
2984 get_user_authid(id, steam, 31)
2985 new createinto[1001]
2986
2987 new cData[192]
2988 cData[0] = id
2989 formatex(cData[2], charsmax(cData)-2, "^"%f^" ^"%d^" ^"%d^" ^"%d^"", time, wpn, checkpoints ,gocheck)
2990
2991 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN"))
2992 {
2993 if(gochecknumbers[id] == 0 && !user_has_weapon(id, CSW_SCOUT))
2994 {
2995 cData[1] = PRO_TOP
2996 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND name='%s'", MapName, name)
2997 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
2998 }
2999 else if(gochecknumbers[id] > 0 || user_has_weapon(id, CSW_SCOUT))
3000 {
3001 cData[1] = NUB_TOP
3002 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND name='%s'", MapName, name)
3003 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
3004 }
3005 } else
3006 {
3007
3008 if(gochecknumbers[id] == 0 && !user_has_weapon(id, CSW_SCOUT))
3009 {
3010 cData[1] = PRO_TOP
3011 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND authid='%s'", MapName, steam)
3012 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
3013 }
3014 else if(gochecknumbers[id] > 0 || user_has_weapon(id, CSW_SCOUT))
3015 {
3016 cData[1] = NUB_TOP
3017 formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND authid='%s'", MapName, steam)
3018 SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
3019 }
3020 }
3021 #else
3022 new Float: time, authid[32]
3023 time = get_gametime() - timer_time[id]
3024 get_user_authid(id, authid, 31)
3025 show_finish_message(id, time)
3026 timer_started[id] = false
3027 in_run[id] = false
3028 if(get_pcvar_num(kz_show_timer) > 0)
3029 kz_showtime_roundtime(id, 0)
3030
3031 if(gochecknumbers[id] == 0 && !user_has_scout[id])
3032 ProTop_update(id, time)
3033 if(gochecknumbers[id] > 0 || user_has_scout[id])
3034 NoobTop_update(id, time, checknumbers[id], gochecknumbers[id])
3035 #endif
3036 user_has_scout[id] = false
3037 hidetime(id)
3038}
3039
3040public show_finish_message(id, Float:kreedztime)
3041{
3042 new name[32]
3043 new imin,isec,ims, wpn
3044 if(user_has_weapon(id, CSW_SCOUT))
3045 wpn=CSW_SCOUT
3046 else
3047 wpn=get_user_weapon(id)
3048 get_user_name(id, name, 31)
3049 imin = floatround(kreedztime / 60.0, floatround_floor)
3050 isec = floatround(kreedztime - imin * 60.0,floatround_floor)
3051 ims = floatround((kreedztime - (imin * 60.0 + isec)) * 100.0, floatround_floor)
3052
3053 if(gochecknumbers[id] == 0 && !user_has_scout[id])
3054 {
3055 ColorChat(0, BLUE, "^x01[KZ] ^x03%s^x01 beat the map in^x03 %02i:%02i.%02i ^x01[%s]", name, imin, isec, ims, g_weaponsnames[wpn])
3056 }
3057 else if(gochecknumbers[id] > 0 || user_has_scout[id])
3058 {
3059 ColorChat(0, RED, "^x01[KZ] ^x03%s^x01 beat the map in^x03 %02i:%02i.%02i ^x01(^x03%d^x01 cps & ^x03%d^x01 gcs) ^x01[%s] ^x01", name, imin, isec, ims, checknumbers[id], gochecknumbers[id], g_weaponsnames[wpn])
3060 }
3061}
3062
3063#if defined USE_SQL
3064
3065public Set_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
3066{
3067 new id = cData[0]
3068 new style = cData[1]
3069 if(iFailState != TQUERY_SUCCESS)
3070 {
3071 log_amx("[KZ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
3072 ColorChat(0, GREEN, "^x01 %F", LANG_PLAYER, "KZ_TOP15_SQL_ERROR")
3073 }
3074
3075 server_print("[KZ] Server Geting Info of SQL Server")
3076 kz_update_plrname(id)
3077
3078 new createinto[1001]
3079 new x1[16], x2[4], x3[5], x4[5]
3080 parse(cData[2], x1, 15, x2, 3, x3, 4, x4, 4)
3081 new dia[64], steam[32], name[32], ip[15], country[3], checkpoints[32], gochecks[32]
3082 new Float:newtime = str_to_float(x1)
3083 new server[64]
3084 get_pcvar_string(kz_sql_name, server, 63)
3085 get_time("%Y%m%d%H%M%S", dia, sizeof dia - 1)
3086 get_user_authid(id, steam, 31)
3087 get_user_name(id, name, sizeof name - 1)
3088 get_user_ip (id, ip, sizeof ip - 1, 1)
3089 geoip_code2_ex(ip, country)
3090
3091 replace_all(name, 31, "`", "")
3092 replace_all(name, 31, "'", "")
3093
3094 if(SQL_NumResults(hQuery) == 0)
3095 {
3096 formatex(checkpoints, 31, ", '%d'", str_to_num(x3))
3097 formatex(gochecks, 31, ", '%d'", str_to_num(x4))
3098 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)
3099 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
3100 GetNewRank(id, style)
3101 }
3102 else
3103 {
3104 new Float:oldtime
3105 SQL_ReadResult(hQuery, 0, oldtime)
3106
3107 if(newtime < oldtime)
3108 {
3109 formatex(checkpoints, 31, ", checkpoints='%d'", str_to_num(x3))
3110 formatex(gochecks, 31, ", gocheck='%d'", str_to_num(x4))
3111 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN"))
3112 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)
3113 else
3114 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)
3115
3116 SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
3117 GetNewRank(id, style)
3118 }
3119 }
3120
3121 return PLUGIN_CONTINUE
3122}
3123
3124public GetNewRank_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
3125{
3126 new id = cData[0]
3127 if(iFailState != TQUERY_SUCCESS)
3128 {
3129 return log_amx("TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
3130 }
3131
3132 new steam[32], authid[32], namez[32], name[32], i = 0
3133 get_user_authid(id, steam, 31)
3134 get_user_name(id, namez, 31)
3135
3136 while(SQL_MoreResults(hQuery))
3137 {
3138 i++
3139 if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN"))
3140 {
3141 SQL_ReadResult(hQuery, 0, name, 31)
3142 if(equal(name, namez))
3143 {
3144 if(cData[1] != NUB_TOP)
3145 {
3146 ColorChat(0, BLUE, "^x01[KZ] ^x03%s^x01 is now^x03 #%d^x01 on^x03 ProTop",namez, i)
3147 }
3148 else
3149 ColorChat(0, RED, "^x01[KZ] ^x03%s^x01 is now^x03 #%d^x01 on^x03 NubTop",namez, i)
3150
3151 if((i == 1) && cData[1] != NUB_TOP)
3152 emit_sound(0, CHAN_BODY, "vox/woop.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3153 else
3154 emit_sound(0, CHAN_BODY, "buttons/bell1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3155 break
3156 }
3157 }
3158 else
3159 {
3160 SQL_ReadResult(hQuery, 0, authid, 31)
3161 if(equal(authid, steam))
3162 {
3163 if(cData[1] != NUB_TOP)
3164 {
3165 ColorChat(0, BLUE, "^x01[KZ] ^x03%s^x01 is now^x03 #%d^x01 on^x03 ProTop",namez, i)
3166 }
3167 else
3168 ColorChat(0, RED, "^x01[KZ] ^x03%s^x01 is now^x03 #%d^x01 on^x03 NubTop",namez, i)
3169
3170 if((i == 1) && cData[1] != NUB_TOP)
3171 emit_sound(0, CHAN_BODY, "vox/woop.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3172 else
3173 emit_sound(0, CHAN_BODY, "buttons/bell1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3174 break
3175 }
3176 }
3177 SQL_NextRow(hQuery)
3178 }
3179
3180 return PLUGIN_CONTINUE
3181}
3182
3183public My_Records(id)
3184{
3185 kz_showhtml_motd(id, MY_RECORDS, "")
3186
3187 return PLUGIN_HANDLED
3188}
3189
3190public Players_Ranking(id)
3191{
3192 kz_showhtml_motd(id, PRO_RECORDS, "")
3193
3194 return PLUGIN_HANDLED
3195}
3196
3197public Map_Statistic(id)
3198{
3199 kz_showhtml_motd(id, MAPS_STATISTIC, "")
3200
3201 return PLUGIN_HANDLED
3202}
3203
3204public ProTop_show(id)
3205{
3206 kz_showhtml_motd(id, PRO_TOP, MapName)
3207
3208 return PLUGIN_HANDLED
3209}
3210
3211public NoobTop_show(id)
3212{
3213 kz_showhtml_motd(id, SEARCH_PLAYER, MapName)
3214
3215 return PLUGIN_HANDLED
3216}
3217
3218public ProRecs_show(id)
3219{
3220 kz_showhtml_motd(id, PRO_RECORDS, MapName)
3221
3222 return PLUGIN_HANDLED
3223}
3224
3225stock kz_showhtml_motd(id, type, const map[])
3226{
3227 new buffer[1001], namebuffer[64], filepath[96]
3228 get_pcvar_string(kz_sql_files, filepath, 95)
3229 new authid[32]
3230 get_user_authid(id, authid, 31)
3231
3232 switch(type)
3233 {
3234 case PRO_TOP:
3235 {
3236 formatex(namebuffer, 63, "Pro 15 of %s", equal(map, "") ? "All Maps" : map)
3237 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/stats15.php?map=%s^"></head><body><p>LOADING...</p></body></html>", filepath, map)
3238 }
3239 case SEARCH_PLAYER:
3240 {
3241 formatex(namebuffer, 63, "Search Player")
3242 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/search.php?map=%s^"></head><body><p>LOADING...</p></body></html>", filepath, map)
3243 }
3244 case PRO_RECORDS:
3245 {
3246 formatex(namebuffer, 63, "ProRecords and Rank")
3247 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/top15.php?authid=%s^"></head><body><p>LOADING...</p></body></html>", filepath, authid)
3248 }
3249 case MY_RECORDS:
3250 {
3251 formatex(namebuffer, 63, "My Records")
3252 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/player.php?id=%s^"></head><body><p>LOADING...</p></body></html>", filepath, authid)
3253 }
3254 case LAST_PRO10:
3255 {
3256 formatex(namebuffer, 63, "Last 10 Pro Entries")
3257 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/lastpro.php^"></head><body><p>LOADING...</p></body></html>", filepath)
3258 }
3259 case MAPS_STATISTIC:
3260 {
3261 formatex(namebuffer, 63, "Maps Statistic")
3262 formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/maps.php^"></head><body><p>LOADING...</p></body></html>", filepath)
3263 }
3264 }
3265
3266 show_motd(id, buffer, namebuffer)
3267}
3268#else
3269
3270public ProTop_update(id, Float:time)
3271{
3272 new authid[32], name[32], thetime[32], Float: slower, Float: faster, Float:protiempo
3273 get_user_name(id, name, 31)
3274 get_user_authid(id, authid, 31)
3275 get_time(" %d/%m/%Y ", thetime, 31)
3276 new bool:Is_in_pro15
3277 Is_in_pro15 = false
3278 for(new i = 0; i < 15; i++)
3279 {
3280 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)))
3281 {
3282 Is_in_pro15 = true
3283 slower = time - Pro_Times[i]
3284 faster = Pro_Times[i] - time
3285 protiempo = Pro_Times[i]
3286 }
3287 }
3288
3289 for (new i = 0; i < 15; i++)
3290 {
3291 if(time < Pro_Times[i])
3292 {
3293 new pos = i
3294 if(get_pcvar_num(kz_top15_authid) == 0)
3295 while(!equal(Pro_Names[pos], name) && pos < 15)
3296 {
3297 pos++
3298 }
3299 else if(get_pcvar_num(kz_top15_authid) == 1)
3300 while(!equal(Pro_AuthIDS[pos], authid) && pos < 15)
3301 {
3302 pos++
3303 }
3304
3305 for (new j = pos; j > i; j--)
3306 {
3307 formatex(Pro_AuthIDS[j], 31, Pro_AuthIDS[j-1])
3308 formatex(Pro_Names[j], 31, Pro_Names[j-1])
3309 formatex(Pro_Date[j], 31, Pro_Date[j-1])
3310 Pro_Times[j] = Pro_Times[j-1]
3311 }
3312
3313 formatex(Pro_AuthIDS[i], 31, authid)
3314 formatex(Pro_Names[i], 31, name)
3315 formatex(Pro_Date[i], 31, thetime)
3316 Pro_Times[i] = time
3317
3318 save_pro15()
3319
3320 if(Is_in_pro15)
3321 {
3322 if(time < protiempo)
3323 {
3324 new min, Float:sec
3325 min = floatround(faster, floatround_floor)/60
3326 sec = faster - (60*min)
3327
3328 if((i + 1) == 1)
3329 {
3330 emit_sound(0, CHAN_ITEM, "vox/woop.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3331 ColorChat(0, GREEN, "^x01[KZ] ^x03%s^x01 is now^x03 #1^x01 on ^x03Pro-15", name)
3332 }
3333 else
3334 {
3335 emit_sound(0, CHAN_ITEM, "buttons/bell1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3336 ColorChat(0, GREEN, "^x01[KZ] ^x03%s^x01 is now^x03 #%d^x01 on ^x03Pro-15", name, (i+1))
3337 }
3338 }
3339 }
3340 else
3341 {
3342 if((i + 1) == 1)
3343 {
3344 emit_sound(0, CHAN_ITEM, "vox/woop.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3345 ColorChat(0, GREEN, "^x01[KZ] ^x03%s^x01 is now^x03 #1^x01 on ^x03Pro-15", name)
3346 }
3347 else
3348 {
3349 emit_sound(0, CHAN_ITEM, "buttons/bell1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3350 ColorChat(0, GREEN, "^x01[KZ] ^x03%s^x01 is now^x03 #%d^x01 on ^x03Pro-15", name, (i+1))
3351 }
3352 }
3353
3354 return
3355 }
3356 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)))
3357 {
3358 if(time > protiempo)
3359 {
3360 new min, Float:sec
3361 min = floatround(slower, floatround_floor)/60
3362 sec = slower - (60*min)
3363 return
3364 }
3365 }
3366
3367 }
3368}
3369
3370public save_pro15()
3371{
3372 new profile[128]
3373 formatex(profile, 127, "%s/pro_%s.cfg", Topdir, MapName)
3374
3375 if(file_exists(profile))
3376 {
3377 delete_file(profile)
3378 }
3379 new Data[256]
3380 new f = fopen(profile, "at")
3381
3382 for(new i = 0; i < 15; i++)
3383 {
3384 formatex(Data, 255, "^"%.2f^" ^"%s^" ^"%s^" ^"%s^"^n", Pro_Times[i], Pro_AuthIDS[i], Pro_Names[i], Pro_Date[i])
3385 fputs(f, Data)
3386 }
3387 fclose(f)
3388}
3389
3390public read_pro15()
3391{
3392 new profile[128], prodata[256]
3393 formatex(profile, 127, "%s/pro_%s.cfg", Topdir, MapName)
3394
3395 new f = fopen(profile, "rt")
3396 new i = 0
3397 while(!feof(f) && i < 16)
3398 {
3399 fgets(f, prodata, 255)
3400 new totime[25]
3401 parse(prodata, totime, 24, Pro_AuthIDS[i], 31, Pro_Names[i], 31, Pro_Date[i], 31)
3402 Pro_Times[i] = str_to_float(totime)
3403 i++
3404 }
3405 fclose(f)
3406}
3407
3408public NoobTop_update(id, Float:time, checkpoints, gochecks)
3409{
3410 new authid[32], name[32], thetime[32], wpn, Float: slower, Float: faster, Float:noobtiempo
3411 get_user_name(id, name, 31)
3412 get_user_authid(id, authid, 31)
3413 get_time(" %d/%m/%Y ", thetime, 31)
3414 new bool:Is_in_noob15
3415 Is_in_noob15 = false
3416 if(user_has_weapon(id, CSW_SCOUT))
3417 wpn=CSW_SCOUT
3418 else
3419 wpn=get_user_weapon(id)
3420
3421 for(new i = 0; i < 15; i++)
3422 {
3423 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)))
3424 {
3425 Is_in_noob15 = true
3426 slower = time - Noob_Tiempos[i]
3427 faster = Noob_Tiempos[i] - time
3428 noobtiempo = Noob_Tiempos[i]
3429 }
3430 }
3431
3432 for (new i = 0; i < 15; i++)
3433 {
3434 if(time < Noob_Tiempos[i])
3435 {
3436 new pos = i
3437
3438 if(get_pcvar_num(kz_top15_authid) == 0)
3439 while(!equal(Noob_Names[pos], name) && pos < 15)
3440 {
3441 pos++
3442 }
3443 else if(get_pcvar_num(kz_top15_authid) == 1)
3444 while(!equal(Noob_AuthIDS[pos], authid) && pos < 15)
3445 {
3446 pos++
3447 }
3448
3449 for (new j = pos; j > i; j--)
3450 {
3451 formatex(Noob_AuthIDS[j], 31, Noob_AuthIDS[j-1])
3452 formatex(Noob_Names[j], 31, Noob_Names[j-1])
3453 formatex(Noob_Date[j], 31, Noob_Date[j-1])
3454 formatex(Noob_Weapon[j], 31, Noob_Weapon[j-1])
3455 Noob_Tiempos[j] = Noob_Tiempos[j-1]
3456 Noob_CheckPoints[j] = Noob_CheckPoints[j-1]
3457 Noob_GoChecks[j] = Noob_GoChecks[j-1]
3458 }
3459
3460 formatex(Noob_AuthIDS[i], 31, authid)
3461 formatex(Noob_Names[i], 31, name)
3462 formatex(Noob_Date[i], 31, thetime)
3463 formatex(Noob_Weapon[i], 31, g_weaponsnames[wpn])
3464 Noob_Tiempos[i] = time
3465 Noob_CheckPoints[i] = checkpoints
3466 Noob_GoChecks[i] = gochecks
3467
3468 save_Noob15()
3469
3470 if(Is_in_noob15)
3471 {
3472 if(time < noobtiempo)
3473 {
3474 new min, Float:sec
3475 min = floatround(faster, floatround_floor)/60
3476 sec = faster - (60*min)
3477
3478 if((i + 1) == 1)
3479 {
3480 emit_sound(0, CHAN_ITEM, "vox/woop.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3481 ColorChat(0, GREEN, "^x01[KZ] ^x03%s^x01 is now^x03 #1^x01 on ^x03Noob-15", name)
3482 }
3483 else
3484 {
3485 emit_sound(0, CHAN_ITEM, "buttons/bell1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3486 ColorChat(0, GREEN, "^x01[KZ] ^x03%s^x01 is now^x03 #%d^x01 on ^x03Noob-15", name, (i+1))
3487 }
3488 }
3489 }
3490 else
3491 {
3492 if((i + 1) == 1)
3493 {
3494 emit_sound(0, CHAN_ITEM, "vox/woop.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3495 ColorChat(0, GREEN, "^x01[KZ] ^x03%s^x01 is now^x03 #1^x01 on ^x03Noob-15", name)
3496 }
3497 else
3498 {
3499 emit_sound(0, CHAN_ITEM, "buttons/bell1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
3500 ColorChat(0, GREEN, "^x01[KZ] ^x03%s^x01 is now^x03 #%d^x01 on ^x03Noob-15", name, (i+1))
3501 }
3502 }
3503 return
3504 }
3505 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)))
3506 {
3507 if(time > noobtiempo)
3508 {
3509
3510 new min, Float:sec
3511 min = floatround(slower, floatround_floor)/60
3512 sec = slower - (60*min)
3513 return
3514 }
3515 }
3516
3517 }
3518}
3519
3520public save_Noob15()
3521{
3522 new profile[128]
3523 formatex(profile, 127, "%s/Noob_%s.cfg", Topdir, MapName)
3524
3525 if(file_exists(profile))
3526 {
3527 delete_file(profile)
3528 }
3529 new Data[256]
3530 new f = fopen(profile, "at")
3531
3532 for(new i = 0; i < 15; i++)
3533 {
3534 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])
3535 fputs(f, Data)
3536 }
3537 fclose(f)
3538}
3539
3540public read_Noob15()
3541{
3542 new profile[128], prodata[256]
3543 formatex(profile, 127, "%s/Noob_%s.cfg", Topdir, MapName)
3544
3545 new f = fopen(profile, "rt")
3546 new i = 0
3547 while(!feof(f) && i < 16)
3548 {
3549 fgets(f, prodata, 255)
3550 new totime[25], checks[5], gochecks[5]
3551 parse(prodata, totime, 24, Noob_AuthIDS[i], 31, Noob_Names[i], 31, checks, 4, gochecks, 4, Noob_Date[i], 31, Noob_Weapon[i], 31)
3552 Noob_Tiempos[i] = str_to_float(totime)
3553 Noob_CheckPoints[i] = str_to_num(checks)
3554 Noob_GoChecks[i] = str_to_num(gochecks)
3555 i++
3556 }
3557 fclose(f)
3558}
3559
3560public ProTop_show(id)
3561{
3562 new buffer[2048], len, name[32]
3563 len = formatex(buffer, 2047, "<body bgcolor=#000000><table width=100%% cellpadding=2 cellspacing=0 border=0>")
3564 len += formatex(buffer[len], 2047-len, "<tr align=center bgcolor=#000000><th width=5%%> # <th width=45%% align=center> Player <th width=30%%> Time <th width=20%%> Date ")
3565
3566 for (new i = 0; i < 10; i++)
3567 {
3568 name = Pro_Names[i]
3569
3570 if(Pro_Times[i] > 9999999.0)
3571 {
3572 len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s <td> %s <td> %s", ((i%2)==0) ? " bgcolor=#003366" : " bgcolor=#336699", (i+1), "", "", "")
3573 }
3574 else
3575 {
3576 new minutos, Float:segundos
3577 minutos = floatround(Pro_Times[i], floatround_floor)/60
3578 segundos = Pro_Times[i] - (60*minutos)
3579 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=#003366" : " bgcolor=#336699", (i+1), Pro_Names[i], minutos, segundos < 10 ? "0" : "", segundos, Pro_Date[i])
3580 }
3581 }
3582 len += formatex(buffer[len], 2047-len, "</table></body>")
3583 len += formatex(buffer[len], 2047-len, "")
3584
3585 show_motd(id, buffer, "Pro10 Climbers")
3586 return PLUGIN_HANDLED
3587}
3588
3589public NoobTop_show(id)
3590{
3591 new buffer[2048], name[32], len
3592 len = formatex(buffer, 2047, "<body bgcolor=#000000><table width=100%% cellpadding=2 cellspacing=0 border=0>")
3593 len += formatex(buffer[len], 2047-len, "<tr align=center bgcolor=#000000><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")
3594
3595 for (new i = 0; i < 10; i++)
3596 {
3597 if(Noob_Tiempos[i] > 9999999.0)
3598 {
3599 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=#003366" : " bgcolor=#336699", (i+1), "", "", "", "", "")
3600 }
3601 else
3602 {
3603 name = Noob_Names[i]
3604 new minutos, Float:segundos
3605 minutos = floatround(Noob_Tiempos[i], floatround_floor)/60
3606 segundos = Noob_Tiempos[i] - (60*minutos)
3607
3608 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=#003366" : " bgcolor=#336699", (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])
3609 }
3610 }
3611
3612 len += formatex(buffer[len], 2047-len, "</table></body>")
3613 len += formatex(buffer[len], 2047-len, "")
3614
3615 show_motd(id, buffer, "Noob10 Climbers")
3616 return PLUGIN_HANDLED
3617}
3618#endif
3619
3620public CmdUpTime(id) {
3621 if(! (get_user_flags(id) & ADMIN_BAN))
3622 {
3623 client_print(id, print_center, "This command is not available to you at this point")
3624 return PLUGIN_HANDLED
3625 }
3626 new gameTime = floatround(get_gametime())
3627 new mins = gameTime / 60
3628 new secs = gameTime % 60
3629
3630 YellowPrint(id, "The server has been online for%s %02i:%02i^1.", mins >= 50 ? "^3" : "^4", mins, secs)
3631
3632 return PLUGIN_CONTINUE
3633}
3634
3635stock YellowPrint(id, const message[ ], any:...)
3636{
3637 static szMessage[ 192 ], iLen, iSayText
3638
3639 if(!iLen)
3640 iLen = formatex(szMessage, 191, "^1[KZ] ")
3641
3642 if(!iSayText)
3643 iSayText = get_user_msgid("SayText")
3644
3645 vformat(szMessage[ iLen ], 191 - iLen, message, 3)
3646
3647 message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, iSayText, _, id)
3648 write_byte(id ? id : 1)
3649 write_string(szMessage)
3650 message_end()
3651
3652 return 1
3653}
3654
3655public MessageStatusIcon(msg_id, msg_dest, msg_entity)
3656{
3657 new icon[9]
3658 get_msg_arg_string(2, icon, charsmax(icon))
3659
3660 if(equal(icon, "buyzone"))
3661 {
3662
3663 return PLUGIN_HANDLED
3664 }
3665
3666 return PLUGIN_CONTINUE
3667}
3668
3669public showtime(id)
3670{
3671 message_begin(MSG_ONE,iconstatus,{0,0,0},id)
3672 write_byte(1)
3673 write_string("stopwatch")
3674 write_byte(0)
3675 write_byte(90)
3676 write_byte(255)
3677 message_end()
3678 return PLUGIN_HANDLED
3679}
3680
3681public showtime2(id)
3682{
3683 message_begin(MSG_ONE,iconstatus,{0,0,0},id)
3684 write_byte(1)
3685 write_string("stopwatch")
3686 write_byte(145)
3687 write_byte(0)
3688 write_byte(0)
3689 message_end()
3690 return PLUGIN_HANDLED
3691}
3692
3693public hidetime(id)
3694{
3695 message_begin(MSG_ONE,iconstatus,{0,0,0},id)
3696 write_byte(0)
3697 write_string("stopwatch")
3698 write_byte(0)
3699 write_byte(90)
3700 write_byte(255)
3701 message_end()
3702 return PLUGIN_HANDLED
3703}
3704
3705public showtime22(id)
3706{
3707 if(timer_started[id])
3708 {
3709 set_task(0.5,"showtime",id)
3710 }
3711}
3712
3713stock IsOnGround(id)
3714{
3715 new flags = pev(id, pev_flags)
3716 if((flags & FL_ONGROUND) || (flags & FL_PARTIALGROUND) ||( flags & FL_INWATER ) ||( flags & FL_CONVEYOR ) ||( flags & FL_FLOAT))
3717 {
3718 return true
3719 }
3720 return false
3721}
3722
3723stock kz_roundtime(id, tiempo)
3724{
3725 if( is_user_connected(id) )
3726 {
3727 message_begin(MSG_ONE_UNRELIABLE, g_roundtime, _, id)
3728 write_short(tiempo + 1)
3729 message_end()
3730 }
3731}
3732
3733public event_new_round()
3734{
3735 new Alive[32], alivePlayers
3736 get_players(Alive, alivePlayers, "ach")
3737 for(new i=0;i<alivePlayers;i++)
3738 {
3739 timer_started[Alive[i]] = false
3740 in_run[Alive[i]] = false
3741 }
3742}
3743
3744public EventMoney( id )
3745{
3746 if( get_pcvar_num( kz_block_money ) )
3747 {
3748 set_pdata_int( id, 115, 0 )
3749
3750 message_begin( MSG_ONE_UNRELIABLE, g_iMsgMoney, _, id )
3751 write_long ( 0 )
3752 write_byte ( 1 )
3753 message_end( )
3754 }
3755}
3756
3757stock StringTimer(const Float:flRealTime, szOutPut[], const iSizeOutPut, gametime = true)
3758{
3759 static Float:flTime, iMinutes, iSeconds, iMiliSeconds
3760 if(gametime)
3761 {
3762 flTime = get_gametime() - flRealTime
3763 }
3764 else
3765 {
3766 flTime = flRealTime
3767 }
3768 if(flTime < 0.0)
3769 {
3770 flTime = 0.0
3771 }
3772 iMinutes = floatround(flTime / 60, floatround_floor)
3773 iSeconds = floatround(flTime - (iMinutes * 60), floatround_floor)
3774 iMiliSeconds = floatround((flTime - (iMinutes * 60 + iSeconds)) * 100, floatround_floor)
3775 formatex(szOutPut, iSizeOutPut, "%02d:%02d.%02d", iMinutes, iSeconds,iMiliSeconds)
3776}
3777
3778stock ham_strip_user_weapon(id,weapon[])
3779{
3780 if(!equal(weapon,"weapon_",7)) return 0
3781
3782 new wId = get_weaponid(weapon)
3783 if(!wId) return 0
3784
3785 new wEnt
3786 while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
3787 if(!wEnt) return 0
3788
3789 if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
3790
3791 if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0
3792 ExecuteHamB(Ham_Item_Kill,wEnt)
3793
3794 set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId))
3795
3796 return 1
3797}
3798
3799stock is_user_spectating_player(spectator, player)
3800{
3801 if( !pev_valid(spectator) || !pev_valid(player) )
3802 return 0
3803 if( !is_user_connected(spectator) || !is_user_connected(player) )
3804 return 0
3805 if( is_user_alive(spectator) || !is_user_alive(player) )
3806 return 0
3807
3808 if( pev(spectator, pev_deadflag) != 2 )
3809 return 0
3810
3811 static specmode
3812 specmode = pev(spectator, pev_iuser1)
3813 if( !(specmode == 1 || specmode == 2 || specmode == 4) )
3814 return 0
3815
3816 if( pev(spectator, pev_iuser2) == player )
3817 return 1
3818
3819 return 0
3820}
3821
3822stock ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
3823{
3824 new nIdx = 0, l = strlen( p_szInput );
3825 new nLen = (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput, p_szDelimiter ) );
3826 while ( (nLen < l) && (++nIdx < p_nMax) )
3827 nLen += (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput[nLen], p_szDelimiter ) );
3828 return(nIdx);
3829}