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