Разработчик
Скриптер
Проверенный
- Сообщения
- 2,750
- Реакции
- 3,013
- Помог
- 61 раз(а)
Оттестируйте плагин на CSDM сервере. Нужен ли такой вообще?!
Переброс игрока в спектаторы и обратно по нажатию M.
Переброс игрока в спектаторы и обратно по нажатию M.
Код:
const Float: FLOOD_TIMEOUT = 2.0;
#define VERSION "0.0.1"
#include <amxmodx>
#include <reapi>
new TeamName: g_iPlayerLastTeam[MAX_CLIENTS];
new Float: g_fPlayerLastChooseTime[MAX_CLIENTS];
new bool: g_bSpectator[MAX_CLIENTS];
public plugin_init()
{
register_plugin("CSDM Spec Switch ReAPI", VERSION, "wopox1337");
// RegisterHookChain(RG_CSGameRules_FPlayerCanRespawn, "CSGameRules_FPlayerCanRespawn_Pre", .post = false);
RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn_Pre", .post = false);
register_clcmd("chooseteam", "Player__SpecSwitch");
}
public Player__SpecSwitch(const pPlayerId)
{
if((get_gametime() - g_fPlayerLastChooseTime[pPlayerId]) < FLOOD_TIMEOUT)
{
client_print(pPlayerId, print_center, "Вы не можете так быстро менять команду!");
return PLUGIN_HANDLED;
}
g_fPlayerLastChooseTime[pPlayerId] = get_gametime();
new TeamName: iTeam;
if(is_user_alive(pPlayerId))
{
switch(g_iPlayerLastTeam[pPlayerId] = get_member(pPlayerId, m_iTeam))
{
case TEAM_TERRORIST, TEAM_CT:
{
iTeam = TEAM_SPECTATOR;
}
}
Player__SilentKill(pPlayerId);
set_entvar(pPlayerId, var_effects, EF_NODRAW);
rg_set_user_team(pPlayerId, .team = iTeam);
g_bSpectator[pPlayerId] = true;
}
else
{
iTeam = g_iPlayerLastTeam[pPlayerId];
rg_set_user_team(pPlayerId, .team = iTeam);
rg_round_respawn(pPlayerId);
g_bSpectator[pPlayerId] = false;
}
return PLUGIN_HANDLED;
}
/* при mp_forcerespawn не будет срабатывать FCanPlayerRespawn. для меня не очевидно
public CSGameRules_FPlayerCanRespawn_Pre(const pPlayerId)
{
if(g_bSpectator[pPlayerId])
{
SetHookChainReturn(ATYPE_INTEGER, false);
}
// log_amx("CSGameRules_FPlayerCanRespawn");
// return HC_CONTINUE;
}
*/
public CBasePlayer_Spawn_Pre(const pPlayerId)
{
if(g_bSpectator[pPlayerId])
{
return HC_SUPERCEDE;
}
return HC_CONTINUE;
}
public client_putinserver(pPlayerId)
{
g_iPlayerLastTeam[pPlayerId] = TEAM_UNASSIGNED;
}
const g_iMsgDeathMsg = 83;
stock Player__SilentKill(pPlayerId)
{
new iMsgBlockState = get_msg_block(g_iMsgDeathMsg);
set_msg_block(g_iMsgDeathMsg, BLOCK_ONCE);
user_kill(pPlayerId, flag = 1);
set_msg_block(g_iMsgDeathMsg, iMsgBlockState);
}