I have server running with some plugins, 2 of them have register_touch in them. Once a while I get crash. No idea why, in crash log it say something about sv_touchlinks.
Plugin 1:
PHP Code:
register_touch("weaponbox", "player", "Touch_WeaponBox");
public Touch_WeaponBox(ent, id)
{
if(get_game_mode() != GAME_STARTED)
return PLUGIN_HANDLED;
if(!(entity_get_int(ent, EV_INT_flags) & FL_ONGROUND))
return PLUGIN_CONTINUE;
if(is_user_alive(id))
{
if(get_user_pd(id, PD_CANTPICK))
return PLUGIN_HANDLED;
if(get_user_class(id) == CLASS_BYSTANDER)
set_user_class(id, CLASS_ARMED);
else if(get_user_class(id) == CLASS_MURDERER)
return PLUGIN_HANDLED;
pickup_weapon(id, CSW_DEAGLE);
cs_set_user_bpammo(id, CSW_DEAGLE, 6);
}
return PLUGIN_CONTINUE;
}
What this code is supposed to do is block deagle pickup (only weapon in game) if the conditions are met, else allow to pick it, play hud sprite, give some ammo.
Plugin 2:
PHP Code:
register_touch("mm_knife_throw", "*", "Touch_Knife");
public Touch_Knife(knife, id)
{
if(!is_valid_ent(knife))
return;
if(is_user_alive(id))
{
if(entity_get_int(knife, EV_INT_movetype) == MOVETYPE_NONE)
{
if(mm_get_playerdata(id, PD_CLASS) == CLASS_MURDERER)
give_murder_knife(id, knife);
}
else
{
new owner = entity_get_edict(knife, EV_ENT_owner);
if(owner == id || !owner)
return;
remove_entity(knife);
ExecuteHamB(Ham_Killed, id, owner, 0);
emit_sound(id, CHAN_ITEM, "weapons/knife_hit4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
create_knife(id, 10, 1);
}
}
else
{
entity_set_int(knife, EV_INT_movetype, MOVETYPE_NONE);
new dropped = drop_to_floor(knife);
if(!dropped)
{
new num, Float:origin[3];
entity_get_vector(knife, EV_VEC_origin, origin);
dropped = make_vacant(knife, origin, num, 15.0);
}
if(!dropped)
give_murder_knife(entity_get_edict(knife, EV_ENT_owner), knife);
else
{
entity_set_size(knife, g_szDroppedSize[0], g_szDroppedSize[1]);
drop_to_floor(knife);
entity_set_edict(knife, EV_ENT_owner, 0);
emit_sound(knife, CHAN_ITEM, "weapons/knife_hitwall1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
}
static Float:angles[3];
entity_get_vector(knife, EV_VEC_angles, angles);
angles[0] = 270.0;
entity_set_vector(knife, EV_VEC_angles, angles);
}
}
This code is for throwing a knife. First check if target is alive, if yes, check movetype, if none can pickup, else remove entity, create new and kill target. If target is not alive it tries to drop to floor the knife, if can drop, nice, change size etc. Else, find a vacant place and then drop it(if stuck is sky box, too high from ground etc.)
So what I have noticed is that crash happens when knife (so plugin 2, but cant be sure) hits player, BUT rarely. So I don't know whats wrong.
__________________