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