[KZ] ScoreTimer, Не реагирует на паузу, хук и тд. |
Здравствуйте, гость Вход | Регистрация
Наши новости:
|
|
|
[KZ] ScoreTimer, Не реагирует на паузу, хук и тд. |
medusa
|
23.2.2015, 14:52
Сообщение
|
![]() |
Хеллоу. Есть такой плагин ScoreTimer, суть его в том , что бы заменить ФРАГИ\СМЕРТИ в таблице счета, на Минуты/Секунды прохождения карты [т.е в реальном времени идет отчет как и на основном таймере игрока, и при достижении финиша время фиксируется в таблице счета], но проблема в том что если сбрасывать таймер такими командами как /reser /noclip +hook и тд - основной таймер сбрасываться а в таблице счета оно продолжает идти. Аналогично и при паузе [время продолжат идти, и после АНпаузинга проходя мапу время в таблице не соответствует реальному таймеру, и при достижении финиша выходят разные результаты в таблице счета и топе(чате)ит.д.. Как можно исправить ибо я слаб в коде, и не разберусь в данных функциях.
На сервере используется Prokreedz 2.31 scoretimer.sma
scoretimer.sma ( 5,42 килобайт )
Кол-во скачиваний: 4Код #include <amxmodx> #include <fakemeta> #include <hamsandwich> #define PLUGIN "scoretimer" #define VERSION "1.5" #define AUTHOR "kielor" #define OFFSET_INTERNALMODEL 126 #define OFFSET_CSDEATHS 444 #define OFFSET_TEAM 114 #define cs_get_user_deaths(%1) get_pdata_int(%1,OFFSET_CSDEATHS) // Best results for scoretable new best_time[33]; // Time when started new start_time[33]; // Time when paused new pause_time[33]; // Started? new bool:started[33]; // Paused? new bool:paused[33]; enum CsTeams { CS_TEAM_UNASSIGNED, CS_TEAM_T, CS_TEAM_CT, CS_TEAM_SPECTATOR }; enum CS_Internal_Models { CS_DONTCHANGE = 0, CS_CT_URBAN = 1, CS_T_TERROR = 2, CS_T_LEET = 3, CS_T_ARCTIC = 4, CS_CT_GSG9 = 5, CS_CT_GIGN = 6, CS_CT_SAS = 7, CS_T_GUERILLA = 8, CS_CT_VIP = 9, CZ_T_MILITIA = 10, CZ_CT_SPETSNAZ = 11 }; public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR); register_cvar("kz_scoretimer","1"); register_clcmd("say /pause", "pause_timer") register_clcmd("say /unpause", "pause_timer") register_clcmd("say /reset", "reset_timer") register_concmd("+hook","reset_timer") register_concmd("-hook","reset_timer") set_task(0.5, "tabletimer", _, _, _, "b"); RegisterHam(Ham_Use, "func_button", "fwdUse", 0) } public reset_timer(id) { start_time[id] = 0; pause_time[id] = 0; started[id] = false; paused[id] = false; cs_set_score(id, 0, 0); return PLUGIN_CONTINUE; } public tabletimer() { if(get_cvar_num("kz_scoretimer") == 1) { static Players[32], count, i, index; get_players(Players, count, "ach"); for(i = 0; i < count; i++) { index = Players[i]; if(started[index]) { if(paused[index]) { new time = pause_time[index], iMin, iSec; iMin = floatround(time / 60.0, floatround_floor); iSec = time - (60*iMin); cs_set_score(index, iMin, iSec); } else { new time = pause_time[index] + (get_systime() - start_time[index]), iMin, iSec; iMin = floatround(time / 60.0, floatround_floor); iSec = time - (60*iMin); cs_set_score(index, iMin, iSec); } } } } } public client_connect(id) { best_time[id] = 0; start_time[id] = 0; pause_time[id] = 0; started[id] = false; paused[id] = false; } public client_PreThink(id) { if(!is_user_alive(id)) return FMRES_IGNORED; if(get_cvar_num("kz_scoretimer") == 0) { cs_set_score(id, 0, 0); return FMRES_IGNORED; } return FMRES_IGNORED; } public fwdUse(ent, id) { if( !ent || id > 32) { return FMRES_IGNORED; } if( !is_user_alive(id) ) { return FMRES_IGNORED; } if( get_cvar_num("kz_scoretimer") == 0 ) { return FMRES_IGNORED; } new target[33]; pev( ent, pev_target, target, sizeof target - 1 ); if( equali( target, "counter_start" ) || equali( target, "clockstartbutton" ) || equali( target, "firsttimerelay" ) ) { start_timer(id); } else if( equali( target, "counter_off" ) || equali( target, "clockstopbutton" ) || equali( target, "clockstop" ) ) { if(started[id]) { finish_timer(id); } } return FMRES_IGNORED; } public pause_timer(id) { if(started[id]) { if(paused[id]) { paused[id] = false; start_time[id] = get_systime(); } else { paused[id] = true; pause_time[id] += (get_systime() - start_time[id]); start_time[id] = 0; } } } start_timer(id) { start_time[id] = get_systime(); started[id] = true; pause_time[id] = 0; } finish_timer(id) { new time = pause_time[id] + (get_systime() - start_time[id]); if(best_time[id] != 0) { if(time < best_time[id]) { best_time[id] = time; } } else { best_time[id] = time; } started[id] = false; pause_time[id] = 0; updatebest(id); } public updatebest(id) { new iMin, iSec; iMin = floatround(best_time[id] / 60.0, floatround_floor); iSec = best_time[id] - (60*iMin); cs_set_score(id, iMin, iSec); } stock _get_brush_entity_origin(ent, Float:orig[3]) // Taken from the engine stock { new Float:Min[3], Float:Max[3]; pev(ent, pev_mins, Min); pev(ent, pev_maxs, Max); orig[0] = (Min[0] + Max[0]) * 0.5; orig[1] = (Min[1] + Max[1]) * 0.5; orig[2] = (Min[2] + Max[2]) * 0.5; return 1; } stock cs_set_score(id, iFrags, iDeaths) { set_pdata_int(id, OFFSET_CSDEATHS, iDeaths); static iMsgScoreInfo; if( iMsgScoreInfo || (iMsgScoreInfo = get_user_msgid("ScoreInfo")) ) { message_begin(MSG_BROADCAST, iMsgScoreInfo); write_byte(id); write_short(iFrags); write_short(iDeaths); write_short(0); write_short(_:cs_get_user_team(id)); message_end(); } } stock CsTeams:cs_get_user_team(id, &{CsInternalModel,_}:iModel = CsInternalModel:CS_DONTCHANGE) { iModel = CsInternalModel:get_pdata_int(id, OFFSET_INTERNALMODEL); return CsTeams:get_pdata_int(id, OFFSET_TEAM); }
Отредактировал: medusa, - 23.2.2015, 14:53
|
|
|
|
![]() ![]() |