|
发表于 2008-8-8 01:19:52
|
显示全部楼层
来自 中国–广东–惠州
回复: 请谁能帮忙在这原码上加个功能.........
试下这样
[php]
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <csx>
// 被队友闪后的颜色(R, G, B)
new const COLOR[3]={0, 0, 0}
//闪到自己或观察者或是被敌人闪中颜色
new const COLOR2[3]={20, 120, 255}
enum FLASH{
Float:GameTime,
Duration,
HoldTime,
FadeType,
Alpha
}
new PLAYER[33][FLASH]
new pTeamFlashed
new gMsgScreenFade
new gMaxPlayers
new const FLASHSOUND[2][]={
"weapons/flashbang-1.wav",
"weapons/flashbang-2.wav"
}
public plugin_init()
{
register_plugin("poop", "1.0", "A.MI")
register_forward(FM_EmitSound, "fw_FM_EmitSound")
register_event("ScreenFade", "event_ScreenFade", "be", "4=255", "5=255", "6=255", "7>199")
pTeamFlashed = register_cvar("team_flashed", "1")
gMsgScreenFade = get_user_msgid("ScreenFade")
gMaxPlayers = get_maxplayers()
}
public fw_FM_EmitSound(entity, channel, const sample[], Float:volume, Float:attenuation, fFlags, pitch)
{
if(!get_pcvar_num(pTeamFlashed))
return FMRES_IGNORED
// 闪光?
if(!equali(sample, FLASHSOUND[0]) && !equali(sample, FLASHSOUND[1]))
return FMRES_IGNORED
static flashed, Float:time, name[32], flasher, team
flashed = 0
flasher = pev(entity, pev_iuser3)
team = pev(entity, pev_iuser4)
time = get_gametime()
get_user_name(flasher, name, 31)
if (is_user_connected(flasher))
{
for(new id=1; id<=gMaxPlayers; id++)
{
if(!is_user_connected(id)) continue;
if(get_user_team(id)==3) continue;
if (PLAYER[id][GameTime]==time&& team==get_user_team(id)&& flasher!=id)
{
FlashedEvent(id, PLAYER[id][Duration], PLAYER[id][HoldTime], PLAYER[id][FadeType], COLOR[0], COLOR[1], COLOR[2], PLAYER[id][Alpha])
flashed = 1
}else if(PLAYER[id][GameTime]==time&&(flasher==id||(team!=get_user_team(id))))
FlashedEvent(id, PLAYER[id][Duration], PLAYER[id][HoldTime], PLAYER[id][FadeType], COLOR2[0], COLOR2[1], COLOR2[2], PLAYER[id][Alpha]);
}
if (flashed)
{
client_print(flasher, print_chat, "* 警 告: 你 已 闪 中 队 友");
}
}
return FMRES_IGNORED
}
// 记录被闪的人的闪光信息
public event_ScreenFade(id)
{
if(get_user_team(id)==3)
{
FlashedEvent(id, read_data(1), read_data(2), read_data(3), COLOR2[0], COLOR2[1], COLOR2[2], read_data(7));
return PLUGIN_HANDLED;
}
PLAYER[id][GameTime] = _:get_gametime()
PLAYER[id][Duration] = read_data(1)
PLAYER[id][HoldTime] = read_data(2)
PLAYER[id][FadeType] = read_data(3)
PLAYER[id][Alpha] = 0
return PLUGIN_HANDLED;
}
// 记录仍雷人的信息
public grenade_throw(id, entity, WpnID)
{
if (WpnID == CSW_FLASHBANG)
{
set_pev(entity, pev_iuser3, id) // 这个雷是谁的
set_pev(entity, pev_iuser4, get_user_team(id)) // 他的队伍是?
}
}
// 发送闪光效果
stock FlashedEvent(id, iDuration, iHoldTime, iFadeType, iRed, iGreen, iBlue, iAlpha)
{
message_begin(MSG_ONE, gMsgScreenFade, {0,0,0}, id)
write_short(iDuration) // Duration
write_short(iHoldTime) // Hold time
write_short(iFadeType) // Fade type
write_byte (iRed) // Red
write_byte (iGreen) // Green
write_byte (iBlue) // Blue
write_byte (iAlpha) // Alpha
message_end()
}
[/php] |
|