The whole task can be done quite simple, take a look
Code:
new Float:v1[3], Float:v2[3]
pev(id, pev_origin, v1) // origin of the 1st player
pev(id2, pev_origin, v2) // origin of the 2nd player
xs_vec_sub(v2, v1, v1) // vector 1st->2nd
engfunc(EngFunc_VecToAngles, v1, v1) // convert origin to angle