I'm having some trouble on updating the scoreboard with my plugin.
The problem I'm having is that the scoreboard won't update itself after I rescued the hostages.
Here's the code on what I have so far:
Code:
#include <amxmodx>
//#include <cstrike>
#include <fun>
static const PLUGIN_NAME[] = "Hostage Score Management"
static const PLUGIN_VERSION[] = "1.1"
static const PLUGIN_AUTHOR[] = "Locks"
new pcvarfragreward
new pcvarfragpenalty
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
pcvarfragreward = register_cvar("hostage_fragreward", "1")
pcvarfragpenalty = register_cvar("hostage_fragpenalty", "1")
register_event("TextMsg", "hostage_killed", "b", "2&#Killed_Hostage")
register_logevent("rescued_hostage", 3, "2=Rescued_A_Hostage")
}
// VEN's stock from CS Bomb Scripting [FAQ/Tutorial]
// <a href="http://forums.alliedmods.net/showthread.php?t=40164" target="_blank" rel="nofollow noopener">http://forums.alliedmods.net/showthread.php?t=40164</a>
stock get_loguser_index()
{
new loguser[80], name[32]
read_logargv(0, loguser, 79)
parse_loguser(loguser, name, 31)
return get_user_index(name)
}
public rescued_hostage()
{
new id = get_loguser_index()
new frags = get_user_frags(id)
new reward = get_pcvar_num(pcvarfragreward)
if ( !is_user_alive(id) /*|| get_pcvar_num(pcvarfragreward) == 0*/ )
return PLUGIN_HANDLED
set_user_frags(id, frags + reward)
new score_info = get_user_msgid("ScoreInfo")
message_begin(MSG_ALL, score_info)
write_byte(id) // Index
write_short(get_user_frags(id)) // Frags
write_short(get_user_deaths(id)) // Death
write_short(0) // ...
write_short(1) // TEAM
message_end()
return PLUGIN_HANDLED
}
public hostage_killed(id)
{
new frags = get_user_frags(id)
new penalty = get_pcvar_num(pcvarfragpenalty)
if ( !is_user_alive(id) || get_pcvar_num(pcvarfragpenalty) == 0 )
return PLUGIN_HANDLED
set_user_frags(id, frags - penalty)
new score_info = get_user_msgid("ScoreMsg")
message_begin(MSG_ALL, score_info)
write_byte(id)
write_short(get_user_frags(id))
write_short(get_user_deaths(id))
write_short(0)
write_short(1)
message_end()
return PLUGIN_HANDLED
}