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