For some reason I'm getting a runtime error on set_user_frags, but the plugin is working. o.O
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <csstats>
#include <cstrike>
#include <fun>
/*Description
What this plugin does is determine a user's overall kills/deaths
and sets their scores accordingly. So, if I have for example 300 kills and 123 deaths,
when I join the server my score will be 300-123.
Credits:
GHW_Chronic - Coding help.
v3x - Coding help.
Changelog
v. 1.0 - Original Coding
v. 1.1 - Addition of Description, credits, changelog
v. 1.2 - Coding Optimization
v. 1.3 - Removed sv_restartround bug.
v. 1.4 - Added new event.
v. 1.5 - Fixed bug! :)*/
new bool:gSet[33];
new gStats[8];
new gBodyhits[8];
public plugin_init()
{
register_plugin("Set Stats", "1.5", "Satan")
register_event("ResetHUD" , "round", "be")
register_event("TextMsg", "event_game_will_restart", "a", "2=#Game_will_restart_in")
register_logevent("new_round" , 2 , "1=Round_Start");
register_logevent("MyFuncRoundStart", 2, "0=World triggered", "1=Round_Start")
}
//-------------------------------------------------------------------
public client_connect(id)
{
gSet[id] = false
}
//-------------------------------------------------------------------
public new_round(id)
{
set_task(0.1, "set_stats", id)
}
//-------------------------------------------------------------------
public round(id)
{
set_task(0.1, "set_stats", id)
}
//-------------------------------------------------------------------
public event_game_will_restart(id)
{
set_task(0.1, "set_stats", id)
}
//-------------------------------------------------------------------
public MyFuncRoundStart(id)
{
set_task(0.1, "set_stats", id)
}
//-------------------------------------------------------------------
public set_stats(id)
{
get_user_stats(id, gStats, gBodyhits)
new kills = get_user_frags(id)
new timesdied = get_user_deaths(id)
new frags = gStats[0]
new deaths = gStats[1]
if(!gSet[id] && frags != kills || deaths != timesdied)
{
set_user_frags(id, frags)
cs_set_user_deaths(id, deaths);
gSet[id] = true;
}
return PLUGIN_CONTINUE
}