搜索
查看: 4261|回复: 11

请谁能帮忙在这原码上加个功能........(解决问题了谢谢).

[复制链接]
发表于 2008-8-7 01:01:49 | 显示全部楼层 |阅读模式 来自 中国–广西–百色
同队闪光无效插件想加个功能:被敌人或自己闪到屏幕为蓝色,观察者屏幕也是蓝色更好.....

#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <csx>
// 被队友闪后的颜色(R, G, B)
new const COLOR[3]={0, 0, 0}
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)&& 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
}
}
if (flashed){
client_print(flasher, print_chat, "* 警 告: 你 已 闪 中 队 友");
}
}
return FMRES_IGNORED
}
// 记录被闪的人的闪光信息
public event_ScreenFade(id)
{
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
}
// 记录仍雷人的信息
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()
}
发表于 2008-8-7 01:25:58 | 显示全部楼层 来自 中国–广东–惠州

回复: 请谁能帮忙在这原码上加个功能.........

没试过,你自己试吧,思路大概是这样了
[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 (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(flasher==id||(get_user_team(flasher)!=get_user_team(id))||get_user_team(id)==3)
    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)
{
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
}
// 记录仍雷人的信息
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]
回复

使用道具 举报

发表于 2008-8-7 09:30:39 | 显示全部楼层 来自 中国–广东–深圳–福田区

回复: 请谁能帮忙在这原码上加个功能.........

请不要随便的把原来作者的名字换成自己的!
毕竟是别人的原创作品!
又不是自己源码全部是自己写的,把自己的名字改上去,怎么看着那么别扭!!
大家还是注意这一点的好,毕竟别人写的源码也不容易!
请保留对原创作者的最起码尊重!!!!!!
回复

使用道具 举报

 楼主| 发表于 2008-8-7 12:02:15 | 显示全部楼层 来自 中国–广西–南宁

回复: 请谁能帮忙在这原码上加个功能.........

Post by baili1258
请不要随便的把原来作者的名字换成自己的!
毕竟是别人的原创作品!
又不是自己源码全部是自己写的,把自己的名字改上去,怎么看着那么别扭!!
大家还是注意这一点的好,毕竟别人写的源码也不容易!
请保留对原创作者的最起码尊重!!!!!!
俺知道...但得到的原码已是非原码.......
何况我也没该成自己的名字啊....

感谢zwfgdlc版主.....测试出来有个问题.....就是你闪中敌方自己屏幕也是蓝色.....问题出现在哪里呢?请帮忙仔细看一下...
回复

使用道具 举报

发表于 2008-8-7 16:42:53 | 显示全部楼层 来自 中国–广东–深圳–福田区

回复: 请谁能帮忙在这原码上加个功能.........

[php]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 (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((get_user_team(flasher)!=get_user_team(id))||get_user_team(id)==3)
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
}[/php]

这样试下!!
希望你说的是真的...
回复

使用道具 举报

发表于 2008-8-7 17:23:55 | 显示全部楼层 来自 中国–广东–惠州–惠城区

回复: 请谁能帮忙在这原码上加个功能.........

  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <cstrike>
  4. #include <csx>
  5. // 被队友闪后的颜色(R, G, B)
  6. new const COLOR[3]={0, 0, 0}
  7. //闪到自己或观察者或是被敌人闪中颜色
  8. new const COLOR2[3]={20, 120, 255}
  9. enum FLASH{
  10. Float:GameTime,
  11. Duration,
  12. HoldTime,
  13. FadeType,
  14. Alpha
  15. }
  16. new PLAYER[33][FLASH]
  17. new pTeamFlashed
  18. new gMsgScreenFade
  19. new gMaxPlayers
  20. new const FLASHSOUND[2][]={
  21. "weapons/flashbang-1.wav",
  22. "weapons/flashbang-2.wav"
  23. }
  24. public plugin_init()
  25. {
  26. register_plugin("poop", "1.0", "A.MI")
  27. register_forward(FM_EmitSound, "fw_FM_EmitSound")
  28. register_event("ScreenFade", "event_ScreenFade", "be", "4=255", "5=255", "6=255", "7>199")
  29. pTeamFlashed = register_cvar("team_flashed", "1")
  30. gMsgScreenFade = get_user_msgid("ScreenFade")
  31. gMaxPlayers = get_maxplayers()
  32. }
  33. public fw_FM_EmitSound(entity, channel, const sample[], Float:volume, Float:attenuation, fFlags, pitch)
  34. {
  35. if(!get_pcvar_num(pTeamFlashed))
  36. return FMRES_IGNORED
  37. // 闪光?
  38. if(!equali(sample, FLASHSOUND[0]) && !equali(sample, FLASHSOUND[1]))
  39. return FMRES_IGNORED
  40. static flashed, Float:time, name[32], flasher, team
  41. flashed = 0
  42. flasher = pev(entity, pev_iuser3)
  43. team = pev(entity, pev_iuser4)
  44. time = get_gametime()
  45. get_user_name(flasher, name, 31)
  46. if (is_user_connected(flasher))
  47. {
  48. for(new id=1; id<=gMaxPlayers; id++)
  49. {
  50. if(!is_user_connected(id)) continue;
  51. if (PLAYER[id][GameTime]==time&& team==get_user_team(id)&& flasher!=id)
  52. {
  53. FlashedEvent(id, PLAYER[id][Duration], PLAYER[id][HoldTime], PLAYER[id][FadeType], COLOR[0], COLOR[1], COLOR[2], PLAYER[id][Alpha])
  54. flashed = 1
  55. }else if(PLAYER[id][GameTime]==time&&(flasher==id||get_user_team(id)==3||(get_user_team(flasher)!=get_user_team(id))))
  56. FlashedEvent(id, PLAYER[id][Duration], PLAYER[id][HoldTime], PLAYER[id][FadeType], COLOR2[0], COLOR2[1], COLOR2[2], PLAYER[id][Alpha]);
  57. }
  58. if (flashed)
  59. {
  60. client_print(flasher, print_chat, "* 警 告: 你 已 闪 中 队 友");
  61. }
  62. }
  63. return FMRES_IGNORED
  64. }
  65. // 记录被闪的人的闪光信息
  66. public event_ScreenFade(id)
  67. {
  68. PLAYER[id][GameTime] = _:get_gametime()
  69. PLAYER[id][Duration] = read_data(1)
  70. PLAYER[id][HoldTime] = read_data(2)
  71. PLAYER[id][FadeType] = read_data(3)
  72. PLAYER[id][Alpha] = 0
  73. }
  74. // 记录仍雷人的信息
  75. public grenade_throw(id, entity, WpnID)
  76. {
  77. if (WpnID == CSW_FLASHBANG)
  78. {
  79. set_pev(entity, pev_iuser3, id) // 这个雷是谁的
  80. set_pev(entity, pev_iuser4, get_user_team(id)) // 他的队伍是?
  81. }
  82. }
  83. // 发送闪光效果
  84. stock FlashedEvent(id, iDuration, iHoldTime, iFadeType, iRed, iGreen, iBlue, iAlpha)
  85. {
  86. message_begin(MSG_ONE, gMsgScreenFade, {0,0,0}, id)
  87. write_short(iDuration) // Duration
  88. write_short(iHoldTime) // Hold time
  89. write_short(iFadeType) // Fade type
  90. write_byte (iRed) // Red
  91. write_byte (iGreen) // Green
  92. write_byte (iBlue) // Blue
  93. write_byte (iAlpha) // Alpha
  94. message_end()
  95. }
复制代码
回复

使用道具 举报

 楼主| 发表于 2008-8-7 20:23:10 | 显示全部楼层 来自 中国–广西–百色–平果市

回复: 请谁能帮忙在这原码上加个功能.........

观察员还是白茫茫.....这个较难点...
回复

使用道具 举报

发表于 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]
回复

使用道具 举报

 楼主| 发表于 2008-8-8 09:25:30 | 显示全部楼层 来自 中国–广西–百色–右江区

回复: 请谁能帮忙在这原码上加个功能.........

多次麻烦....很感谢......但问题依旧.....看来它是个大难题....

(解决这个问题主要是保护玩家的眼睛,要不然俺也不那么强烈为难大家的....
俺问过医生,白屏幕刺眼容易得白内障.............希望大家支持解决)


下面的版主:测试成功,谢谢.
回复

使用道具 举报

发表于 2008-8-8 10:14:50 | 显示全部楼层 来自 中国–广东–深圳–福田区

回复: 请谁能帮忙在这原码上加个功能.........

[PHP]
register_event("ScreenFade", "event_ScreenFade", "b", "4=255", "5=255", "6=255", "7>199")
[/PHP]

把上面的改下试试!
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表