rehlds/ReAPI

Server Crash when get entity owner in SetTouch Callback

Closed this issue · 2 comments

Plugin Code:

public CreateBomb(iOwner)
{
	new ent = rg_create_entity("info_target")
	if (!is_entity(ent))
		return;
	
	static Float:vOrigin[3]; get_entvar(iOwner, var_origin, vOrigin);
	static Float:vViewOfs[3]; get_entvar(iOwner, var_view_ofs, vViewOfs);
	xs_vec_add(vOrigin, vViewOfs, vOrigin)
	static Float:vViewAngle[3]; get_entvar(iOwner, var_v_angle, vViewAngle);
	static Float:vPushangle[3]; get_entvar(iOwner, var_punchangle, vPushangle);
	static Float:vForward[3]; 
	xs_vec_add(vViewAngle, vPushangle, vViewAngle);
	angle_vector(vViewAngle, ANGLEVECTOR_FORWARD, vForward);

	set_entvar(ent ,var_model, W_Model)
	set_entvar(ent, var_owner, iOwner)
	set_entvar(ent, var_classname, "bomb")
	set_entvar(ent, var_mins, Float:{-1.0, -1.0, -1.0})
	set_entvar(ent, var_maxs, Float:{1.0, 1.0, 1.0})
	set_entvar(ent, var_origin, vOrigin)

	set_entvar(ent, var_movetype, MOVETYPE_FLY)
	set_entvar(ent, var_solid, SOLID_TRIGGER)
	set_entvar(ent, var_nextthink, get_gametime())

	xs_vec_mul_scalar(vForward, 100.0, vForward);
	set_entvar(ent, var_velocity, vForward);

	SetTouch(ent, "Bomb_Touched")
}

public Bomb_Touched(const Entity, const Toucher)
{
	client_print(0, print_chat, "%d", get_member(Entity, var_owner))
}

get_member is for specific CBase* class attributes. Use get_entvar for retrieving owner

get_member is for specific CBase* class attributes. Use get_entvar for retrieving owner

Thinks! my mistake!