Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
|
01-09-2021
, 07:13
Players counting exclude spectators
|
#1
|
Hi. This plugin allows picking up AWP guns only when there is 10 players (exclude spectators), but something's gone wrong and now spectators also included in that counting. What need to be fixed? Thank you.
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#define PLUGIN "AWP limit by players"
#define VERSION "1.0"
#define AUTHOR "ArtHa"
#define VIP ADMIN_LEVEL_H
#define VIPN ADMIN_LEVEL_B
new bool:gAwpBlock;
new awp_vip, cvar_player, awp_block, awp_limit
new g_pHp[ 3 ], chat_message
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_dictionary("kita.txt")
awp_vip = register_cvar( "amx_vip_awp", "0" )
awp_limit = register_cvar( "amx_awp_limit", "1" )
awp_block = register_cvar( "amx_awp_block", "1" )
cvar_player = register_cvar("na_players_count", "10")
register_event( "DeathMsg", "Event_DeathMsg", "a" )
g_pHp[ 0 ] = register_cvar( "amx_vip_hpadd", "3" )
g_pHp[ 1 ] = register_cvar( "amx_vip_hsadd", "5" )
g_pHp[ 2 ] = register_cvar( "amx_vip_hpmax", "100" )
chat_message = register_cvar( "amx_hpbonus_msg", "2" )
register_event("CurWeapon", "event_CurWeapon", "be")
}
public Event_DeathMsg( )
{
new iKiller = read_data( 1 )
new iVictim = read_data( 2 )
new HeadShot = read_data( 3 )
if( get_user_team( iKiller ) == get_user_team( iVictim ) )
return
if( iKiller && iVictim != iKiller && get_user_flags(iKiller) & VIPN )
{
static maxhp, hp
maxhp = get_pcvar_num( g_pHp[ 2 ] )
hp = get_user_health( iKiller )
if( hp != maxhp )
{
new BonusHp;
if( HeadShot ) BonusHp = get_pcvar_num( g_pHp[ 1 ] )
else BonusHp = get_pcvar_num( g_pHp[ 0 ] )
if( hp + BonusHp > maxhp )
{
set_user_health( iKiller, maxhp )
if(get_pcvar_num(chat_message) == 1)
ChatColor(iKiller, "%L", iKiller, "HP_BONUS", maxhp - hp )
else if(get_pcvar_num(chat_message) == 2)
{
set_hudmessage(105, 117, 151, 0.5, 0.8, 2, 0.1, 4.0, 0.1, 0.1, 2)
show_hudmessage(iKiller, "%L", iKiller, "HP_BONUS", maxhp - hp );
}
}
else
{
set_user_health( iKiller, hp + BonusHp )
if(get_pcvar_num(chat_message) == 1)
ChatColor(iKiller, "%L", iKiller, "HP_BONUS", BonusHp )
else if(get_pcvar_num(chat_message) == 2)
{
set_hudmessage(105, 117, 151, 0.5, 0.8, 2, 0.1, 4.0, 0.1, 0.1, 2)
show_hudmessage(iKiller, "%L", iKiller, "HP_BONUS", BonusHp );
}
}
}
}
}
public GetCount()
{
new iPlayers[ 32 ] , iNum , iCount;
get_players( iPlayers , iNum );
for ( new i = 0 ; i < iNum ; i++ )
iCount += _:( cs_get_user_team( iPlayers[ i ] ) != CS_TEAM_SPECTATOR );
return iCount;
}
public event_CurWeapon(id)
{
new szMapname[64]
get_mapname(szMapname, 63)
if( containi(szMapname, "cs_max") != -1 || containi(szMapname, "2x2") != -1 || containi(szMapname, "_2x2") != -1)
gAwpBlock = true
if(containi(szMapname, "awp"))
{
gAwpBlock = false
switch(read_data(2))
{
case CSW_AWP, CSW_SCOUT, CSW_SG550, CSW_G3SG1:
{
if(get_pcvar_num(awp_block) == 1 && gAwpBlock)
{
client_cmd(id, "drop")
client_print_color(id, print_team_red, "%L", id, "AWP_BLOCK" )
}
if(get_pcvar_num(awp_limit) == 1 && GetCount() < get_pcvar_num(cvar_player)) // psychical code
{
client_cmd(id, "drop")
client_print_color(id, print_team_red, "%L", id, "AWP_LIMIT", get_pcvar_num(cvar_player) )
}
if(get_pcvar_num(awp_vip) == 1 && (!(get_user_flags(id) & VIP)))
{
client_cmd(id, "drop")
client_print_color(id, print_team_red, "%L", id, "AWP_DROP" )
}
}
}
}
}
stock ChatColor(const id, const szMessage[], any:...)
{
static szMsg[190], IdMsg;
vformat(szMsg, charsmax(szMsg), szMessage, 3);
if(!IdMsg) IdMsg = get_user_msgid("SayText");
message_begin(MSG_ONE, IdMsg, .player = id);
write_byte(id);
write_string(szMsg);
message_end();
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1257\\ deff0\\ deflang1063{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/
|
|