Senior Member
Join Date: Jul 2008
Location: Romania
05-18-2010
, 01:45
Re: Bad Camper 1.4.239
#633
A while ago I've made a request for a camper plugin on the Suggestions/Requests forum that will resemble as much as it can a beacon and sound effect from a source mod camp plugin and you've pointed me to your bad-camper plugin while someone posted some code for that beacon efect. I've forgot about that for some time but not that I've remembered it, I've tacked that piece of code and modded it a bit to look a little more like that source mod beacon effect (double rings and beacon sound) Also I've optimized the code a bit since it was a little buggy when crouching/standing up (for example if you were crouching by holding the "+duck" key the rings were placed at your feet, but if you were in the situation when you are force crouching like when you are in a tunnel/duct or something like that and you didn't need to press "+duck" key to crouch, the rings were rendered below your feet)
So I want to ask you if you can integrate this beacon effect into your plugin
...
Thanks in advance if you consider that.
Here's the code:
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#define MAX_PLAYERS 32
#define UPDATE_INTERVAL 3.0
#define TID_TIMER 9124
// new g_snd_path[] = "buttons/blip1.wav"
// new g_snd_path[] = "buttons/blip2.wav"
new g_snd_path[] = "misc/beacon.wav"
new g_sprite_path[] = "sprites/white.spr"
new bool:g_got_beacon[MAX_PLAYERS+1]
new g_max_players
new Float:g_t_time
new g_timer_entid
new g_sprite
public plugin_init(){
register_plugin("Beacon", "1.0", "Sylwester")
g_max_players = get_maxplayers()
register_clcmd("amx_beacon_set", "cmd_beacon_set", ADMIN_KICK, "<@all|@t|@ct|#userid|name> ")
register_clcmd("amx_beacon_rem", "cmd_beacon_rem", ADMIN_KICK, "<@all|@t|@ct|#userid|name> ")
create_timer()
}
public plugin_precache(){
precache_sound(g_snd_path)
g_sprite = precache_model(g_sprite_path)
}
public client_connect(id){
g_got_beacon[id] = false
}
public cmd_beacon_set(id, level, cid){
static players[MAX_PLAYERS], pnum, arg[32], tmp, i, name[32]
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
read_argv(1, arg, 31)
pnum = 0
if(equali(arg, "@all")){
for(i=1; i<=g_max_players; i++)
if(is_user_connected(i))
players[pnum++] = i
}else if(equali(arg, "@t")){
for(i=1; i<=g_max_players; i++)
if(is_user_connected(i) && get_user_team(i)==1)
players[pnum++] = i
}else if(equali(arg, "@ct")){
for(i=1; i<=g_max_players; i++)
if(is_user_connected(i) && get_user_team(i)==2)
players[pnum++] = i
}else if(arg[0] == '#'){
tmp = str_to_num(arg[1])
for(i=1; i<=g_max_players; i++)
if(is_user_connected(i) && get_user_userid(i)==tmp)
players[pnum++] = i
}else{
for(i=1; i<=g_max_players; i++)
if(is_user_connected(i)){
get_user_name(i, name, 31)
if(equal(name, arg)){
pnum = 0
players[pnum++] = i
break
}else if(contain(name, arg)>-1){
players[pnum++] = i
}
}
}
if(pnum<=0){
client_print(id, print_console, "[Beacon]Error: target not found")
return PLUGIN_HANDLED
}
for(i=0; i<pnum; i++){
g_got_beacon[players[i]] = true
}
return PLUGIN_HANDLED
}
public cmd_beacon_rem(id, level, cid){
static players[MAX_PLAYERS], pnum, arg[32], tmp, i, name[32]
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
read_argv(1, arg, 31)
pnum = 0
if(equali(arg, "@all")){
for(i=1; i<=g_max_players; i++)
if(is_user_connected(i))
players[pnum++] = i
}else if(equali(arg, "@t")){
for(i=1; i<=g_max_players; i++)
if(is_user_connected(i) && get_user_team(i)==1)
players[pnum++] = i
}else if(equali(arg, "@ct")){
for(i=1; i<=g_max_players; i++)
if(is_user_connected(i) && get_user_team(i)==2)
players[pnum++] = i
}else if(arg[0] == '#'){
tmp = str_to_num(arg[1])
for(i=1; i<=g_max_players; i++)
if(is_user_connected(i) && get_user_userid(i)==tmp)
players[pnum++] = i
}else{
for(i=1; i<=g_max_players; i++)
if(is_user_connected(i)){
get_user_name(i, name, 31)
if(equal(name, arg)){
pnum = 0
players[pnum++] = i
break
}else if(contain(name, arg)>-1){
players[pnum++] = i
}
}
}
if(pnum<=0){
client_print(id, print_console, "[Beacon]Error: target not found")
return PLUGIN_HANDLED
}
for(i=0; i<pnum; i++){
g_got_beacon[players[i]] = false
}
return PLUGIN_HANDLED
}
public create_timer(){
g_timer_entid = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"))
if(pev_valid(g_timer_entid)){
set_pev(g_timer_entid, pev_classname, "beacon_timer")
global_get(glb_time, g_t_time)
set_pev(g_timer_entid, pev_nextthink, g_t_time + UPDATE_INTERVAL)
register_forward(FM_Think,"fwd_Think")
}else{
log_amx("Warning: Failed to create timer entity, using task instead")
set_task(UPDATE_INTERVAL, "timer_cycle", TID_TIMER, "", 0, "b")
}
}
public fwd_Think(Ent){
if(Ent != g_timer_entid)
return FMRES_IGNORED
g_t_time += UPDATE_INTERVAL
set_pev(Ent, pev_nextthink, g_t_time)
timer_cycle()
return FMRES_IGNORED
}
public plugin_unpause(){
if(pev_valid(g_timer_entid)){
global_get(glb_time, g_t_time)
g_t_time += UPDATE_INTERVAL
set_pev(g_timer_entid, pev_nextthink, g_t_time)
}
}
public timer_cycle(){
static id
for(id=1; id<=g_max_players; id++)
if(g_got_beacon[id] && is_user_alive(id)){
show_beacon(id)
set_task(0.2, "show_beacon2", id)
}
}
public show_beacon(id){
static origin[3]
// emit_sound(id, CHAN_ITEM, g_snd_path, 1.0, ATTN_NORM, 0, PITCH_NORM)
get_user_origin(id, origin)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMCYLINDER)
write_coord(origin[0]) //position.x
write_coord(origin[1]) //position.y
new flags = entity_get_int(id, EV_INT_flags)
if (flags & FL_DUCKING) write_coord(origin[2]-8) //position.z (in duck)
else write_coord(origin[2]-26) //position.z
write_coord(origin[0]) //axis.x
write_coord(origin[1]) //axis.y
write_coord(origin[2]+200) //axis.z
write_short(g_sprite) //sprite index
write_byte(0) //starting frame
write_byte(1) //frame rate in 0.1's
write_byte(6) //life in 0.1's
write_byte(10) //line width in 0.1's
write_byte(1) //noise amplitude in 0.01's
if(cs_get_user_team(id) == CS_TEAM_T){
write_byte(255) //red
write_byte(0) //green
write_byte(0) //blue
}
else if(cs_get_user_team(id) == CS_TEAM_CT){
write_byte(0) //red
write_byte(0) //green
write_byte(255) //blue
}
write_byte(200) //brightness
write_byte(6) //scroll speed in 0.1's
message_end()
}
public show_beacon2(id){
static origin[3]
emit_sound(id, CHAN_ITEM, g_snd_path, 1.0, ATTN_NORM, 0, PITCH_NORM)
get_user_origin(id, origin)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMCYLINDER)
write_coord(origin[0]) //position.x
write_coord(origin[1]) //position.y
new flags = entity_get_int(id, EV_INT_flags)
if (flags & FL_DUCKING) write_coord(origin[2]-8) //position.z (in duck)
else write_coord(origin[2]-26) //position.z
write_coord(origin[0]) //axis.x
write_coord(origin[1]) //axis.y
write_coord(origin[2]+200) //axis.z
write_short(g_sprite) //sprite index
write_byte(0) //starting frame
write_byte(1) //frame rate in 0.1's
write_byte(6) //life in 0.1's
write_byte(10) //line width in 0.1's
write_byte(1) //noise amplitude in 0.01's
if(cs_get_user_team(id) == CS_TEAM_T){
write_byte(255) //red
write_byte(0) //green
write_byte(0) //blue
}
else if(cs_get_user_team(id) == CS_TEAM_CT){
write_byte(0) //red
write_byte(0) //green
write_byte(255) //blue
}
write_byte(200) //brightness
write_byte(6) //scroll speed in 0.1's
message_end()
}
Here are some screenies
:
And the beacon sound...
Edit:
BTW... I've found the Suggestions/Requests Topic where I've requested the source-ish camper effect:
http://forums.alliedmods.net/showthr...ghlight=camper
Attached Thumbnails
Attached Files
Last edited by Costin83; 05-18-2010 at 01:49 .