It would be something like %player.emote(hateImage,1); except you'd need to search through datablocks to find the emote image for the pain ones rather than the hate one. (The 1 is for the 'spam protection' thing, stopping you from going /alarm /alarm /alarm /alarm to spam the server)