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