|
Senior Member
Join Date: May 2011
Location: Philippines
|

05-13-2011
, 21:28
Re: Compiling won't stop or won't even move
|
#8
|
Quote:
Originally Posted by Hunter-Digital
No.
This is indented and (quickly) fixed, untested.
Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
/* define removed because it couldn't be used anyway */
new const g_heartbeat[] = "player/heartbeat1.wav"
new cvar_heartbeathp
new iconstatus // this variable was used but it wasn't created, so I did.
public plugin_precache()
{
precache_sound(g_heartbeat)
}
public plugin_init()
{
register_plugin("MW2 Low Hp", "1.1", "RazielJohn619.")
register_event("Damage", "event_damage", "be", "2>0")
register_event("DeathMsg", "event_deathmsg", "a")
register_event("ResetHUD", "event_resethud", "be")
register_event("Spectator", "event_spectator", "a")
iconstatus = get_user_msgid("StatusIcon") // statusicon's id stored in iconstatus variable
cvar_heartbeathp = register_cvar("heartbeat_hp", "25")
}
public event_damage(id)
{
if(get_user_health(id) > get_pcvar_num(cvar_heartbeathp))
return
sound_heartbeat(id)
show_spr(id)
set_task(4.0, "hide_spr", id)
}
public event_deathmsg()
sound_heartbeat(read_data(2))
public event_resethud(id)
sound_heartbeat(id)
public event_spectator()
sound_heartbeat(read_data(1))
public show_spr(id)
{
message_begin(MSG_ONE_UNRELIABLE, iconstatus, _, id)
write_byte(1) // status (0=hide, 1=show, 2=flash)
write_string("dmg_rad"); // sprite name - can't be custom !!!
write_byte(255) // R
write_byte(0) // G
write_byte(0) // B
message_end()
}
public hide_spr(id)
{
message_begin(MSG_ONE_UNRELIABLE, iconstatus, _, id)
write_byte(0) // status (0=hide, 1=show, 2=flash)
write_string("dmg_rad") // sprite name
// colors not needed when hiding icon
message_end()
}
sound_heartbeat(id)
emit_sound(id, CHAN_AUTO, g_heartbeat, 1.0, ATTN_NORM, SND_STOP, PITCH_NORM)
The cause of your compiler stall may have been any of the fixes I made, even the first "=====..." which wasn't commented out could've been the issue.
Also, this:
Code:
if(!(pev(id,pev_button) & FL_ONGROUND))
Is stupid... why are you checking player's buttons against ONGROUND flag ? FL_* are for pev_flags and IN_* are for pev_button, you can find list of them in includes/hlsdk_const.inc.
You're also checking if player has above 25 hp twice... why ?!
And don't use MSG_ONE for unimportant stuff like an icon, in laggy conditions the server would force itself to send that and could crash players... so just use MSG_ONE_UNRELIABLE for all non-important messages.
EDIT:
Out of curiousity I progresively removed and re-compiled your code, it seems that your float value size for array was the issue, so don't use float as variable array size !
|
thanks man..the .sma now is compiled and there is no error and I checked the code the the code..the line 36, 42, 45, 48, and 70 is an invalid function call, why is that?but compilation is fine..and is the showing of sprite still there? this sprite ..and thanks again man..
|
|