Po edycji nie wystąpił error tak więc dla kogoś komu się to przytrafiło a nie potrafi tego rozwiązać :
public Surf(id, skill, prop)
{
new level = SkillLevel(id, skill)
new Float:surf_origin[3]
new surf_ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
set_pev(surf_ent, pev_classname, "pokemod_ent")
set_pev(surf_ent, pev_owner, id)
set_pev(surf_ent, pev_iuser1, 5+SkillLevel(id, skill))
set_pev(surf_ent, pev_iuser2, skill)
//lets use origin multiple times for the heck of not creating more variables (and im lazy)
pev(id, pev_origin, surf_origin)
engfunc(EngFunc_SetOrigin, surf_ent, surf_origin)
pev(id, pev_angles, surf_origin)
surf_origin[1] -=90 //my stupidity when making the model, so lets rotate it so it looks correct
if(surf_origin[1]<-180)
surf_origin[1] += 360
surf_origin[0] = 0.0
surf_origin[2] = 0.0
set_pev(surf_ent, pev_angles, surf_origin)
velocity_by_aim(id, 100+level*4, surf_origin)
surf_origin[2] = 0.0
xs_vec_normalize(surf_origin, surf_origin)
surf_origin[0] *= 100+level*4
surf_origin[1] *= 100+level*4
/*
new while_time = 0
while(floatsqroot(surf_origin[0]*surf_origin[0] + surf_origin[1]*surf_origin[1])<100+level*4 && while_time<level){
surf_origin[0] *= 1.1
surf_origin[1] *= 1.1
while_time++ //lets only do this so many times
}
*/
set_pev(surf_ent, pev_velocity, surf_origin)
engfunc(EngFunc_SetModel, surf_ent, MODELS[MDL_SURF])
set_pev(surf_ent, pev_movetype, MOVETYPE_NOCLIP)
set_pev(surf_ent, pev_solid, SOLID_BBOX)
set_pev(surf_ent, pev_maxs, Float:{100.0,100.0,30.0})
set_pev(surf_ent, pev_mins, Float:{-100.0,-100.0,-30.0})
set_task(0.1,"check_wave",surf_ent)
return SKILL_USED;
}
public check_wave(ent)
{
if(!pev_valid(ent))
return
new id = pev(ent, pev_owner)
new shortestDistance = 9999
new distance, players[32], pnum
new wave_dist = SURF_DISTANCE
AddLvl(id, wave_dist)
// Find all alive players
poke_get_players(players, pnum, PLAYER_ALIVE|PLAYER_MORTAL)
new aid
// Find the closest enemy
for( new i = 0; i < pnum; i++ ){
aid = players[i]
if(!pev_valid(ent))
return
if(!pev_valid(aid))
continue
#if SURF_DUCK==1
if( pev(aid,pev_button) & IN_DUCK )
continue
#endif
distance = fm_get_entity_distance(aid, ent)
if( distance <= shortestDistance )
shortestDistance = distance
if( distance <= wave_dist )
surf_touch(ent, aid)
}
if( shortestDistance>=9999 || (is_user_alive(aid) && fm_get_entity_distance(aid, ent)>1000)){
fm_remove_entity(ent)
return
}
set_task(0.1, "check_wave", ent)
poke_sound(ent, CHAN_VOICE, SND_WADE)
}