Each player can set LaserMine on the wall.
================================================
Releaseed(Time in JP) Version comment
------------------------------------------------
2006/03/21 1.0 FirstRelease
================================================
Compile and install plugin. (configs/plugins.ini)
================================================
Client command / +setlaser
- can set lasermine on the wall
Server command(CVAR SETTING)
- amx_lasermine_ammo //The setup of ammo (default 2 max 10)
- amx_lasermine_fragmoney //A setup for the reward (default 300 min 100)
- amx_lasermine_cost //The settlement of the cost (default 500 min 100 max 16000)
- amx_lasermine_health //The settlement of the degree of durability (default 500 min 1 max 800)
- amx_lasermine_dmg //The setup of the damage (default 10000 min 1)
================================================
================================================
new player_mines_ent[33][MAX_MINES]
new player_mines_count[33]
new bool:g_settinglaser[33]
public plugin_modules() {
require_module("cstrike")
detonate_mine(iCurrent, iHit) {
entity_get_vector(iCurrent, EV_VEC_origin, vOrigin)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(99) //99 = KillBeam
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_coord(floatround(vOrigin[0]))
write_coord(floatround(vOrigin[1]))
write_coord(floatround(vOrigin[2]))
radius_damage(vOrigin, 1, 50)
//id = Entvars_Get_Edict(iCurrent, EV_ENT_owner)
// clear this from the list of live lasermines
for (slot=0;slot<MAX_MINES;slot++) {
if (player_mines_ent[id][slot] == iCurrent) {
player_mines_ent[id][slot] = -1
player_mines_count[id] = player_mines_count[id] - 1
client_print(id, print_chat, "[LaserMines] Your mine has detonated.")
entity_get_string(iHit, EV_SZ_netname, szNetName, 32)
client_print(id, print_chat, "[LaserMines] %s detonated your mine.",szNetName)
public CreateLaserMine_Progress(id){
g_settinglaser[id] = true
// Progress Bar (Activate) -- This was taken almost directly from xeroblood!
message_begin( MSG_ONE, 108, {0,0,0}, id )
write_byte(1) // duration
write_byte(0) // duration
set_task(1.0, "CreateLaserMine", (TASK_PLANT + id), PID, 1)
public StopCreateLaserMine(id)
if (task_exists((TASK_PLANT + id)))
remove_task((TASK_PLANT + id))
g_settinglaser[id] = false
// Progress Bar (Terminate)
message_begin(MSG_ONE, 108, {0,0,0}, id)
write_byte(0) // duration
write_byte(0) // duration
public bool:CreateCheck(id){
new Status = get_cvar_num( "amx_lasermine" )
client_print(id, print_chat, "[Lasermines] Lasermines are not currently active.")
if(entity_get_int(id, EV_INT_deadflag) != 0)
if(is_user_alive(id) == 0)
if(player_mines_count[id] >= MAX_MINES_CVAR) {
client_print(id, print_chat, "[Lasermines] Maximum mines have been deployed.")
if (cs_get_user_money(id) < MINE_COST) {
client_print(id, print_chat, "[Lasermines] You don't have enough money to set a lasermine! ($%d needed)", MINE_COST)
new Float:vTraceDirection[3]
new Float:vTraceResult[3]
entity_get_vector(id, EV_VEC_origin, vOrigin)
entity_get_vector(id, EV_VEC_v_angle, vAngles)
NewEnt = create_entity("info_target")
entity_set_string(NewEnt, EV_SZ_classname, "lasermine")
entity_set_int(NewEnt, EV_INT_movetype, 5) //5 = movetype_fly, No grav, but collides.
entity_set_int(NewEnt, EV_INT_solid, 0)
entity_set_model(NewEnt, "models/v_tripmine.mdl")
entity_set_float(NewEnt, EV_FL_frame, 0.0)
entity_set_int(NewEnt, EV_INT_body, 3)
entity_set_int(NewEnt, EV_INT_sequence, 7) // 7 = TRIPMINE_WORLD
entity_set_float(NewEnt, EV_FL_framerate, 0.0)
entity_set_float(NewEnt, EV_FL_takedamage, 1.0)
entity_set_float(NewEnt, EV_FL_dmg, 100.0)
entity_set_float(NewEnt, EV_FL_health, float(MINE_HEALTH))
entity_set_int(NewEnt, EV_INT_iuser2, 0) //0 Will be for inactive.
entity_set_vector(NewEnt, EV_VEC_mins, MinBox)
entity_set_vector(NewEnt, EV_VEC_maxs, MaxBox)
velocity_by_aim(id, 64, vTraceDirection)
vTraceEnd[0] = vTraceDirection[0] + vOrigin[0]
vTraceEnd[1] = vTraceDirection[1] + vOrigin[1]
vTraceEnd[2] = vTraceDirection[2] + vOrigin[2]
trace_line(id, vOrigin, vTraceEnd, vTraceResult)
if(trace_normal(id, vOrigin, vTraceEnd, vNormal) == 0) {
client_print(id, print_chat, "[Lasermines] You must plant the lasermine on a wall!")
g_settinglaser[id] = false
public CreateLaserMine(PID[]){
entity_get_vector(id, EV_VEC_origin, vOrigin)
entity_get_vector(id, EV_VEC_v_angle, vAngles)
NewEnt = create_entity("func_breakable"/*"info_target"*/)
return PLUGIN_HANDLED_MAIN
entity_set_string(NewEnt, EV_SZ_classname, "lasermine")
entity_set_int(NewEnt, EV_INT_movetype, 5) //5 = movetype_fly, No grav, but collides.
entity_set_int(NewEnt, EV_INT_solid, 0)
entity_set_model(NewEnt, "models/v_tripmine.mdl")
entity_set_float(NewEnt, EV_FL_frame, 0.0)
entity_set_int(NewEnt, EV_INT_body, 3)
entity_set_int(NewEnt, EV_INT_sequence, 7) // 7 = TRIPMINE_WORLD
entity_set_float(NewEnt, EV_FL_framerate, 0.0)
entity_set_float(NewEnt, EV_FL_takedamage, 1.0)
entity_set_float(NewEnt, EV_FL_dmg, 100.0)
entity_set_float(NewEnt, EV_FL_health, float(MINE_HEALTH))
entity_set_int(NewEnt, EV_INT_iuser2, 0) //0 Will be for inactive.
entity_set_vector(NewEnt, EV_VEC_mins, MinBox)
entity_set_vector(NewEnt, EV_VEC_maxs, MaxBox)
new Float:vTraceDirection[3]
new Float:vTraceResult[3]
velocity_by_aim(id, 64, vTraceDirection)
vTraceEnd[0] = vTraceDirection[0] + vOrigin[0]
vTraceEnd[1] = vTraceDirection[1] + vOrigin[1]
vTraceEnd[2] = vTraceDirection[2] + vOrigin[2]
trace_line(id, vOrigin, vTraceEnd, vTraceResult)
if(trace_normal(id, vOrigin, vTraceEnd, vNormal) == 0) {
g_settinglaser[id] = false
client_print(id, print_chat, "[Lasermines] You must plant the lasermine on a wall!")
return PLUGIN_HANDLED_MAIN
for (slot = 0; slot < MAX_MINES; slot++) {
if (player_mines_ent[id][slot] == -1)
if (slot >= MAX_MINES) //unhandled error
return PLUGIN_HANDLED_MAIN
player_mines_ent[id][slot] = NewEnt
player_mines_count[id] = player_mines_count[id] + 1
vNewOrigin[0] = vTraceResult[0] + (vNormal[0] * 8.0)
vNewOrigin[1] = vTraceResult[1] + (vNormal[1] * 8.0)
vNewOrigin[2] = vTraceResult[2] + (vNormal[2] * 8.0)
entity_set_origin(NewEnt, vNewOrigin)
vector_to_angle(vNormal, vEntAngles)
entity_set_vector(NewEnt, EV_VEC_angles, vEntAngles)
new Float:vTracedBeamEnd[3]
vBeamEnd[0] = vNewOrigin[0] + (vNormal[0] * 8192)
vBeamEnd[1] = vNewOrigin[1] + (vNormal[1] * 8192)
vBeamEnd[2] = vNewOrigin[2] + (vNormal[2] * 8192)
trace_line(-1, vNewOrigin, vBeamEnd, vTracedBeamEnd)
entity_set_vector(NewEnt, EV_VEC_vuser1, vTracedBeamEnd)
emit_sound(NewEnt, CHAN_WEAPON, "weapons/mine_deploy.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
emit_sound(NewEnt, CHAN_VOICE, "weapons/mine_charge.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
num_to_str(NewEnt,args,4)
entity_set_int(NewEnt, LASERMINE_INT_TEAM, int:cs_get_user_team(id))
entity_set_int(NewEnt, LASERMINE_OWNER,id)
g_settinglaser[id] = false
cs_set_user_money(id,cs_get_user_money(id) - MINE_COST)
set_task(3.0, "LaserMine_Activate", 0, args, 4)
return PLUGIN_HANDLED_MAIN
format(ammo, 50, "LaserMines: %i", MAX_MINES_CVAR - player_mines_count[id])
message_begin(MSG_ONE, g_msgStatusText, {0,0,0}, id)
public LaserMine_Activate(MineID[]) {
new EntID = str_to_num(MineID)
new iCurrent = find_ent_by_model(-1,"lasermine","models/v_tripmine.mdl")
entity_get_vector(EntID, EV_VEC_origin, vOrigin)
entity_get_vector(EntID, EV_VEC_vuser1, vEnd)
new teamid = entity_get_int(EntID, LASERMINE_INT_TEAM)
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_coord(floatround(vOrigin[0]))
write_coord(floatround(vOrigin[1]))
write_coord(floatround(vOrigin[2]))
write_coord(floatround(vEnd[0])) //Random
write_coord(floatround(vEnd[1])) //Random
write_coord(floatround(vEnd[2])) //Random
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_coord(floatround(vOrigin[0]))
write_coord(floatround(vOrigin[1]))
write_coord(floatround(vOrigin[2]))
write_coord(floatround(vEnd[0])) //Random
write_coord(floatround(vEnd[1])) //Random
write_coord(floatround(vEnd[2])) //Random
entity_set_int(EntID, EV_INT_iuser2, 1) //1 Will be for active.
entity_set_int(EntID, EV_INT_solid, 2) //1 Will be for active.
emit_sound(EntID, CHAN_VOICE, "weapons/mine_activate.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
public LaserMineThink() {
if(get_cvar_num( "amx_lasermine" ) != 1 )
iCurrent = find_ent_by_class(-1, "lasermine")
if(entity_get_int(iCurrent, EV_INT_iuser2) == 1) {
entity_get_vector(iCurrent, EV_VEC_origin, vOrigin)
entity_get_vector(iCurrent, EV_VEC_vuser1, vEnd)
iHit = trace_line(iCurrent, vOrigin, vEnd, vTrace)
health[0] = entity_get_float(iCurrent, EV_FL_health)
new teamid = entity_get_int(iCurrent, LASERMINE_INT_TEAM)
detonate_mine(iCurrent,-1)
entity_get_string(iHit, EV_SZ_classname, szClassName, 32)
if(equal(szClassName, "player")){
if(is_user_alive(iHit) && !get_user_godmode(iHit)){
new iHitTeam = int:cs_get_user_team(iHit)
new iHitHP = get_user_health(iHit) - LASER_HIT_DMG
new id = entity_get_int(iCurrent,LASERMINE_OWNER)//, szNetName[32]
if (get_cvar_num("mp_friendlyfire") == 0){
cs_set_user_money(id,cs_get_user_money(id) + FRAGMONEY)
//set_user_health(iHit, 0)
//entity_set_float(iHit, EV_FL_health,0.0)
emit_sound(iHit, CHAN_WEAPON, "debris/beamstart9.wav", 1.0, ATTN_NORM, 0, PITCH_NORM )
set_score(id,iHit,hitscore,iHitHP)
//entity_get_string(iHit, EV_SZ_netname, szNetName, 32)
//client_print(id, print_chat, "[LaserMines] %s killed your mine.",szNetName)
cs_set_user_money(id,cs_get_user_money(id) + FRAGMONEY)
cs_set_user_money(id,cs_get_user_money(id) - FRAGMONEY)
//set_user_health(iHit, 0)
//entity_set_float(iHit, EV_FL_health, 0.0)
emit_sound(iHit, CHAN_WEAPON, "debris/beamstart9.wav", 1.0, ATTN_NORM, 0, PITCH_NORM )
set_score(id,iHit,hitscore,iHitHP)
//entity_get_string(iHit, EV_SZ_netname, szNetName, 32)
//client_print(id, print_chat, "[LaserMines] %s killed your mine.",szNetName)
set_user_health(iHit, iHitHP)
message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, {0,0,0}, iHit)
write_byte(LASER_HIT_DMG)
write_byte(LASER_HIT_DMG)
write_coord(floatround(vOrigin[0]))
write_coord(floatround(vOrigin[1]))
write_coord(floatround(vOrigin[2]))
iCurrent = find_ent_by_class(iCurrent, "lasermine")
public LaserMine_LaserThink() {
if(get_cvar_num( "amx_lasermine" ) != 1 )
iCurrent = find_ent_by_class(-1, "lasermine")
if(entity_get_int(iCurrent, EV_INT_iuser2) == 1){
entity_get_vector(iCurrent, EV_VEC_origin, vOrigin)
entity_get_vector(iCurrent, EV_VEC_vuser1, vEnd)
new teamid = entity_get_int(iCurrent, LASERMINE_INT_TEAM)
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_coord(floatround(vOrigin[0]))
write_coord(floatround(vOrigin[1]))
write_coord(floatround(vOrigin[2]))
write_coord(floatround(vEnd[0])) //Random
write_coord(floatround(vEnd[1])) //Random
write_coord(floatround(vEnd[2])) //Random
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_coord(floatround(vOrigin[0]))
write_coord(floatround(vOrigin[1]))
write_coord(floatround(vOrigin[2]))
write_coord(floatround(vEnd[0])) //Random
write_coord(floatround(vEnd[1])) //Random
write_coord(floatround(vEnd[2])) //Random
iCurrent = find_ent_by_class(iCurrent, "lasermine")
public set_score(id,target,hitscore,HP){
// entity_set_float(id, EV_FL_frags, entity_get_float(id, EV_FL_frags) + hitscore)
// entity_set_float(target, EV_FL_frags, entity_get_float(target, EV_FL_frags) + 1.0)
new idfrags = get_user_frags(id) + hitscore
set_user_frags(id, idfrags)
new tarfrags = get_user_frags(target) + 1
set_user_frags(target,tarfrags)
new idteam = int:cs_get_user_team(id)
new iddeaths = get_user_deaths(id)
message_begin(MSG_ALL, g_msgDeathMsg, {0, 0, 0} ,0)
write_string("lasermine")
message_begin(MSG_ALL, g_msgScoreInfo)
set_msg_block(g_msgDeathMsg, BLOCK_ONCE)
//entity_set_float(target, EV_FL_health,float(HP))
set_user_health(target, HP)
entity_set_float(id, EV_FL_maxspeed, 1.0)
public client_PostThink(id) {
if (!g_settinglaser[id] && plsetting[id]){
else if (g_settinglaser[id] && !plsetting[id]) {
plspeed[id] = entity_get_float(id, EV_FL_maxspeed)
entity_set_float(id, EV_FL_maxspeed, 1.0)
plsetting[id] = g_settinglaser[id]
entity_set_float(who, EV_FL_maxspeed, plspeed[who])
public client_connect(id){
for (j=0;j<MAX_MINES;j++) {
player_mines_ent[id][j] = -1
player_mines_count[id] = 0
g_settinglaser[id] = false
public client_disconnect(id){
if(get_cvar_num( "amx_lasermine" ) != 1 )
g_settinglaser[id] = false
if(get_cvar_num( "amx_lasermine" ) != 1 )
plspeed[id] = entity_get_float(id, EV_FL_maxspeed)
g_settinglaser[id] = false
if(get_cvar_num( "amx_lasermine" ) != 1 )
g_settinglaser[id] = false
if(get_cvar_num( "amx_lasermine" ) != 1 )
player_mines_count[id] = 0
for (j=0;j<MAX_MINES;j++) {
if (player_mines_ent[id][j] != -1) {
iCurrent = player_mines_ent[id][j]
entity_get_vector(iCurrent, EV_VEC_origin, vOrigin)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(99) //99 = KillBeam
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_coord(floatround(vOrigin[0]))
write_coord(floatround(vOrigin[1]))
write_coord(floatround(vOrigin[2]))
radius_damage(vOrigin, 1, 50)
player_mines_ent[id][j] = -1
if (get_cvar_num("amx_lasermine_ammo") > 10) {
server_print("[Lasermines] amx_lasermine_ammo can't be greater than 10, setting cvar to 10 now.")
set_cvar_num("amx_lasermine_ammo", 10)
if (get_cvar_num("amx_lasermine_ammo") < 1) {
server_print("[Lasermines] amx_lasermine_ammo can't be less than 1, setting cvar to 1 now.")
set_cvar_num("amx_lasermine_ammo", 1)
if (get_cvar_num("amx_lasermine_health") > 800){
server_print("[Lasermines] amx_lasermine_health can't be greater than 800, setting cvar to 800 now.")
set_cvar_num("amx_lasermine_health", 800)
if (get_cvar_num("amx_lasermine_health") < 1) {
server_print("[Lasermines] amx_lasermine_health can't be less than 1, setting cvar to 1 now.")
set_cvar_num("amx_lasermine_health", 1)
if (get_cvar_num("amx_lasermine_cost") > 16000){
server_print("[Lasermines] amx_lasermine_cost can't be greater than 16000, setting cvar to 16000 now.")
set_cvar_num("amx_lasermine_cost", 16000)
if (get_cvar_num("amx_lasermine_cost") < 100) {
server_print("[Lasermines] amx_lasermine_cost can't be less than 100, setting cvar to 100 now.")
set_cvar_num("amx_lasermine_cost", 100)
if (get_cvar_num("amx_lasermine_dmg") < 1) {
server_print("[Lasermines] amx_lasermine_dmg can't be less than 1, setting cvar to 1 now.")
set_cvar_num("amx_lasermine_dmg", 1)
if (get_cvar_num("amx_lasermine_fragmoney") < 100) {
server_print("[Lasermines] amx_lasermine_dmg can't be less than 100, setting cvar to 100 now.")
set_cvar_num("amx_lasermine_dmg", 100)
MAX_MINES_CVAR = get_cvar_num("amx_lasermine_ammo")
FRAGMONEY = get_cvar_num("amx_lasermine_fragmoney")
MINE_COST = get_cvar_num("amx_lasermine_cost")
MINE_HEALTH = get_cvar_num("amx_lasermine_health")
LASER_HIT_DMG = get_cvar_num("amx_lasermine_dmg")
public plugin_precache() {
precache_sound("weapons/mine_deploy.wav")
precache_sound("weapons/mine_charge.wav")
precache_sound("weapons/mine_activate.wav")
precache_sound("debris/beamstart9.wav")
precache_model("models/v_tripmine.mdl")
beam = precache_model("sprites/laserbeam.spr")
boom = precache_model("sprites/zerogxplode.spr")
public server_changelevel(map[]){
MAX_MINES_CVAR = get_cvar_num("amx_lasermine_ammo")
FRAGMONEY = get_cvar_num("amx_lasermine_fragmoney")
MINE_COST = get_cvar_num("amx_lasermine_cost")
MINE_HEALTH = get_cvar_num("amx_lasermine_health")
LASER_HIT_DMG = get_cvar_num("amx_lasermine_dmg")
register_plugin("LaserMine Entity","1.0","+ARUKARI-")
register_clcmd("+setlaser","CreateLaserMine_Progress")
register_clcmd("-setlaser","StopCreateLaserMine")
register_cvar( "amx_lasermine", "1", FCVAR_UNLOGGED )
register_event("DeathMsg", "DeathEvent", "a")
register_event("CurWeapon", "standing", "be", "1=1")
register_event("ResetHUD", "newround", "b")
register_cvar("amx_lasermine_ammo","2")
register_cvar("amx_lasermine_dmg","10000")
register_cvar("amx_lasermine_cost","500")
register_cvar("amx_lasermine_fragmoney","300")
register_cvar("amx_lasermine_health","500")
g_msgDeathMsg = get_user_msgid("DeathMsg")
g_msgScoreInfo = get_user_msgid("ScoreInfo")
g_msgDamage = get_user_msgid("Damage")
g_msgStatusText = get_user_msgid("StatusText")
set_task(0.01, "LaserMineThink", 0, "", 0, "b")
set_task(0.1, "LaserMine_LaserThink", 0, "", 0, "b")
set_task(2.0,"check_cvars",0,"",0,"b")