Osker Lee 发表于 2008-2-13 21:31:30

关于"index out of bounds"的问题

今天我测试火箭筒插件的时候发现了个问题:玩家连续购买火箭筒后,再把火箭筒扔向同一个方向,并且扔两次以上,包括两次,(即购买一支后扔掉,然后再购买一支,朝同一方向再扔掉),控制台就会马上出现debug出错报告,屡试不爽.出错信息如下:
L 09/25/2007 - 19:25:21: Displaying debug trace (plugin "bazooka.amxx")
L 09/25/2007 - 19:25:21: Run time error 4: index out of bounds
L 09/25/2007 - 19:25:21: bazooka.sma: fn_touch(line 939)
L 09/25/2007 - 19:25:21: Displaying debug trace (plugin "bazooka.amxx")
L 09/25/2007 - 19:25:21: Run time error 4: index out of bounds
L 09/25/2007 - 19:25:21: bazooka.sma: fn_touch (line 939)
L 09/25/2007 - 19:25:21: Displaying debug trace (plugin "bazooka.amxx")
L 09/25/2007 - 19:25:21: Run time error 4: index out of bounds
L 09/25/2007 - 19:25:21: bazooka.sma: fn_touch (line 939)
L 09/25/2007 - 19:25:21: Displaying debug trace (plugin "bazooka.amxx")
L 09/25/2007 - 19:25:21: Run time error 4: index out of bounds
L 09/25/2007 - 19:25:21: bazooka.sma: fn_touch (line 939)
麻烦高手们看看到底是什么原因?

zwfgdlc 发表于 2008-2-13 22:51:13

回复: 关于"index out of bounds"的问题

在这少了个判断,增加两行代码试下.

public pfn_touch (toucher, touched) {

new ClassName1
new ClassName2
if(!is_valid_ent(toucher))
return PLUGIN_CONTINUE
if (is_valid_ent(toucher))
entity_get_string(toucher, EV_SZ_classname, ClassName1, 31)

if (is_valid_ent(touched))
entity_get_string(touched, EV_SZ_classname, ClassName2, 31)
if(equal(ClassName1, "rpglancher")&&equal(ClassName2, "rpglancher")) //增加行
return PLUGIN_CONTINUE//增加行

if (equal(ClassName1, "rpgrocket")) {

Osker Lee 发表于 2008-2-14 14:07:23

回复: 关于"index out of bounds"的问题

谢谢zwfgdlc楼主!问题解决了!
页: [1]
查看完整版本: 关于"index out of bounds"的问题