PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include "furien.inc"
#include "furien_shop.inc"
#define VERSION "0.0.2"
#define XTRA_OFS_PLAYER 5
#define m_Activity 73
#define m_IdealActivity 74
#define m_flNextAttack 83
#define m_afButtonPressed 246
#define FIRST_PLAYER_ID 1
#define MAX_PLAYERS 32
#define PLAYER_JUMP 6
#define ACT_HOP 7
//#define FBitSet(%1,%2) (%1 & %2)
new g_iMaxPlayers
#define IsPlayer(%1) ( FIRST_PLAYER_ID <= %1 <= g_iMaxPlayers )
#define IsHidden(%1) IsPlayer(%1)
#define KNIFE_DRAW 3
new g_bHasWallHang
#define SetUserWallHang(%1) g_bHasWallHang |= 1<<(%1&31)
#define RemoveUserWallHang(%1) g_bHasWallHang &= ~(1<<(%1&31))
#define HasUserWallHang(%1) g_bHasWallHang & 1<<(%1&31)
new g_bHanged
#define SetUserHanged(%1) g_bHanged |= 1<<(%1&31)
#define RemoveUserHanged(%1) g_bHanged &= ~(1<<(%1&31))
#define IsUserHanged(%1) g_bHanged & 1<<(%1&31)
new Float:g_fVecMins[MAX_PLAYERS+1][3]
new Float:g_fVecMaxs[MAX_PLAYERS+1][3]
new Float:g_fVecOrigin[MAX_PLAYERS+1][3]
new g_iCost[2]
new bool:g_bRoundEnd
public plugin_init()
{
register_plugin("Furien WallHang", VERSION, "ConnorMcLeod")
new szConfigFile[128]
get_localinfo("amxx_configsdir", szConfigFile, charsmax(szConfigFile))
format(szConfigFile, charsmax(szConfigFile), "%s/furien/items/wallhang.ini", szConfigFile);
new fp = fopen(szConfigFile, "rt")
if( !fp )
{
return
}
new szFurienName[32], szAntiName[32]
new szDatas[64], szKey[16], szValue[32]
while( !feof(fp) )
{
fgets(fp, szDatas, charsmax(szDatas))
trim(szDatas)
if(!szDatas[0] || szDatas[0] == ';' || szDatas[0] == '#' || (szDatas[0] == '/' && szDatas[1] == '/'))
{
continue
}
parse(szDatas, szKey, charsmax(szKey), szValue, charsmax(szValue))
switch( szKey[0] )
{
case 'A':
{
switch( szKey[7] )
{
case 'M':
{
if( equal(szKey, "ANTI_NAME" ) )
{
copy(szAntiName, charsmax(szAntiName), szValue)
}
}
case 'S':
{
if( equal(szKey, "ANTI_COST" ) )
{
g_iCost[AntiFurien] = str_to_num(szValue)
}
}
}
}
case 'F':
{
switch( szKey[9] )
{
case 'M':
{
if( equal(szKey, "FURIEN_NAME" ) )
{
copy(szFurienName, charsmax(szAntiName), szValue)
}
}
case 'S':
{
if( equal(szKey, "FURIEN_COST" ) )
{
g_iCost[Furien] = str_to_num(szValue)
}
}
}
}
}
}
fclose( fp )
if( g_iCost[Furien] || g_iCost[AntiFurien] )
{
furien_register_item(szFurienName, g_iCost[Furien], szAntiName, g_iCost[AntiFurien], "furien_buy_wallhang")
RegisterHam(Ham_Player_Jump, "player", "Player_Jump")
RegisterHam(Ham_Touch, "func_wall", "World_Touch")
RegisterHam(Ham_Touch, "func_breakable", "World_Touch")
RegisterHam(Ham_Touch, "worldspawn", "World_Touch")
g_iMaxPlayers = get_maxplayers()
register_event("HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0")
register_logevent("Logevent_Round_End", 2, "1=Round_End")
}
}
public Event_HLTV_New_Round()
{
g_bRoundEnd = false
}
public Logevent_Round_End()
{
g_bRoundEnd = true
g_bHanged = 0
}
public client_putinserver( id )
{
RemoveUserWallHang( id )
RemoveUserHanged( id )
}
public furien_team_change( /*iFurien */ )
{
if( !g_iCost[Furien] || !g_iCost[AntiFurien] )
{
g_bHasWallHang = 0
g_bHanged = 0
}
}
public furien_round_restart()
{
g_bHasWallHang = 0
g_bHanged = 0
}
public furien_buy_wallhang( id )
{
new iTeam = furien_get_user_team(id)
if( iTeam == -1 )
{
return ShopCloseMenu
}
new iItemCost = g_iCost[iTeam]
if( iItemCost <= 0 )
{
return ShopTeamNotAvail
}
if( ~HasUserWallHang(id) )
{
if( furien_try_buy(id, iItemCost) )
{
SetUserWallHang( id )
return ShopBought
}
else
{
return ShopNotEnoughMoney
}
}
return ShopAlreadyHaveOne
}
public Player_Jump(id)
{
if( g_bRoundEnd
|| ~HasUserWallHang(id)
|| ~IsUserHanged(id)
|| !is_user_alive(id) )
{
return HAM_IGNORED
}
if( (pev(id, pev_flags) & FL_WATERJUMP) || pev(id, pev_waterlevel) >= 2 )
{
return HAM_IGNORED
}
static afButtonPressed ; afButtonPressed = get_pdata_int(id, m_afButtonPressed)
if( ~afButtonPressed & IN_JUMP )
{
return HAM_IGNORED
}
RemoveUserHanged(id)
new Float:fVecVelocity[3]
velocity_by_aim(id, 600, fVecVelocity)
set_pev(id, pev_velocity, fVecVelocity)
set_pdata_int(id, m_Activity, ACT_HOP)
set_pdata_int(id, m_IdealActivity, ACT_HOP)
set_pev(id, pev_gaitsequence, PLAYER_JUMP)
set_pev(id, pev_frame, 0.0)
set_pdata_int(id, m_afButtonPressed, afButtonPressed & ~IN_JUMP)
return HAM_SUPERCEDE
}
public client_PostThink(id)
{
if( HasUserWallHang(id) && IsUserHanged(id) )
{
engfunc(EngFunc_SetSize, id, g_fVecMins[ id ], g_fVecMaxs[ id ])
engfunc(EngFunc_SetOrigin, id, g_fVecOrigin[ id ])
set_pev(id, pev_velocity, 0)
set_pdata_float(id, m_flNextAttack, 1.0, XTRA_OFS_PLAYER)
}
}
public World_Touch(iEnt, id)
{
if( !g_bRoundEnd
&& IsPlayer(id)
&& HasUserWallHang(id)
&& ~IsUserHanged(id)
&& is_user_alive(id)
&& pev(id, pev_button) & IN_USE
&& ~pev(id, pev_flags) & FL_ONGROUND )
{
SetUserHanged(id)
pev(id, pev_mins, g_fVecMins[id])
pev(id, pev_maxs, g_fVecMaxs[id])
pev(id, pev_origin, g_fVecOrigin[id])
}
}