/*
HL Model Flinger
Code Used From Ludwig's Roll The Dice Plugin
*/
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#define PLUGIN "HL Model Flinger"
#define VERSION "1.0"
#define AUTHOR "Rara Avis"
new headcrab
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd("m_headcrabs", "m_headcrabs", 0, "<on|off> Flings Headcrabs")
}
public plugin_precache(){
headcrab = precache_model("models/headcrab.mdl")
return PLUGIN_CONTINUE
}
public m_headcrabs(id){
if(!is_user_alive(id))
return PLUGIN_HANDLED; // always use this return for console commands that you make
new vec[3]
new aimvec[3]
new velocityvec[3]
new length
new speed = 800
get_user_origin(id,vec)
get_user_origin(id,aimvec,2)
velocityvec[0]=aimvec[0]-vec[0]
velocityvec[1]=aimvec[1]-vec[1]
velocityvec[2]=aimvec[2]-vec[2]
length=(velocityvec[0]*velocityvec[0]+velocityvec[1]*velocityvec[1]+velocityvec[2]*velocityvec[2])
velocityvec[0]=velocityvec[0]*speed/length
velocityvec[1]=velocityvec[1]*speed/length
velocityvec[2]=velocityvec[2]*speed/length
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(106)
write_coord(vec[0])
write_coord(vec[1])
write_coord(vec[2]+20)
write_coord(velocityvec[0])
write_coord(velocityvec[1])
write_coord(velocityvec[2]+100)
write_angle (0)
write_short (headcrab)
write_byte (2)
write_byte (255)
message_end()
set_task(0.5 , "m_headcrabs" , id , _ , _ , "a" , 25);
// repeat this function on 'id' 25 times at 0.5 second intervals
return PLUGIN_HANDLED; // always remember to add a return at the end
}