731 发表于 2008-5-14 16:15:27

Voice_Comm_Control.amxx 插件报错!谁来帮忙看看BUG日志

L 05/12/2008 - 23:54:18: Start of error session.
L 05/12/2008 - 23:54:18: Info (map "de_inferno") (logfile "error_051208.log")
L 05/12/2008 - 23:54:18: Invalid player 20
L 05/12/2008 - 23:54:18: Displaying debug trace (plugin "Voice_Comm_Control.amxx")
L 05/12/2008 - 23:54:18: Run time error 10: native error (native "set_speak")
L 05/12/2008 - 23:54:18:     Voice_Comm_Control.sma::eventResetHud (line 58)

==================以下是代码请帮忙修改=========================


/*new g_teamsNames[] = {"TERRORIST","CT"}*/
/*Voice Comm Control
Control dead player can voice comm each other, but alive player can not hear them.
*/
public plugin_init(){
register_plugin("Voice Comm Control","0.0.1","Zhao")
register_event("ResetHUD", "eventResetHud", "be")
register_event("DeathMsg","eDeathMsg","a")
register_concmd("amx_mute","amx_mute_player",ADMIN_VOTE,"playername --Mute players Microphone")
register_concmd("amx_unmute","amx_mute_player",ADMIN_VOTE,"playername --Unmute player's Microphone")
set_task(15.0,"alltalkoff")
}
public alltalkoff(){
set_cvar_num("sv_alltalk",0)
}
public amx_mute_player(id,level,cid){
new playername
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
//new argc = read_argc()
new cmdname
read_argv(0,cmdname,32)
read_argv(1,playername,32)
new player = cmd_target(id,playername,1)
if (!player) return PLUGIN_HANDLED
new imname,name2
get_user_name(player,imname,31)
get_user_name(id,name2,31)

if(equal(cmdname,"amx_mute")){
set_speak(player,SPEAK_MUTED)
console_print(id,"%s is Muted",imname)
log_amx("Mute:%s Muted %s microphone",name2,imname)
}else{
set_speak(player,SPEAK_NORMAL)
console_print(id,"%s is Unmuted",imname)
log_amx("Mute:%s unmuted %s microphone",name2,imname)
}

return PLUGIN_HANDLED
}
public client_putinserver(id){
set_speak(id,SPEAK_LISTENALL)
}
public eventResetHud(id){
new clmsg
set_speak(id,SPEAK_NORMAL)
format(clmsg,512,"^x04^x03现在语音通话被限制在队友之间")
message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, id)
write_byte(id)
write_string(clmsg)
message_end()
}
public eDeathMsg(){
new victim=read_data(2)
new clmsg
set_speak(victim,SPEAK_LISTENALL)
remove_voice_from_alive(victim)
format(clmsg,512,"^x04^x01牺牲了,可以听所有玩家语音通话,但活的队友听不到你的声音")
message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, victim)
write_byte(victim)
write_string(clmsg)
message_end()
}

jim_yang 发表于 2008-5-14 16:39:19

回复: Voice_Comm_Control.amxx 插件报错!谁来帮忙看看BUG日志

run time error 10 不是什么严重的bug,通常是你要执行的参数的对象不存在。
具体到这个插件里就是set_speak(id, _); 这个id不在服务器内。
解决此办法的最好方法就是在前面加 if(is_user_connected(id))
如果是对entity操作就需要在前面加 if(pev_valid(id))
说此bug不严重是因为在调用这个native时,amxx或子模块会检查 entity是否存在,不存在就报错run time error 10并停止执行函数,所以不加你不加检查也是没事儿的。

731 发表于 2008-5-14 16:51:30

回复: Voice_Comm_Control.amxx 插件报错!谁来帮忙看看BUG日志

谢谢 JIM_YANG 的解答!特此感谢.

lu0007 发表于 2008-5-14 16:58:04

回复: Voice_Comm_Control.amxx 插件报错!谁来帮忙看看BUG日志

专业!!!!!!!!!!!!!!!
页: [1]
查看完整版本: Voice_Comm_Control.amxx 插件报错!谁来帮忙看看BUG日志