Portugal
Пользователь
- Регистрация
- 2 Мар 2018
- Сообщения
- 257
- Симпатии
- 5
- Предупреждения
- 60
- Пол
- Мужской
Не пойму в чём проблема сразу скажу что плагин не всегда такое исполняет вообщем сама проблема Заходит игрок начинается warmup по истечении warmup должен воспроизвестись звук и рестарт раунда бывает работает а бывает делается просто рестарт раунда и пропадает прицел худ и респавн вроде не работает при убийстве.
Логи:
Логи:
Код:
[AMXX] Displaying debug trace (plugin "knife_warmup.amxx", version "0.1")
[AMXX] Run time error 4: index out of bounds
[AMXX] [0] knife_warmup.sma::EventRoundEnd (line 154)
[AMXX] [1] knife_warmup.sma::FwdThink (line 222)
with "worldspawn" (world)
Код:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>
//#include <roundcontrol> // раскомментируйте эту строку, если на сервере не используется Regamedll_CS
#pragma semicolon 1
#define bit_set(%0,%1) (%1 |= (1<<%0))
#define bit_clear(%0,%1) (%1 &= ~(1<<%0))
#define bit_valid(%0,%1) (%1 & (1<<%0))
#define USE_PAUSE // раскомментируйте эту строку, если желаете, чтобы плагин прекратил работу после выполнения задачи
#if AMXX_VERSION_NUM < 183
const MAX_PLAYERS = 30; // максимальное кол-во игроков на сервере, заменить своим (по умолчанию 32)
#endif
const WARMUP_TIME = 70; // кол-во времени в секундах, отведённое на разминку (по умолчанию 90)
const Float:RESPAWN_DELAY = 0.75; // кол-во времени в секундах, отведённое на задержку перед респауном (по умолчанию 0.75)
const Float:SHOW_MSG_DELAY = 0.8; // кол-во времени в секундах, отведённое на задержку перед отправкой HUD-сообщения (по умолчанию 0.5)
const Float:WARMUP_HEALTH = 65.0; // кол-во ед. здоровья, устанавливаемое игроку при спауне во время разминки (по умолчанию 35.0)
const HW_CROSS_AMMO_WPNLIST = (1<<0);
const HW_TIMER = (1<<4);
const HW_MONEY = (1<<5);
new const szSound[][] = {
"wrsnz/wrmzs1.wav", "wrsnz/wrmzs2.wav", "wrsnz/wrmzs3.wav"
};
enum {
WS_WAITING = 1,
WS_BEGIN,
WS_IN_PROGRESS,
WS_ENDED
}
new HamHook:g_pHamSpawn, HamHook:g_pHamAddPlayerItem, HamHook:g_pHamGiveAmmo, HamHook:g_pHamUse, HamHook:g_pHamKilled;
#if defined _roundcontrol_included
new RoundControlHook:g_pCheckWinHook;
#else
new g_pRoundInfinite, g_szRoundInfinite[10];
#endif
new g_pRestartRound, g_pHideWeaponMsgId, g_pStatusIconMsgId, g_pHudSyncObj1, g_pHudSyncObj2, g_pThinkEnt, g_iConnectedBitsum, g_iAliveBitsum, g_iMessageBitsum, g_iFrags[MAX_PLAYERS + 1],
g_iWarmupState = WS_WAITING, g_pHideWeapon, g_iTimerCount;
public plugin_precache() {
for(new i; i < sizeof szSound; i++) {
precache_sound(szSound[i]);
}
}
public plugin_init() {
register_plugin("Knife warmup", "0.1", "Subb98");
register_clcmd("joinclass", "CmdJoinClass");
const JOIN_CLASS_MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
register_menucmd(register_menuid("Terrorist_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
register_menucmd(register_menuid("CT_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
register_event("HLTV", "EventHLTV", "a", "1=0", "2=0");
register_logevent("EventGameCommencing", 2, "1=Game_Commencing");
register_logevent("EventRoundStart", 2, "1=Round_Start");
register_logevent("EventRoundEnd", 2, "1=Round_End");
new const ENT_CLASSNAME[] = "player";
DisableHamForward(g_pHamSpawn = RegisterHam(Ham_Spawn, ENT_CLASSNAME, "HamSpawnPlayerPost", 1));
DisableHamForward(g_pHamAddPlayerItem = RegisterHam(Ham_AddPlayerItem, ENT_CLASSNAME, "HamAddPlayerItemPre"));
DisableHamForward(g_pHamGiveAmmo = RegisterHam(Ham_GiveAmmo, ENT_CLASSNAME, "HamGiveAmmoPre"));
DisableHamForward(g_pHamUse = RegisterHam(Ham_Use, "hostage_entity", "HamUseHostagePre"));
DisableHamForward(g_pHamKilled = RegisterHam(Ham_Killed, ENT_CLASSNAME, "HamKilledPlayerPost", 1));
#if !defined _roundcontrol_included
g_pRoundInfinite = get_cvar_pointer("mp_round_infinite");
#endif
g_pRestartRound = get_cvar_pointer("sv_restartround");
g_pHideWeaponMsgId = get_user_msgid("HideWeapon");
g_pStatusIconMsgId = get_user_msgid("StatusIcon");
g_pHudSyncObj1 = CreateHudSyncObj();
g_pHudSyncObj2 = CreateHudSyncObj();
CreateThinkEntity();
}
#if !defined _roundcontrol_included
public plugin_cfg() {
if(g_pRoundInfinite) {
get_pcvar_string(g_pRoundInfinite, g_szRoundInfinite, charsmax(g_szRoundInfinite));
}
}
#endif
public client_putinserver(id) {
ResetValues(id);
if(!is_user_bot(id) && !is_user_hltv(id)) {
bit_set(id, g_iConnectedBitsum);
}
}
public client_disconnected(id) {
ResetValues(id);
remove_task(id);
}
public CmdJoinClass(const id) {
if(g_iWarmupState == WS_IN_PROGRESS) {
set_task(RESPAWN_DELAY, "TaskRespawn", id);
}
}
public EventHLTV() {
switch(g_iWarmupState) {
case WS_BEGIN: {
g_iWarmupState = WS_IN_PROGRESS;
g_iMessageBitsum = 0;
EnableHamForward(g_pHamSpawn);
EnableHamForward(g_pHamAddPlayerItem);
EnableHamForward(g_pHamGiveAmmo);
EnableHamForward(g_pHamUse);
EnableHamForward(g_pHamKilled);
server_cmd("sv_gravity 350");
g_pHideWeapon = register_message(g_pHideWeaponMsgId, "MessageHideWeapon");
#if defined _roundcontrol_included
g_pCheckWinHook = SetBlockControl(RC_CheckWinConditions);
#else
if(g_pRoundInfinite) {
set_pcvar_num(g_pRoundInfinite, 1);
}
#endif
set_msg_block(g_pStatusIconMsgId, BLOCK_SET);
}
case WS_ENDED: {
entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + SHOW_MSG_DELAY);
}
}
}
public EventGameCommencing() {
if(g_iWarmupState == WS_WAITING) {
g_iWarmupState = WS_BEGIN;
}
}
public EventRoundStart() {
if(g_iWarmupState == WS_IN_PROGRESS) {
entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + 1.0);
}
}
public EventRoundEnd() {
if(g_iWarmupState == WS_IN_PROGRESS) {
g_iWarmupState = WS_ENDED;
DisableHamForward(g_pHamSpawn);
DisableHamForward(g_pHamAddPlayerItem);
DisableHamForward(g_pHamGiveAmmo);
DisableHamForward(g_pHamUse);
DisableHamForward(g_pHamKilled);
server_cmd("sv_gravity 850");
client_cmd(0, "spk sound/%s", szSound[random_num(0, sizeof szSound)]);
unregister_message(g_pHideWeaponMsgId, g_pHideWeapon);
#if defined _roundcontrol_included
RemoveBlockControl(RC_CheckWinConditions, g_pCheckWinHook);
#else
if(g_pRoundInfinite) {
set_pcvar_string(g_pRoundInfinite, g_szRoundInfinite);
}
#endif
set_msg_block(g_pStatusIconMsgId, BLOCK_NOT);
set_pcvar_float(g_pRestartRound, 1.0);
}
}
public MessageHideWeapon() {
const ARG_FLAGS = 1;
set_msg_arg_int(ARG_FLAGS, ARG_BYTE, get_msg_arg_int(ARG_FLAGS) | HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
}
public HamSpawnPlayerPost(const id) {
if(is_user_alive(id)) {
bit_set(id, g_iAliveBitsum);
if(!bit_valid(id, g_iMessageBitsum)) {
set_task(SHOW_MSG_DELAY, "TaskWarmupStartMsg", id);
}
entity_set_float(id, EV_FL_health, WARMUP_HEALTH);
engclient_cmd(id, "weapon_knife");
message_begin(MSG_ONE, g_pHideWeaponMsgId, _, id);
write_byte(HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
message_end();
}
}
public HamAddPlayerItemPre(const id, const pEnt) {
if(cs_get_weapon_id(pEnt) != CSW_KNIFE) {
entity_set_int(pEnt, EV_INT_flags, entity_get_int(pEnt, EV_INT_flags ) | FL_KILLME);
SetHamReturnInteger(0);
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public HamGiveAmmoPre() {
const NO_AMMO_STOP_PROCESSING = -1;
SetHamReturnInteger(NO_AMMO_STOP_PROCESSING);
return HAM_SUPERCEDE;
}
public HamUseHostagePre() {
return HAM_SUPERCEDE;
}
public HamKilledPlayerPost(const id, const pKiller) {
bit_clear(id, g_iAliveBitsum);
set_task(RESPAWN_DELAY, "TaskRespawn", id);
}
public FwdThink(const pEnt) {
switch(g_iWarmupState) {
case WS_IN_PROGRESS: {
static iDiff, iMin;
iDiff = WARMUP_TIME - g_iTimerCount++, iMin = 0;
GetMinutes(iDiff, iMin);
set_hudmessage(124, 252, 0, _, 0.96, _, _, 1.0, 0.0, 0.01, -1);
ShowSyncHudMsg(0, g_pHudSyncObj1, "Iki warmup pabaigos: %d:%d", iMin, iDiff);
if(iDiff || iMin) {
entity_set_float(pEnt, EV_FL_nextthink, get_gametime() + 1.0);
} else {
EventRoundEnd();
}
}
case WS_ENDED: {
g_iWarmupState = WS_WAITING;
g_iTimerCount = 0;
set_hudmessage(0, 139, 139, _, 0.25, _, _, 5.0, _, _, -1);
ShowSyncHudMsg(0, g_pHudSyncObj2, "Žaidimas prasideda - [GLHF] !");
#if defined USE_PAUSE
pause("d");
#endif
}
}
}
public TaskRespawn(const id) {
if(bit_valid(id, g_iConnectedBitsum) && !bit_valid(id, g_iAliveBitsum) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
ExecuteHamB(Ham_CS_RoundRespawn, id);
}
}
public TaskWarmupStartMsg(const id) {
if(bit_valid(id, g_iAliveBitsum)) {
set_hudmessage(124, 252, 0, _, 0.25, _, _, 5.0, _, _, -1);
ShowSyncHudMsg(id, g_pHudSyncObj2, "Pasiruošk!^n[WARMUP] - Prasideda!");
bit_set(id, g_iMessageBitsum);
}
}
CreateThinkEntity() {
new const ENT_CLASSNAME[] = "_warmup_think_ent";
if((g_pThinkEnt = create_entity("info_target"))) {
entity_set_string(g_pThinkEnt, EV_SZ_classname, ENT_CLASSNAME);
register_think(ENT_CLASSNAME, "FwdThink");
} else {
set_fail_state("Failed to create think entity");
}
}
ResetValues(const id) {
bit_clear(id, g_iConnectedBitsum);
bit_clear(id, g_iAliveBitsum);
bit_clear(id, g_iMessageBitsum);
g_iFrags[id] = 0;
}
GetMinutes(&iSec, &iMin) {
const SECONDS_IN_MINUTE = 60;
iMin = iSec / SECONDS_IN_MINUTE, iSec %= SECONDS_IN_MINUTE;
}