搜索
查看: 4156|回复: 9

怎么看都没有错的变量匹配错误tag mismatch

[复制链接]
发表于 2008-6-29 22:47:47 | 显示全部楼层 |阅读模式 来自 中国–广东–深圳
stock bool:fm_is_hull_vacant(const Float:origin[3], hull)
{
static tr; tr = 0; engfunc(EngFunc_TraceHull, origin, origin, 0, hull, 0, tr);
return (!get_tr2(tr, TR_StartSolid) && !get_tr2(tr, TR_AllSolid) && get_tr2(tr, TR_InOpen)) ? true : false
}
以上代码最后一行红色部分,一编译就提示tag mismatch
救命啊。。。:cry:
 楼主| 发表于 2008-6-29 22:48:43 | 显示全部楼层 来自 中国–广东–深圳

回复: 怎么看都没有错的变量匹配错误tag mismatch

TraceResult constants cause a tag mismatch on compile if both engine and fakemeta are included, since both const includes have the TraceResult enum.
engine_const.inc:
// Used by the traceresult() native.
enum
{
TR_AllSolid,   // (int) if true, plane is not valid
TR_StartSolid,  // (int) if true, the initial point was in a solid area
TR_InOpen,  // (int)
TR_InWater, // (int)
TR_Fraction,   // (float) time completed, 1.0 = didn't hit anything
TR_EndPos,   // (vector) final position
TR_PlaneDist,  // (float)
TR_PlaneNormal,  // (vector) surface normal at impact
TR_Hit,    // (entity) entity the surface is on
TR_Hitgroup   // (int) 0 == generic, non zero is specific body part
};fakemeta_const.inc:
enum TraceResult
{
TR_AllSolid,  // int
TR_StartSolid,  // int
TR_InOpen,   // int
TR_InWater,   // int
TR_flFraction,  // float
TR_vecEndPos,  // float array[3]
TR_flPlaneDist,  // float
TR_vecPlaneNormal, // float array[3]
TR_pHit,   // int (edict_t*)
TR_iHitgroup,  // int
};
--------------------------------------------------------------------------------
Was using:
get_tr2(tr, TR_InOpen)Could only get it to compile, after I realized what was going on, when I placed TraceResult in front like so:
get_tr2(tr, TraceResult:TR_InOpen)
回复

使用道具 举报

 楼主| 发表于 2008-6-29 22:49:19 | 显示全部楼层 来自 中国–广东–深圳

回复: 怎么看都没有错的变量匹配错误tag mismatch

TR_StartSolid
TR_AllSolid
TR_InOpen
是整型int,没错呀
回复

使用道具 举报

发表于 2008-6-30 08:05:08 | 显示全部楼层 来自 中国–江苏–南京

回复: 怎么看都没有错的变量匹配错误tag mismatch

多加几个括号试试
:sweat:
回复

使用道具 举报

 楼主| 发表于 2008-6-30 12:16:50 | 显示全部楼层 来自 中国–广东–深圳–宝安区

回复: 怎么看都没有错的变量匹配错误tag mismatch

Post by 52yz
多加几个括号试试
:sweat:
也不行,就算我缩减成get_tr2(tr, TR_InOpen),也会提示一个错误,如果3个都加的话,就提示3个错误,如果这3个我删除了,就不会报错,问题一定是出在get_tr2(tr, TR_InOpen)这个里面。。。:confused:
回复

使用道具 举报

发表于 2008-6-30 12:34:00 | 显示全部楼层 来自 中国–北京–北京–海淀区

回复: 怎么看都没有错的变量匹配错误tag mismatch

  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #define PLUGIN "Test"
  5. #define AUTHOR "Jim"
  6. #define VERSION "1.0"
  7. public plugin_init()
  8. {
  9. register_plugin(PLUGIN, VERSION, AUTHOR)
  10. register_clcmd("test", "test")
  11. }
  12. public test(id)
  13. {
  14. new Float:origin[3]
  15. pev(id, pev_origin, origin)
  16. fm_is_hull_vacant(origin, 1)
  17. }
  18. stock bool:fm_is_hull_vacant(const Float:origin[3], hull)
  19. {
  20. static tr;
  21. tr = 0;
  22. engfunc(EngFunc_TraceHull, origin, origin, 0, hull, 0, tr);
  23. return (!get_tr2(tr, TR_StartSolid) && !get_tr2(tr, TR_AllSolid) && get_tr2(tr, TR_InOpen)) ? true : false
  24. }
复制代码
我用这个测试了一下,没有任何错误
回复

使用道具 举报

发表于 2008-6-30 13:29:00 | 显示全部楼层 来自 中国–福建–漳州

回复: 怎么看都没有错的变量匹配错误tag mismatch

Post by ttbs123
stock bool:fm_is_hull_vacant(const Float:origin[3], hull)
{
static tr; tr = 0; engfunc(EngFunc_TraceHull, origin, origin, 0, hull, 0, tr);
return (!get_tr2(tr, TR_StartSolid) && !get_tr2(tr, TR_AllSolid) && get_tr2(tr, TR_InOpen)) ? true : false
}
以上代码最后一行红色部分,一编...
经测试,这几行代码没有任何错误或警告提示。
回复

使用道具 举报

 楼主| 发表于 2008-6-30 14:37:26 | 显示全部楼层 来自 中国–广东–深圳–宝安区

回复: 怎么看都没有错的变量匹配错误tag mismatch

已经解决了,感谢大家
这是丧尸插件里面的,没有修改之前是编译没有错误的,修改之后就有错误。
今天仔细看我2楼发的资料,我在他们前面加TraceResult:,编译就没有问题了,等于
return (!get_tr2(tr, TraceResult:TR_StartSolid) && !get_tr2(tr, TraceResult:TR_AllSolid) && get_tr2(tr, TraceResult:TR_InOpen)) ? true : false
原因我也不知道为什么要加上那个,现在不会出错太高兴了
回复

使用道具 举报

发表于 2008-7-1 12:33:05 | 显示全部楼层 来自 中国–北京–北京–海淀区

回复: 怎么看都没有错的变量匹配错误tag mismatch

我也没仔细看你2楼的,刚才一看,原来是因为fakemeta和engine都包含TraceResult这个枚举常量,所以编译的时候会出现错误。
回复

使用道具 举报

 楼主| 发表于 2008-7-1 13:12:54 | 显示全部楼层 来自 中国–广东–深圳

回复: 怎么看都没有错的变量匹配错误tag mismatch

Post by jim_yang
我也没仔细看你2楼的,刚才一看,原来是因为fakemeta和engine都包含TraceResult这个枚举常量,所以编译的时候会出现错误。
哦,原来是这个原因,我不懂英文真惨,什么都看不懂
回复

使用道具 举报

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

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