OooH_闪光插件rsdtt斑竹最终修正版含原码
本帖最后由 zhaojian0733 于 2011-8-21 00:20 编辑OooH_Team_Flashed报错,大师来帮忙
就是闪到队友扣钱 多少次以后就禁止闪光
斑竹 大师们 帮忙看看
L 08/17/2011 - 12:27:53: Start of error session.
L 08/17/2011 - 12:27:53: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20110817.log")
L 08/17/2011 - 12:27:53: Displaying debug trace (plugin "OooH_Team_Flashed.amxx")
L 08/17/2011 - 12:28:52: Displaying debug trace (plugin "OooH_Team_Flashed.amxx")
L 08/17/2011 - 12:28:52: Run time error 4: index out of bounds
L 08/17/2011 - 12:28:52: OooH_Team_Flashed.sma::save_stats (line 229)
L 08/17/2011 - 12:28:52: OooH_Team_Flashed.sma::fw_FM_EmitSound (line 164)
下面是插件代码:
/*
插件:OooH Team Flashed 被队友闪到时,闪光为红色
作者:PooHoo@老友记
来源:http://cs-friends.com.cn
, CS/CZ 3329+, AMXX 1.76, 测试通过
附言:
*/
感谢原作者创作
特别感谢rsdtt斑竹修正有new db_playerFlash
经观察应该是溢出问题,将这里改为
new db_playerFlash 的错误
现上传一下 完美版 给各位网友分享 register_event("CurWeapon","eWeaponChange","be")//没收闪光
gMaxPlayers = get_maxplayers()
db_slot_i = gMaxPlayers+1
}
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) && !equali(sample, FLASHSOUND))
return FMRES_IGNORED
static flashed, Float:time, name, flasher, team, teamnum,g_punishmoney,msg
flashed = 0
teamnum = 0//初始化闪到队友的人数
flasher = pev(entity, pev_iuser3)
team = pev(entity, pev_iuser4)
time = get_gametime()
get_user_name(flasher, name, 31)
g_punishmoney = get_cvar_num("sl_punishmoney")
if (is_user_connected(flasher))
{
for(new id=1; id<=gMaxPlayers; id++)
{
if (is_user_connected(id) && PLAYER==time && team==get_user_team(id) && flasher!=id && is_user_alive(id) ){
if(is_player_in_buyzone(id)&& z_teamFlash && is_player_in_buyzone(flasher))//在购买区域,购时间的范围内!在基地乱丢闪光并闪到在基地的队友!
{
if(is_user_alive(flasher))
{
user_kill(flasher);//处死
ryu_set_money(flasher,0,1)//没收全部金钱
format(msg,sizeof msg - 1,"^x04[基地故意闪光]::^x03%s^x01在基地恶意扔闪光,已被^x04吊死^x01!!!,并^x04没收个人所有财产",name)
client_color(0, id, msg)
return FMRES_HANDLED
}
}else if(ryu_get_money(flasher) >= g_punishmoney){
format(msg,sizeof msg - 1,"^x04[^x03队友闪光提示^x04]::^x01队友 ^x03%s ^x01闪到你,赔偿你精神损失费^x04[^x03$%d^x04]",name,g_punishmoney)
client_color(id, id, msg)
client_cmd(id, "q3/hit" )
ryu_set_money(id,ryu_get_money(id)+g_punishmoney,1)
ryu_set_money(flasher,ryu_get_money(flasher) - g_punishmoney,1)
}else{
format(msg,sizeof msg - 1,"^x04[^x03队友闪光提示^x04]::^x01队友^x03 %s,^x01可他好穷啊!连 ^x04[$%d^x04] ^x01都赔不起,扁他...!",name,g_punishmoney)
client_color(id, id, msg)
user_slap(flasher,8,1)
client_cmd(id, "spk q3/hit" )
}
flashed = 1
teamnum++ //闪到队友的累计
}
save_stats(flasher)
}
if (flashed)
{
// 这个闪光的人 flasher 通知或惩罚他
if (playerFlash >= get_pcvar_num(g_team_flashnum) ){
g_playerFlash = true
format(msg,sizeof msg - 1,"^x04[^x03队友闪光处罚^x04]:^x01你因闪到队友超过^x04[^x03%d^x04]^x01次,当前地图已^x03禁止你使用闪光弹",get_pcvar_num(g_team_flashnum))
client_color(flasher, flasher, msg)
client_cmd(flasher, "spk q3/hit" )
save_stats(flasher)
return FMRES_HANDLED
}
else if(ryu_get_money(flasher) >= g_punishmoney){
format(msg,sizeof msg - 1,"^x04[^x03队友闪光处罚^x04]:^x01闪到^x04[^x03%d^x04]^x01个队友,赔偿^x03精神损失费^x04[^x03$%d^x04][^x01禁闪次数:^x03%d^x01次^x04/^x01此次是第^x03%d^x01次^x04]",teamnum,g_punishmoney*teamnum,get_pcvar_num(g_team_flashnum),playerFlash+1)
client_color(flasher, flasher, msg)
}
else{
format(msg,sizeof msg - 1,"^x04[^x03队友闪光处罚^x04]:^x01闪到^x04[^x03%d^x04]^x01个队友,有钱赔钱,^x03没钱一人一拳^x04[^x01禁闪次数:^x03%d^x01次^x04/^x01此次是第^x03%d^x01次^x04]",teamnum,get_pcvar_num(g_team_flashnum),playerFlash+1)
client_color(flasher, flasher, msg)
ryu_set_money(flasher,0,1)
}
client_cmd(flasher, "spk q3/hit" )
playerFlash++
}
}
return FMRES_IGNORED
}
public client_putinserver(id)
{
load_stats(id)
}
public eNewRound(){
z_teamFlash=true
set_task(get_cvar_float("mp_buytime")*60+get_cvar_float("mp_freezetime"),"set_cvar")
}
public set_cvar()
{
z_teamFlash=false;
}
//防止用户断开后,之前记录的闪光闪到队友次数为0了
save_stats(id)
{
static name
get_user_name(id, name, sizeof name - 1)
if (db_name && !equal(name, db_name))
{
if (db_slot_i >= sizeof db_name)
db_slot_i = gMaxPlayers+1
if ( !is_user_connected(id))
return;
copy(db_name, 63, db_name)
db_playerFlash = db_playerFlash
db_slot_i++
}
copy(db_name, 63, name)
db_playerFlash = playerFlash
}
//载入之前保存的数据!
load_stats(id)
{
static name, i
get_user_name(id, name, sizeof name - 1)
for (i = 0; i < sizeof db_name; i++)
{
if (equal(name, db_name))
{
playerFlash = db_playerFlash;
if(playerFlash >= get_pcvar_num(g_team_flashnum))
{
g_playerFlash = true
}
return;
}
}
}
// 记录被闪的人的闪光信息
public event_ScreenFade(id)
{
PLAYER = _:get_gametime()
PLAYER = read_data(1)
PLAYER = read_data(2)
PLAYER = read_data(3)
PLAYER = read_data(7)
}
// 记录仍雷人的信息
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))// 他的队伍是?
}
}
public HookBuyFlash(id)
{
if(!z_teamFlash && !is_player_in_buyzone(id))//购买时间内,购买区域内
return PLUGIN_HANDLED
if( get_pcvar_num(pTeamFlashed) && g_playerFlash)
{
client_print(id, print_center, "当前地图你闪到队友超过 %d 次,服务器禁止你购买闪光弹",get_pcvar_num(g_team_flashnum))
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public eAmmoX(id)
{
new clip, ammo
new wpnid = get_user_weapon(id, clip, ammo)
if ( wpnid == CSW_FLASHBANG && g_playerFlash && get_pcvar_num(pTeamFlashed))
{
client_print(id, print_center, "当前地图你闪到队友超过 %d 次,服务器禁止你购买和使用闪光弹",get_pcvar_num(g_team_flashnum))
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public eWeaponChange(id)
{
new wpnid = read_data(2)
if ( wpnid == CSW_FLASHBANG && g_playerFlash && get_pcvar_num(pTeamFlashed))
{
client_print(id, print_center, "当前地图你闪到队友超过 %d 次,服务器没收你的闪光弹",get_pcvar_num(g_team_flashnum))
fm_set_user_bpammo(id,CSW_FLASHBANG,0)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
// Set User BP Ammo
stock fm_set_user_bpammo(id, weapon, amount)
{
static offset
switch(weapon)
{
case CSW_AWP: offset = OFFSET_AWM_AMMO;
case CSW_SCOUT,CSW_AK47,CSW_G3SG1: offset = OFFSET_SCOUT_AMMO;
case CSW_M249: offset = OFFSET_PARA_AMMO;
case CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552: offset = OFFSET_FAMAS_AMMO;
case CSW_M3,CSW_XM1014: offset = OFFSET_M3_AMMO;
case CSW_USP,CSW_UMP45,CSW_MAC10: offset = OFFSET_USP_AMMO;
case CSW_FIVESEVEN,CSW_P90: offset = OFFSET_FIVESEVEN_AMMO;
case CSW_DEAGLE: offset = OFFSET_DEAGLE_AMMO;
case CSW_P228: offset = OFFSET_P228_AMMO;
case CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITE: offset = OFFSET_GLOCK_AMMO;
case CSW_FLASHBANG: offset = OFFSET_FLASH_AMMO;
case CSW_HEGRENADE: offset = OFFSET_HE_AMMO;
case CSW_SMOKEGRENADE: offset = OFFSET_SMOKE_AMMO;
case CSW_C4: offset = OFFSET_C4_AMMO;
default: return;
}
set_pdata_int(id, offset, amount, 5);
}
stock ryu_set_money(id,money,flash=0)
{
set_pdata_int(id,OFFSET_CSMONEY,money,5);
message_begin(MSG_ONE,get_user_msgid("Money"),{0,0,0},id);
write_long(money);
write_byte(flash);
message_end();
}
stock ryu_get_money(id)
{
return get_pdata_int(id,OFFSET_CSMONEY,5);
}
public client_color(playerid, colorid, msg[])
{
message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),_,playerid)
write_byte(colorid)
write_string(msg)
message_end()
} 把整个文件发上来,你这样发窝不知道你哪行出错了 应该是出在保存信息的环节上,如果没必要保存闪光次数可以用这个就可以了/*
插件:OooH Team Flashed 被队友闪到时,闪光为红色
作者:PooHoo@老友记
来源:http://cs-friends.com.cn
, CS/CZ 3329+, AMXX 1.76, 测试通过
功能:
当被队友闪到时,闪光为红色,被敌人或自己闪不改原有设置,依然是白色
说明:
team_flashed "1" // 插件开关(默认1)
附言:
这个插件,难就难在如何确定被闪时,这个闪光是谁扔的?
判断方法有好多种,在官方论坛里有几个关于闪光的插件
“No Team Flash”“Team Flash Snitch”。。等等
但处理方法不理想,不能100%正确判断扔雷的人。
我使用不同的处理方法,准确判断扔闪光的人100%有效。
正确获得扔雷的人后,我们可以修改扩展一下功能:
1,惩罚闪队友的人(掉血,扣金钱,没收武器。。)
2,进行计数,闪队友N次后,踢出,处死
3,去掉队友的闪光,
4,禁止他再购买或使用闪光弹
5,等等。。。
注意:如果惩罚过度,会激化玩家之间的矛盾,需谨慎。
*/
#include <amxmodx>
#include <fakemeta>
#include <csx>
// 被队友闪后的颜色(R, G, B)
new const COLOR={255, 50, 50} // 红色
enum FLASH{
Float:GameTime,
Duration,
HoldTime,
FadeType,
Alpha
}
new PLAYER
new pTeamFlashed
new gMsgScreenFade
new gMaxPlayers
new const FLASHSOUND[]={
"weapons/flashbang-1.wav",
"weapons/flashbang-2.wav"
}
public plugin_init()
{
register_plugin("OooH Team Flashed", "1.0", "PooHoo@cs-friends.com.cn")
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) && !equali(sample, FLASHSOUND))
return FMRES_IGNORED
static flashed, Float:time, name, 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==time
&& team==get_user_team(id)
&& flasher!=id)
{
client_print(id, print_chat, "OooH, 队友[%s] 闪到你了", name)
FlashedEvent(id, PLAYER, PLAYER, PLAYER, COLOR, COLOR, COLOR, PLAYER)
flashed = 1
}
}
if (flashed)
{
// 这个闪光的人 flasher 通知或惩罚他
client_print(flasher, print_chat, "OH NO, 老兄,你闪到队友了,要注意哦...")
// 添加其他惩罚代码。。。
}
}
return FMRES_IGNORED
}
// 记录被闪的人的闪光信息
public event_ScreenFade(id)
{
PLAYER = _:get_gametime()
PLAYER = read_data(1)
PLAYER = read_data(2)
PLAYER = read_data(3)
PLAYER = read_data(7)
}
// 记录仍雷人的信息
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()
}
4# rsdtt
请问大侠 这个可以设置比如 闪了队友5次了就不能买用闪光了即使他重新再进一次服务器又开始重新计算5次呢?
我不要求他闪了队友5次后从此不能在买用闪光 而只要要保留在当前开放的服务器信息里,因为我每天都要重新服务器的 这样他能够得以恢复就可以 我还是想记录次数啊 不然不差钱的VIP岂不是可以狂闪别人了,或者钱被扣光了就重新进一下服务器,就又有16000了啊 ,我就是想约束一下乱扔闪光的人,他要是不会扔就别让他扔,他只顾自己的乱扔别人弄的老是白。。
如果不好找漏洞那就请 大师帮我看看会不会因为这个漏洞而导致插件不能运行或者对服务器稳定有什么影响吗
如果影响不大 我就忍了 这个作者毕竟是2007年创作的,估计人家早就不研究这个了。。。 你把源码打包上来,你这样我不知道具体哪一行有问题 本帖最后由 zhaojian0733 于 2011-8-21 00:08 编辑
7# rsdtt
好的 谢谢大师 我现在服务器就这一个插件报错误 其他都很好了。。麻烦你多费心
7# rsdtt
再次感谢! 期待R版的完美源码,呵呵。。。
页:
[1]
2