get_user_team会返回哪几个值,下面的代码老是index out of round
1 魔兽里面的skills.inl 76行if ( Verify_Skill(id, RACE_BLOOD, SKILL1) ){
new Float:randomnumber = random_float(0.0,1.0)
new teamnumber = get_user_team(id)
if (randomnumber <= p_pheonix-1]){
p_data_b = true
//这里应该加上点判断,我认为!
PhoenixFound++
}
}
PhoenixFound++这句,指不定什么时候就出个索引超出范围,是因为teamnumber没判断,还是id是否有效没判断?
回复: get_user_team会返回哪几个值,下面的代码老是index out of round
/* Get team directly from player's entity.* 1 = terrorist
* 2 = counter-terrorist
* 3 = spectator
*/
enum CsTeams {
CS_TEAM_UNASSIGNED = 0,
CS_TEAM_T = 1,
CS_TEAM_CT = 2,
CS_TEAM_SPECTATOR = 3
};
这是定义的常数
回复: get_user_team会返回哪几个值,下面的代码老是index out of round
常数定义了 new PhoenixFound是不是改成3会好,因为存在旁观者3
回复: get_user_team会返回哪几个值,下面的代码老是index out of round
返回值应该在0~3之间吧,所以要定义一个带4个元素的数组,即PhoenixFound.使用时就PhoenixFound++就行了,不要再减1了。
回复: get_user_team会返回哪几个值,下面的代码老是index out of round
实践后,-1是必须的,否则会出现无法复活队友的情况,大家如果也存在warcraft3ft.amxx 2.3.2报错,Runtime error 4(索引超限) 这个错误,只需要把定义的new PhoenixFound改成new PhoenixFound,顺便再一次感谢rulzy版主的大力支持。回复: get_user_team会返回哪几个值,下面的代码老是index out of round
1 魔兽里面的skills.inl 76行if ( Verify_Skill(id, RACE_BLOOD, SKILL1) ){
new Float:randomnumber = random_float(0.0,1.0)
new teamnumber = get_user_team(id)
if (randomnumber <= p_pheonix-1]){
p_data_b = true
//这里应该加上点判断,我认为!
//实际上确实应该加判断,否则索引改成4依然出错
if (!(teamnumber == 0)){
PhoenixFound++
}
}
}
页:
[1]