I have tried so many ways for hours with no success.
I'm not sure if it is a problem with my plugin planting the bomb automatically or if it is because I'm testing with bots as the bomb is not properly removed from bots.
Anyways I think you guys missunderstood me, I'm trying to remove the +3 points that are given to the planter and defuser. In the thread I linked to in my OP they are talking about how it is hard to properly do this because if the bomb kills a CT the T still get points.
Now I've been experimenting with a lot of things, including:
PHP Code:
new g_BombCarrier;
public plugin_init()
{
register_logevent("logevent_function_p", 3, "2=Spawned_With_The_Bomb")
}
public logevent_function_p() {
g_BombCarrier = get_loguser_index()
}
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 newRound()
{
set_user_frags(g_BombCarrier, get_user_frags(g_BombCarrier) - 3)
}
I think it works but there is no way to know when testing with bots, and my plugin swaps teams every round and points for bomb/defuse is added on next round so I think this fucks shit up.
For example sometimes when the bomb go off, me (who spawned with c4) gets +3, bot that also got bomb gets +3, and random CT gets + 3.
It's way to many things to consider because I am working with team swapping and auto bomb plant, also testing with bots does not help...
I would like to know, before I give up, if there is a proper way to compare frags from one round to another like I'm trying to do here below.
All I want is to remove 3 frags from whoever (maybe multiple) who gained 3 frags in the time between round over and round begin... Thank you!
PHP Code:
new g_playersWithFrags[33][2]
//This is called when bomb explodes:
public GetAllPlayersWithFrags()
{
new iPlayers[ 32 ] , iNum , id , iFrags;
get_players(iPlayers , iNum);
for (new i = 0 ; i < iNum ; i++)
{
id = iPlayers[i];
iFrags = get_user_frags(id);
g_playerWithFrags[id][0] = id;
g_playerWithFrags[id][1] = iFrags;
}
set_task(6.0, "RemoveThreeFrags");
}
//This is triggered by delay so someone got +3 points, who? Remove three points from whoever.
public RemoveThreeFrags()
{
new iPlayers[ 32 ] , iNum , id , iFrags;
get_players(iPlayers , iNum);
for (new i = 0 ; i < iNum ; i++)
{
id = iPlayers[i];
if (get_user_frags(id) == (g_playerWithFrags[id][1] + 3)) // This only works if I remove the "+ 3"
{
ExecuteHam(Ham_AddPoints, id, -3, true);
}
}
}