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