Участник
Пользователь
- Сообщения
- 45
- Реакции
- 24
Всем привет! ищу плагин (видел где то такой но не могу вспомнить) когда заходишь на сервер то не дожидаясь конца раунда спавнишся и сразу играешь не CSDM, обычный паблик
6 Май 2021
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#pragma semicolon 1
#define VERSION "0.1.0"
#define PLUGIN "Respawn on First Join"
const m_iJoiningState = 121;
const m_iMenu = 205;
const MENU_CHOOSEAPPEARANCE = 3;
const JOIN_CHOOSEAPPEARANCE = 4;
new HamHook:g_iHhCBasePlayerPreThink;
#define MaskEnt(%0) ( 1<<(%0 & 31) )
new g_iBitHookPlayerPreThink;
#define MarkPlayerPreThink(%0) g_iBitHookPlayerPreThink |= MaskEnt(%0)
#define ClearPlayerPreThink(%0) g_iBitHookPlayerPreThink &= ~MaskEnt(%0)
#define HookPlayerPreThink(%0) ( g_iBitHookPlayerPreThink & MaskEnt(%0) )
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod");
register_clcmd("menuselect", "ClCmd_MenuSelect_JoinClass"); // old style menu
register_clcmd("joinclass", "ClCmd_MenuSelect_JoinClass"); // VGUI menu
DisableHamForward( g_iHhCBasePlayerPreThink = RegisterHam(Ham_Player_PreThink, "player", "OnCBasePlayer_PreThink_Post", true) ); // register it for later
}
// player is pressing a key in an old style menu
// or player is sending joinclass command, either by typing it in console, either selecting a option from VGUI skins selection menu
public ClCmd_MenuSelect_JoinClass(id)
{
// Don't need to check args here, because (assuming player is in the skin select menu,
// we gonna check this) if there is no arg, or if arg is bad, game gonna act as if player was choosing auto-select.
// So first check if player is in the correct menu, pdata m_iMenu can just tell us
// Then check if player has just joined the server, m_iJoiningState is used by the game for this
if( get_pdata_int(id, m_iMenu) == MENU_CHOOSEAPPEARANCE && get_pdata_int(id, m_iJoiningState) == JOIN_CHOOSEAPPEARANCE )
{
// Enable PreThink for 1 frame if not already
if( !g_iBitHookPlayerPreThink )
{
EnableHamForward( g_iHhCBasePlayerPreThink );
}
MarkPlayerPreThink(id);
}
}
// Little explanation on what should happen after player has chosen a skin :
// In CBasePlayer::PreThink, if player pdata m_iJoiningState is different from 0, function CBasePlayer::JoinThink gonna be called
// In JoinThink function, if m_iJoiningState 5 it means that player has just chosen a skin, we had checked if pdata was 4 because player has not chosen a team yet
// Then game checks if that player can be respawn with function CGameRules::FPlayerCanRespawn (if no objective or no player in 1 team player can respawn,
// else if we are less that 20sec after round start player can respawn, else player won't spawn)
// So now that PreThink and JoinThink have been called, let's check if player has been respawned or not.
public OnCBasePlayer_PreThink_Post( id )
{
if( !HookPlayerPreThink(id) )
{
return HAM_IGNORED;
}
ClearPlayerPreThink(id);
if( !g_iBitHookPlayerPreThink )
{
DisableHamForward( g_iHhCBasePlayerPreThink );
}
if( !is_user_alive(id) )
{
// if player has not been respawned by the game, let's force it.
ExecuteHam(Ham_Spawn, id);
return HAM_HANDLED;
}
return HAM_IGNORED;