I recently learned how to use the temporary event commands, and I decided to test my skills. I wanted to see if I was capable of making a laser beam like the plugin Ludwig Van Laser Guns. I understand that this was made, and Im not going to post the finished product. This is simply for personal use and practice at my writing skills. I would like some feedback on this. I would like to know if there are better ways to write this, and if certian things wont work. I dont have a server myself, and I can only test it on my lan server. Im not sure if the laser does dmg, other ppl cant get in my server. Heres the code:
Code:
/////////////////////
#include <amxmodx>
#include <cstrike>
#include <fun>
/////////////////////
#define TEAM_T 1
#define TEAM_CT 2
/////////////////////
new origin[33][3]
new laser, red, blue
/////////////////////
public plugin_init()
{
register_plugin("Laser Cannons","0.1","Knekter")
register_clcmd("fire_laser","laser_init")
register_clcmd("say /lasers","laser_help")
register_logevent("StartRound",2,"1=Round_Start")
}
/////////////////////
public plugin_precache()
{
laser = precache_model("sprites/laserbeam.spr")
precache_sound("weapons/electro5.wav")
precache_sound("buttons/bell1.wav")
return PLUGIN_CONTINUE
}
/////////////////////
public StartRound()
{
set_hudmessage(0, 255, 0, -1.0, 0.3, 0, 1.0, 5.0, 0.1, 0.2, 4)
show_hudmessage(0,"Lasers are currently enabled! Say /lasers for help")
}
public laser_init(id)
{
if(get_user_armor(id) < 10)
{
client_print(id,print_chat,"[AMXX] You ran of energy for your laser gun!")
emit_sound(0,CHAN_ITEM,"buttons/bell1.wav",1.0,ATTN_NORM,0,PITCH_NORM)
return PLUGIN_HANDLED
}
new armor = get_user_armor(id)
set_user_armor(id,armor - 10)
new name[33]
get_user_name(id,name,32)
new team = cs_get_user_team(id)
if(team == 1)
{
red = 255
blue = 0
}
else
{
red = 0
blue = 255
}
new victum, pHit
new vname[33]
get_user_aiming(id,victum,pHit,9999)
get_user_name(victum,vname,32)
get_user_origin(id,origin[id],3)
emit_sound(0,CHAN_ITEM,"weapons/electro5.wav",1.0,ATTN_NORM,0,PITCH_NORM)
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(1) // TE_BEAMENTPOINT
write_short(id) // ent
write_coord(origin[id][0]) // x
write_coord(origin[id][1]) // y
write_coord(origin[id][2]) // z
write_short(laser) // sprite
write_byte(1) // start frame
write_byte(1) // framerate
write_byte(2) // life
write_byte(10) // width
write_byte(0) // noise
write_byte(red)
write_byte(0)
write_byte(blue)
write_byte(200)
write_byte(1) // scroll speed
message_end()
new vHP = get_user_health(vname[id])
if(pHit == 1)
{
user_kill(vname[id])
return PLUGIN_HANDLED
}
if(pHit == 2 || pHit == 3)
{
vHP = (vHP - 30)
set_user_health(vname[id],vHP)
return PLUGIN_HANDLED
}
if(pHit == 4 || pHit == 5)
{
vHP = (vHP - 20)
set_user_health(vname[id],vHP)
return PLUGIN_HANDLED
}
if(pHit == 6 || pHit == 7)
{
vHP = (vHP - 15)
set_user_health(vname[id],vHP)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public laser_help(id)
{
show_motd(id,"/addons/amxx/laser.txt","Laser Help")
return PLUGIN_HANDLED
}