搜索
查看: 2162|回复: 5

[求助] jim_yang 请你帮我看一下这个代码问题该怎么修正!

[复制链接]
发表于 2008-6-27 18:35:59 | 显示全部楼层 |阅读模式 来自 中国–辽宁–沈阳
debug 模式运行显示以下 错误
[PHP]L 06/27/2008 - 18:01:45: [AMXX] Run time error 10: native error (native "get_weaponname")
L 06/27/2008 - 18:01:45: [AMXX]    [0] test.sma::MyLast (line 20)[/PHP]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
发表于 2008-6-27 18:44:25 | 显示全部楼层 来自 中国–北京–北京–海淀区

回复: [求助] jim_yang 请你帮我看一下这个代码问题该怎么修正!

if( 0 < wpid < MAX_WEAPONS)
   get_weaponname(wpid, ...)
回复

使用道具 举报

 楼主| 发表于 2008-6-29 19:31:31 | 显示全部楼层 来自 中国–辽宁–沈阳

回复: [求助] jim_yang 请你帮我看一下这个代码问题该怎么修正!

谢谢 jim_yang  能解释一下原因么?
回复

使用道具 举报

发表于 2008-6-29 20:23:33 | 显示全部楼层 来自 中国–北京–北京–海淀区

回复: [求助] jim_yang 请你帮我看一下这个代码问题该怎么修正!

原因就是get_weaponname函数是通过给定id查找武器名字字符串数组,所以会存在越界问题,所以用之前amxx会自行检查给定的wpid是否是合法值(0<wpid<32),不是的话就会产生运行时错误。为避免错误发生可以加入 if 语句检查,否则得不到想要的结果
回复

使用道具 举报

发表于 2008-6-29 20:36:45 | 显示全部楼层 来自 中国–辽宁–沈阳

回复: [求助] jim_yang 请你帮我看一下这个代码问题该怎么修正!

/* Returns all carried weapons as bit sum. Gets
* also theirs indexes.
* Note that num is incremental - if you pass 0, you get
* 32 weapons towards the total. Afterwards, num will
* will contain the number of weapons retrieved.
* However, subsequent calls to get_user_weapons() will
* return the next batch of weapons, in case the mod
* supports more than 32 weapons.
* This means to call get_user_weapons() on the same
* inputs twice, you must reset num to 0 to get the
* original output again.
*/


学到了一些东西 谢谢
回复

使用道具 举报

 楼主| 发表于 2008-6-29 20:41:07 | 显示全部楼层 来自 中国–辽宁–沈阳

回复: [求助] jim_yang 请你帮我看一下这个代码问题该怎么修正!

万分感激  ........:)
回复

使用道具 举报

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

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