Spoiler
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define EXTRAOFFSET 5
#define OFFSET_MONEY 115
#define OFFSET_DEATHS 555
#define OFFSET_INTERALMODEL 126
#define OFFSET_TEAM 114
new bool:lockspawn
new bool:is_user_late[33]
new useroldmoney[33]
new lockenable,locktime,locktype,round
new lockmoney,gmsg_ScoreInfo
enum CsTeams
{
CS_TEAM_UNASSIGNED, // 0
CS_TEAM_T, // 1
CS_TEAM_CT, // 2
CS_TEAM_SPECTATOR // 3
};
enum CsInternalModel
{
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("Anti Late Join","1.3","Biscuit")
RegisterHam(Ham_Spawn, "player", "Spawn", 1)
register_logevent("Roundstart", 2, "1=Round_Start")
register_logevent("UnLockSpawn", 2, "1=Round_End")
register_event("TextMsg","UnLockSpawn","a","2&#Game_C")
register_event("DeathMsg","deathevent","a","1>0")
lockenable = register_cvar("LockSpawn","1")
lockmoney = register_cvar("LockSpawnMoney","1")
locktime = register_cvar("LockSpawnTime","5")
locktype = register_cvar("LockSpawnType","3")
gmsg_ScoreInfo = get_user_msgid("ScoreInfo")
}
public deathevent()
{
if(get_pcvar_num(lockenable))
{
//Firstblood,lock spawn
new type = get_pcvar_num(locktype)
if((type == 2 || type == 3) && !lockspawn)
{
new id = read_data(1);
if(is_user_alive(id)) //is not kill by worldspawn
{
lockspawn = true
}
}
}
}
public Roundstart()
{
if(get_pcvar_num(lockenable))
{
new type = get_pcvar_num(locktype)
if(type == 1 || type == 3)
{
if(round >1 ) //is not first round
set_task(get_pcvar_float(locktime),"LockSpawn")
else
round++
}
}
}
public Spawn(id)
{
if(get_pcvar_num(lockenable))
{
if(!is_user_alive(id))
return PLUGIN_HANDLED
if(get_pcvar_num(lockmoney) && is_user_late[id])
{
is_user_late[id] = false
fm_cs_set_user_money(id,useroldmoney[id])
}
if(lockspawn)
{
client_print(id,print_chat,"[Amxx] You join the round too late.")
is_user_late[id] = true
//save user money
useroldmoney[id] = fm_cs_get_user_money(id)
//kill user
user_kill(id,1)
//reset user score
fm_cs_set_user_deaths(id, 0)
fm_set_user_frags(id, 0)
//scorebroad
message_begin ( MSG_BROADCAST , gmsg_ScoreInfo );
write_byte( id );
write_short( 0 ) ;
write_short( 0 ) ;
write_short( 0 ) ;
write_short( get_user_team(id) );
message_end();
}
}
return PLUGIN_HANDLED
}
public LockSpawn() lockspawn = true
public UnLockSpawn() lockspawn = false
stock fm_set_user_frags(index, frags) {
set_pev(index, pev_frags, float(frags))
return 1
}
stock fm_cs_get_user_money(client)
{
return get_pdata_int(client, OFFSET_MONEY, EXTRAOFFSET)
}
stock fm_cs_set_user_money(client, money, flash=1)
{
set_pdata_int(client, OFFSET_MONEY, money, EXTRAOFFSET);
static Money;
if( Money || (Money = get_user_msgid("Money")) )
{
emessage_begin(MSG_ONE_UNRELIABLE, Money, _, client)
ewrite_long(money)
ewrite_byte(flash ? 1 : 0)
emessage_end()
}
}
stock fm_cs_set_user_deaths(client, deaths)
{
set_pdata_int(client, OFFSET_DEATHS, deaths, EXTRAOFFSET);
static ScoreInfo;
if( ScoreInfo || (ScoreInfo = get_user_msgid("ScoreInfo")) )
{
emessage_begin(MSG_BROADCAST, ScoreInfo);
ewrite_byte(client);
ewrite_short(get_user_frags(client));
ewrite_short(deaths);
ewrite_short(0);
ewrite_short(_:fm_cs_get_user_team(client));
emessage_end();
}
}
stock CsTeams:fm_cs_get_user_team(client, &{CsInternalModel,_}:model=CS_DONTCHANGE)
{
model = CsInternalModel:get_pdata_int(client, OFFSET_INTERALMODEL, EXTRAOFFSET)
return CsTeams:get_pdata_int(client, OFFSET_TEAM, EXTRAOFFSET)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
?